@@ -53,7 +53,7 @@ public Document Convert(Document document)
5353 return _newDocument ;
5454 }
5555
56- public override void Visit ( Document document )
56+ public override void VisitDocument ( Document document )
5757 {
5858 _newDocument = new Document
5959 {
@@ -131,10 +131,10 @@ public override void Visit(Document document)
131131 }
132132 }
133133
134- base . Visit ( document ) ;
134+ base . VisitDocument ( document ) ;
135135 }
136136
137- public override void Visit ( Container elements )
137+ public override void VisitContainer ( Container elements )
138138 {
139139 if ( _topLevel )
140140 {
@@ -209,10 +209,10 @@ public override void Visit(Container elements)
209209 }
210210 }
211211
212- base . Visit ( elements ) ;
212+ base . VisitContainer ( elements ) ;
213213 }
214214
215- public override void Visit ( Source source )
215+ public override void VisitSource ( Source source )
216216 {
217217 // remove method attributes as the elastic doc generation doesn't like them; it
218218 // expects a linenumbering in the index 2 position of a source block
@@ -226,18 +226,18 @@ public override void Visit(Source source)
226226 // (elastic docs generation does not like this callout format)
227227 source . Text = Regex . Replace ( source . Text . Replace ( "\t " , " " ) , @"//[ \t]*\<(\d+)\>.*" , "<$1>" ) ;
228228
229- base . Visit ( source ) ;
229+ base . VisitSource ( source ) ;
230230 }
231231
232- public override void Visit ( SectionTitle sectionTitle )
232+ public override void VisitSectionTitle ( SectionTitle sectionTitle )
233233 {
234234 // Generate an anchor for all top level section titles
235235 if ( this . _document . IndexOf ( sectionTitle ) == 0 && ! sectionTitle . Attributes . HasAnchor )
236236 {
237237 var builder = new StringBuilder ( ) ;
238238 using ( var writer = new AsciiDocVisitor ( new StringWriter ( builder ) ) )
239239 {
240- writer . Visit ( ( InlineContainer ) sectionTitle ) ;
240+ writer . VisitInlineContainer ( sectionTitle ) ;
241241 }
242242
243243 var title = builder . ToString ( ) . PascalToHyphen ( ) ;
@@ -257,88 +257,87 @@ public override void Visit(SectionTitle sectionTitle)
257257 Ids . Add ( key , _destination . FullName ) ;
258258 }
259259
260- base . Visit ( sectionTitle ) ;
260+ base . VisitSectionTitle ( sectionTitle ) ;
261261 }
262262
263- public override void Visit ( AttributeEntry attributeEntry )
263+ public override void VisitAttributeEntry ( AttributeEntry attributeEntry )
264264 {
265- if ( attributeEntry . Name == "xml-docs" )
266- {
267- var value = attributeEntry . Value ;
268-
269- if ( string . IsNullOrEmpty ( value ) )
270- {
271- base . Visit ( attributeEntry ) ;
272- return ;
273- }
274-
275- var parts = value . Split ( ':' ) ;
276- var assemblyName = parts [ 0 ] ;
277- var typeName = parts [ 1 ] ;
278-
279- string xmlDocsFile ;
280- Assembly assembly ;
281- string assemblyNamespace ;
282-
283- //TODO: tidy this up
284- switch ( assemblyName . ToLowerInvariant ( ) )
285- {
286- case "elasticsearch.net" :
287- xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Elasticsearch.Net" , "net46" , "Elasticsearch.Net.XML" ) ) ;
288- assembly = typeof ( ElasticLowLevelClient ) . Assembly ;
289- assemblyNamespace = typeof ( ElasticLowLevelClient ) . Namespace ;
290- break ;
291- default :
292- xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Nest" , "net46" , "Nest.XML" ) ) ;
293- assembly = typeof ( ElasticClient ) . Assembly ;
294- assemblyNamespace = typeof ( ElasticClient ) . Namespace ;
295- break ;
296- }
297-
298- // build xml documentation file on the fly if it doesn't exist
299- if ( ! File . Exists ( xmlDocsFile ) )
300- {
301- var project = _projects [ assemblyName ] ;
302- var compilation = project . GetCompilationAsync ( ) . Result ;
303-
304- using ( var peStream = new MemoryStream ( ) )
305- using ( var commentStream = File . Create ( xmlDocsFile ) )
306- {
307- var emitResult = compilation . Emit ( peStream , null , commentStream ) ;
308-
309- if ( ! emitResult . Success )
310- {
311- var failures = emitResult . Diagnostics . Where ( diagnostic =>
312- diagnostic . IsWarningAsError ||
313- diagnostic . Severity == DiagnosticSeverity . Error ) ;
314-
315- var builder = new StringBuilder ( $ "Unable to emit compilation for: { assemblyName } ") ;
316- foreach ( var diagnostic in failures )
317- {
318- builder . AppendLine ( $ "{ diagnostic . Id } : { diagnostic . GetMessage ( ) } ") ;
319- }
320- builder . AppendLine ( new string ( '-' , 30 ) ) ;
321-
322- throw new Exception ( builder . ToString ( ) ) ;
323- }
324- }
325- }
326-
327- var assemblyMembers = DocReader . Read ( assembly , xmlDocsFile ) ;
328- var type = assembly . GetType ( assemblyNamespace + "." + typeName ) ;
329- var visitor = new XmlDocsVisitor ( type ) ;
330-
331- visitor . VisitAssembly ( assemblyMembers ) ;
332- if ( visitor . LabeledListItems . Any ( ) )
333- {
334- var labeledList = new LabeledList ( ) ;
335- foreach ( var item in visitor . LabeledListItems . OrderBy ( l => l . Label ) )
336- {
337- labeledList . Items . Add ( item ) ;
338- }
339- _newDocument . Insert ( _newDocument . IndexOf ( attributeEntry ) , labeledList ) ;
340- }
341- }
265+ if ( attributeEntry . Name != "xml-docs" ) return ;
266+
267+ var value = attributeEntry . Value ;
268+
269+ if ( string . IsNullOrEmpty ( value ) )
270+ {
271+ base . VisitAttributeEntry ( attributeEntry ) ;
272+ return ;
273+ }
274+
275+ var parts = value . Split ( ':' ) ;
276+ var assemblyName = parts [ 0 ] ;
277+ var typeName = parts [ 1 ] ;
278+
279+ string xmlDocsFile ;
280+ Assembly assembly ;
281+ string assemblyNamespace ;
282+
283+ //TODO: tidy this up
284+ switch ( assemblyName . ToLowerInvariant ( ) )
285+ {
286+ case "elasticsearch.net" :
287+ xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Elasticsearch.Net" , "net46" , "Elasticsearch.Net.XML" ) ) ;
288+ assembly = typeof ( ElasticLowLevelClient ) . Assembly ;
289+ assemblyNamespace = typeof ( ElasticLowLevelClient ) . Namespace ;
290+ break ;
291+ default :
292+ xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Nest" , "net46" , "Nest.XML" ) ) ;
293+ assembly = typeof ( ElasticClient ) . Assembly ;
294+ assemblyNamespace = typeof ( ElasticClient ) . Namespace ;
295+ break ;
296+ }
297+
298+ // build xml documentation file on the fly if it doesn't exist
299+ if ( ! File . Exists ( xmlDocsFile ) )
300+ {
301+ var project = _projects [ assemblyName ] ;
302+ var compilation = project . GetCompilationAsync ( ) . Result ;
303+
304+ using ( var peStream = new MemoryStream ( ) )
305+ using ( var commentStream = File . Create ( xmlDocsFile ) )
306+ {
307+ var emitResult = compilation . Emit ( peStream , null , commentStream ) ;
308+
309+ if ( ! emitResult . Success )
310+ {
311+ var failures = emitResult . Diagnostics . Where ( diagnostic =>
312+ diagnostic . IsWarningAsError ||
313+ diagnostic . Severity == DiagnosticSeverity . Error ) ;
314+
315+ var builder = new StringBuilder ( $ "Unable to emit compilation for: { assemblyName } ") ;
316+ foreach ( var diagnostic in failures )
317+ {
318+ builder . AppendLine ( $ "{ diagnostic . Id } : { diagnostic . GetMessage ( ) } ") ;
319+ }
320+ builder . AppendLine ( new string ( '-' , 30 ) ) ;
321+
322+ throw new Exception ( builder . ToString ( ) ) ;
323+ }
324+ }
325+ }
326+
327+ var assemblyMembers = DocReader . Read ( assembly , xmlDocsFile ) ;
328+ var type = assembly . GetType ( assemblyNamespace + "." + typeName ) ;
329+ var visitor = new XmlDocsVisitor ( type ) ;
330+
331+ visitor . VisitAssembly ( assemblyMembers ) ;
332+ if ( visitor . LabeledListItems . Any ( ) )
333+ {
334+ var labeledList = new LabeledList ( ) ;
335+ foreach ( var item in visitor . LabeledListItems . OrderBy ( l => l . Label ) )
336+ {
337+ labeledList . Items . Add ( item ) ;
338+ }
339+ _newDocument . Insert ( _newDocument . IndexOf ( attributeEntry ) , labeledList ) ;
340+ }
342341 }
343342
344343 private void RemoveDocDirectoryAttribute ( Document document )
@@ -358,7 +357,7 @@ private bool LastSectionTitleMatches(Func<string, bool> predicate)
358357 var builder = new StringBuilder ( ) ;
359358 using ( var visitor = new AsciiDocVisitor ( new StringWriter ( builder ) ) )
360359 {
361- visitor . Visit ( ( InlineContainer ) lastSectionTitle ) ;
360+ visitor . VisitInlineContainer ( lastSectionTitle ) ;
362361 }
363362
364363 return predicate ( builder . ToString ( ) ) ;
0 commit comments