@@ -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 {
@@ -133,10 +133,10 @@ public override void Visit(Document document)
133133 }
134134 }
135135
136- base . Visit ( document ) ;
136+ base . VisitDocument ( document ) ;
137137 }
138138
139- public override void Visit ( Container elements )
139+ public override void VisitContainer ( Container elements )
140140 {
141141 if ( _topLevel )
142142 {
@@ -211,10 +211,10 @@ public override void Visit(Container elements)
211211 }
212212 }
213213
214- base . Visit ( elements ) ;
214+ base . VisitContainer ( elements ) ;
215215 }
216216
217- public override void Visit ( Source source )
217+ public override void VisitSource ( Source source )
218218 {
219219 // remove method attributes as the elastic doc generation doesn't like them; it
220220 // expects a linenumbering in the index 2 position of a source block
@@ -228,18 +228,18 @@ public override void Visit(Source source)
228228 // (elastic docs generation does not like this callout format)
229229 source . Text = Regex . Replace ( source . Text . Replace ( "\t " , " " ) , @"//[ \t]*\<(\d+)\>.*" , "<$1>" ) ;
230230
231- base . Visit ( source ) ;
231+ base . VisitSource ( source ) ;
232232 }
233233
234- public override void Visit ( SectionTitle sectionTitle )
234+ public override void VisitSectionTitle ( SectionTitle sectionTitle )
235235 {
236236 // Generate an anchor for all top level section titles
237237 if ( this . _document . IndexOf ( sectionTitle ) == 0 && ! sectionTitle . Attributes . HasAnchor )
238238 {
239239 var builder = new StringBuilder ( ) ;
240240 using ( var writer = new AsciiDocVisitor ( new StringWriter ( builder ) ) )
241241 {
242- writer . Visit ( ( InlineContainer ) sectionTitle ) ;
242+ writer . VisitInlineContainer ( sectionTitle ) ;
243243 }
244244
245245 var title = builder . ToString ( ) . PascalToHyphen ( ) ;
@@ -259,88 +259,87 @@ public override void Visit(SectionTitle sectionTitle)
259259 Ids . Add ( key , _destination . FullName ) ;
260260 }
261261
262- base . Visit ( sectionTitle ) ;
262+ base . VisitSectionTitle ( sectionTitle ) ;
263263 }
264264
265- public override void Visit ( AttributeEntry attributeEntry )
265+ public override void VisitAttributeEntry ( AttributeEntry attributeEntry )
266266 {
267- if ( attributeEntry . Name == "xml-docs" )
268- {
269- var value = attributeEntry . Value ;
270-
271- if ( string . IsNullOrEmpty ( value ) )
272- {
273- base . Visit ( attributeEntry ) ;
274- return ;
275- }
276-
277- var parts = value . Split ( ':' ) ;
278- var assemblyName = parts [ 0 ] ;
279- var typeName = parts [ 1 ] ;
280-
281- string xmlDocsFile ;
282- Assembly assembly ;
283- string assemblyNamespace ;
284-
285- //TODO: tidy this up
286- switch ( assemblyName . ToLowerInvariant ( ) )
287- {
288- case "elasticsearch.net" :
289- xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Elasticsearch.Net" , "net46" , "Elasticsearch.Net.XML" ) ) ;
290- assembly = typeof ( ElasticLowLevelClient ) . Assembly ;
291- assemblyNamespace = typeof ( ElasticLowLevelClient ) . Namespace ;
292- break ;
293- default :
294- xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Nest" , "net46" , "Nest.XML" ) ) ;
295- assembly = typeof ( ElasticClient ) . Assembly ;
296- assemblyNamespace = typeof ( ElasticClient ) . Namespace ;
297- break ;
298- }
299-
300- // build xml documentation file on the fly if it doesn't exist
301- if ( ! File . Exists ( xmlDocsFile ) )
302- {
303- var project = _projects [ assemblyName ] ;
304- var compilation = project . GetCompilationAsync ( ) . Result ;
305-
306- using ( var peStream = new MemoryStream ( ) )
307- using ( var commentStream = File . Create ( xmlDocsFile ) )
308- {
309- var emitResult = compilation . Emit ( peStream , null , commentStream ) ;
310-
311- if ( ! emitResult . Success )
312- {
313- var failures = emitResult . Diagnostics . Where ( diagnostic =>
314- diagnostic . IsWarningAsError ||
315- diagnostic . Severity == DiagnosticSeverity . Error ) ;
316-
317- var builder = new StringBuilder ( $ "Unable to emit compilation for: { assemblyName } ") ;
318- foreach ( var diagnostic in failures )
319- {
320- builder . AppendLine ( $ "{ diagnostic . Id } : { diagnostic . GetMessage ( ) } ") ;
321- }
322- builder . AppendLine ( new string ( '-' , 30 ) ) ;
323-
324- throw new Exception ( builder . ToString ( ) ) ;
325- }
326- }
327- }
328-
329- var assemblyMembers = DocReader . Read ( assembly , xmlDocsFile ) ;
330- var type = assembly . GetType ( assemblyNamespace + "." + typeName ) ;
331- var visitor = new XmlDocsVisitor ( type ) ;
332-
333- visitor . VisitAssembly ( assemblyMembers ) ;
334- if ( visitor . LabeledListItems . Any ( ) )
335- {
336- var labeledList = new LabeledList ( ) ;
337- foreach ( var item in visitor . LabeledListItems . OrderBy ( l => l . Label ) )
338- {
339- labeledList . Items . Add ( item ) ;
340- }
341- _newDocument . Insert ( _newDocument . IndexOf ( attributeEntry ) , labeledList ) ;
342- }
343- }
267+ if ( attributeEntry . Name != "xml-docs" ) return ;
268+
269+ var value = attributeEntry . Value ;
270+
271+ if ( string . IsNullOrEmpty ( value ) )
272+ {
273+ base . VisitAttributeEntry ( attributeEntry ) ;
274+ return ;
275+ }
276+
277+ var parts = value . Split ( ':' ) ;
278+ var assemblyName = parts [ 0 ] ;
279+ var typeName = parts [ 1 ] ;
280+
281+ string xmlDocsFile ;
282+ Assembly assembly ;
283+ string assemblyNamespace ;
284+
285+ //TODO: tidy this up
286+ switch ( assemblyName . ToLowerInvariant ( ) )
287+ {
288+ case "elasticsearch.net" :
289+ xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Elasticsearch.Net" , "net46" , "Elasticsearch.Net.XML" ) ) ;
290+ assembly = typeof ( ElasticLowLevelClient ) . Assembly ;
291+ assemblyNamespace = typeof ( ElasticLowLevelClient ) . Namespace ;
292+ break ;
293+ default :
294+ xmlDocsFile = Path . GetFullPath ( Path . Combine ( Program . BuildOutputPath , "Nest" , "net46" , "Nest.XML" ) ) ;
295+ assembly = typeof ( ElasticClient ) . Assembly ;
296+ assemblyNamespace = typeof ( ElasticClient ) . Namespace ;
297+ break ;
298+ }
299+
300+ // build xml documentation file on the fly if it doesn't exist
301+ if ( ! File . Exists ( xmlDocsFile ) )
302+ {
303+ var project = _projects [ assemblyName ] ;
304+ var compilation = project . GetCompilationAsync ( ) . Result ;
305+
306+ using ( var peStream = new MemoryStream ( ) )
307+ using ( var commentStream = File . Create ( xmlDocsFile ) )
308+ {
309+ var emitResult = compilation . Emit ( peStream , null , commentStream ) ;
310+
311+ if ( ! emitResult . Success )
312+ {
313+ var failures = emitResult . Diagnostics . Where ( diagnostic =>
314+ diagnostic . IsWarningAsError ||
315+ diagnostic . Severity == DiagnosticSeverity . Error ) ;
316+
317+ var builder = new StringBuilder ( $ "Unable to emit compilation for: { assemblyName } ") ;
318+ foreach ( var diagnostic in failures )
319+ {
320+ builder . AppendLine ( $ "{ diagnostic . Id } : { diagnostic . GetMessage ( ) } ") ;
321+ }
322+ builder . AppendLine ( new string ( '-' , 30 ) ) ;
323+
324+ throw new Exception ( builder . ToString ( ) ) ;
325+ }
326+ }
327+ }
328+
329+ var assemblyMembers = DocReader . Read ( assembly , xmlDocsFile ) ;
330+ var type = assembly . GetType ( assemblyNamespace + "." + typeName ) ;
331+ var visitor = new XmlDocsVisitor ( type ) ;
332+
333+ visitor . VisitAssembly ( assemblyMembers ) ;
334+ if ( visitor . LabeledListItems . Any ( ) )
335+ {
336+ var labeledList = new LabeledList ( ) ;
337+ foreach ( var item in visitor . LabeledListItems . OrderBy ( l => l . Label ) )
338+ {
339+ labeledList . Items . Add ( item ) ;
340+ }
341+ _newDocument . Insert ( _newDocument . IndexOf ( attributeEntry ) , labeledList ) ;
342+ }
344343 }
345344
346345 private void RemoveDocDirectoryAttribute ( Document document )
@@ -360,7 +359,7 @@ private bool LastSectionTitleMatches(Func<string, bool> predicate)
360359 var builder = new StringBuilder ( ) ;
361360 using ( var visitor = new AsciiDocVisitor ( new StringWriter ( builder ) ) )
362361 {
363- visitor . Visit ( ( InlineContainer ) lastSectionTitle ) ;
362+ visitor . VisitInlineContainer ( lastSectionTitle ) ;
364363 }
365364
366365 return predicate ( builder . ToString ( ) ) ;
0 commit comments