Skip to content

Commit 21f618f

Browse files
Mpdreamzrusscam
authored andcommitted
update to alpha6 on the 6.x branch (#3089)
(cherry picked from commit 9265d9c)
1 parent 088e737 commit 21f618f

File tree

3 files changed

+92
-93
lines changed

3 files changed

+92
-93
lines changed

src/CodeGeneration/DocGenerator/AsciiDoc/GeneratedAsciidocVisitor.cs

Lines changed: 87 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -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());

src/CodeGeneration/DocGenerator/AsciiDoc/RawAsciidocVisitor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public RawAsciidocVisitor(FileInfo source, FileInfo destination)
2222
_destination = destination;
2323
}
2424

25-
public override void Visit(Document document)
25+
public override void VisitDocument(Document document)
2626
{
2727
_document = document;
2828

@@ -42,10 +42,10 @@ public override void Visit(Document document)
4242
"please modify the original csharp file found at the link and submit the PR with that change. Thanks!"
4343
});
4444

45-
base.Visit(document);
45+
base.VisitDocument(document);
4646
}
4747

48-
public override void Visit(AttributeEntry attributeEntry)
48+
public override void VisitAttributeEntry(AttributeEntry attributeEntry)
4949
{
5050
if (attributeEntry.Name == "includes-from-dirs")
5151
{
@@ -106,7 +106,7 @@ public override void Visit(AttributeEntry attributeEntry)
106106
}
107107
}
108108

109-
base.Visit(attributeEntry);
109+
base.VisitAttributeEntry(attributeEntry);
110110
}
111111
}
112112
}

src/CodeGeneration/DocGenerator/DocGenerator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="2.3.2" />
1212
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
1313
<ProjectReference Include="..\..\Nest\Nest.csproj" />
14-
<PackageReference Include="AsciiDocNet" Version="1.0.0-alpha5" />
14+
<PackageReference Include="AsciiDocNet" Version="1.0.0-alpha6" />
1515
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.2" />
1616
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.3.2" />
1717
<PackageReference Include="Microsoft.Build" Version="15.3.409" />

0 commit comments

Comments
 (0)