@@ -53,7 +53,7 @@ public Document Convert(Document document)
53
53
return _newDocument ;
54
54
}
55
55
56
- public override void Visit ( Document document )
56
+ public override void VisitDocument ( Document document )
57
57
{
58
58
_newDocument = new Document
59
59
{
@@ -133,10 +133,10 @@ public override void Visit(Document document)
133
133
}
134
134
}
135
135
136
- base . Visit ( document ) ;
136
+ base . VisitDocument ( document ) ;
137
137
}
138
138
139
- public override void Visit ( Container elements )
139
+ public override void VisitContainer ( Container elements )
140
140
{
141
141
if ( _topLevel )
142
142
{
@@ -211,10 +211,10 @@ public override void Visit(Container elements)
211
211
}
212
212
}
213
213
214
- base . Visit ( elements ) ;
214
+ base . VisitContainer ( elements ) ;
215
215
}
216
216
217
- public override void Visit ( Source source )
217
+ public override void VisitSource ( Source source )
218
218
{
219
219
// remove method attributes as the elastic doc generation doesn't like them; it
220
220
// expects a linenumbering in the index 2 position of a source block
@@ -228,18 +228,18 @@ public override void Visit(Source source)
228
228
// (elastic docs generation does not like this callout format)
229
229
source . Text = Regex . Replace ( source . Text . Replace ( "\t " , " " ) , @"//[ \t]*\<(\d+)\>.*" , "<$1>" ) ;
230
230
231
- base . Visit ( source ) ;
231
+ base . VisitSource ( source ) ;
232
232
}
233
233
234
- public override void Visit ( SectionTitle sectionTitle )
234
+ public override void VisitSectionTitle ( SectionTitle sectionTitle )
235
235
{
236
236
// Generate an anchor for all top level section titles
237
237
if ( this . _document . IndexOf ( sectionTitle ) == 0 && ! sectionTitle . Attributes . HasAnchor )
238
238
{
239
239
var builder = new StringBuilder ( ) ;
240
240
using ( var writer = new AsciiDocVisitor ( new StringWriter ( builder ) ) )
241
241
{
242
- writer . Visit ( ( InlineContainer ) sectionTitle ) ;
242
+ writer . VisitInlineContainer ( sectionTitle ) ;
243
243
}
244
244
245
245
var title = builder . ToString ( ) . PascalToHyphen ( ) ;
@@ -259,88 +259,87 @@ public override void Visit(SectionTitle sectionTitle)
259
259
Ids . Add ( key , _destination . FullName ) ;
260
260
}
261
261
262
- base . Visit ( sectionTitle ) ;
262
+ base . VisitSectionTitle ( sectionTitle ) ;
263
263
}
264
264
265
- public override void Visit ( AttributeEntry attributeEntry )
265
+ public override void VisitAttributeEntry ( AttributeEntry attributeEntry )
266
266
{
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
+ }
344
343
}
345
344
346
345
private void RemoveDocDirectoryAttribute ( Document document )
@@ -360,7 +359,7 @@ private bool LastSectionTitleMatches(Func<string, bool> predicate)
360
359
var builder = new StringBuilder ( ) ;
361
360
using ( var visitor = new AsciiDocVisitor ( new StringWriter ( builder ) ) )
362
361
{
363
- visitor . Visit ( ( InlineContainer ) lastSectionTitle ) ;
362
+ visitor . VisitInlineContainer ( lastSectionTitle ) ;
364
363
}
365
364
366
365
return predicate ( builder . ToString ( ) ) ;
0 commit comments