Skip to content

Commit 9265d9c

Browse files
Mpdreamzrusscam
authored andcommitted
update to alpha6 on the 6.x branch (#3089)
1 parent 302ff5a commit 9265d9c

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
{
@@ -128,10 +128,10 @@ public override void Visit(Document document)
128128
}
129129
}
130130

131-
base.Visit(document);
131+
base.VisitDocument(document);
132132
}
133133

134-
public override void Visit(Container elements)
134+
public override void VisitContainer(Container elements)
135135
{
136136
if (_topLevel)
137137
{
@@ -206,10 +206,10 @@ public override void Visit(Container elements)
206206
}
207207
}
208208

209-
base.Visit(elements);
209+
base.VisitContainer(elements);
210210
}
211211

212-
public override void Visit(Source source)
212+
public override void VisitSource(Source source)
213213
{
214214
// remove method attributes as the elastic doc generation doesn't like them; it
215215
// expects a linenumbering in the index 2 position of a source block
@@ -223,18 +223,18 @@ public override void Visit(Source source)
223223
// (elastic docs generation does not like this callout format)
224224
source.Text = Regex.Replace(source.Text.Replace("\t", " "), @"//[ \t]*\<(\d+)\>.*", "<$1>");
225225

226-
base.Visit(source);
226+
base.VisitSource(source);
227227
}
228228

229-
public override void Visit(SectionTitle sectionTitle)
229+
public override void VisitSectionTitle(SectionTitle sectionTitle)
230230
{
231231
// Generate an anchor for all top level section titles
232232
if (this._document.IndexOf(sectionTitle) == 0 && !sectionTitle.Attributes.HasAnchor)
233233
{
234234
var builder = new StringBuilder();
235235
using (var writer = new AsciiDocVisitor(new StringWriter(builder)))
236236
{
237-
writer.Visit((InlineContainer)sectionTitle);
237+
writer.VisitInlineContainer(sectionTitle);
238238
}
239239

240240
var title = builder.ToString().PascalToHyphen();
@@ -253,88 +253,87 @@ public override void Visit(SectionTitle sectionTitle)
253253
Ids.Add(key, _destination.FullName);
254254
}
255255

256-
base.Visit(sectionTitle);
256+
base.VisitSectionTitle(sectionTitle);
257257
}
258258

259-
public override void Visit(AttributeEntry attributeEntry)
259+
public override void VisitAttributeEntry(AttributeEntry attributeEntry)
260260
{
261-
if (attributeEntry.Name == "xml-docs")
262-
{
263-
var value = attributeEntry.Value;
264-
265-
if (string.IsNullOrEmpty(value))
266-
{
267-
base.Visit(attributeEntry);
268-
return;
269-
}
270-
271-
var parts = value.Split(':');
272-
var assemblyName = parts[0];
273-
var typeName = parts[1];
274-
275-
string xmlDocsFile;
276-
Assembly assembly;
277-
string assemblyNamespace;
278-
279-
//TODO: tidy this up
280-
switch (assemblyName.ToLowerInvariant())
281-
{
282-
case "elasticsearch.net":
283-
xmlDocsFile = Path.GetFullPath(Path.Combine(Program.BuildOutputPath, "Elasticsearch.Net", "net46", "Elasticsearch.Net.XML"));
284-
assembly = typeof(ElasticLowLevelClient).Assembly;
285-
assemblyNamespace = typeof(ElasticLowLevelClient).Namespace;
286-
break;
287-
default:
288-
xmlDocsFile = Path.GetFullPath(Path.Combine(Program.BuildOutputPath, "Nest", "net46", "Nest.XML"));
289-
assembly = typeof(ElasticClient).Assembly;
290-
assemblyNamespace = typeof(ElasticClient).Namespace;
291-
break;
292-
}
293-
294-
// build xml documentation file on the fly if it doesn't exist
295-
if (!File.Exists(xmlDocsFile))
296-
{
297-
var project = _projects[assemblyName];
298-
var compilation = project.GetCompilationAsync().Result;
299-
300-
using (var peStream = new MemoryStream())
301-
using (var commentStream = File.Create(xmlDocsFile))
302-
{
303-
var emitResult = compilation.Emit(peStream, null, commentStream);
304-
305-
if (!emitResult.Success)
306-
{
307-
var failures = emitResult.Diagnostics.Where(diagnostic =>
308-
diagnostic.IsWarningAsError ||
309-
diagnostic.Severity == DiagnosticSeverity.Error);
310-
311-
var builder = new StringBuilder($"Unable to emit compilation for: {assemblyName}");
312-
foreach (var diagnostic in failures)
313-
{
314-
builder.AppendLine($"{diagnostic.Id}: {diagnostic.GetMessage()}");
315-
}
316-
builder.AppendLine(new string('-', 30));
317-
318-
throw new Exception(builder.ToString());
319-
}
320-
}
321-
}
322-
323-
var assemblyMembers = DocReader.Read(assembly, xmlDocsFile);
324-
var type = assembly.GetType(assemblyNamespace + "." + typeName);
325-
var visitor = new XmlDocsVisitor(type);
326-
327-
visitor.VisitAssembly(assemblyMembers);
328-
if (visitor.LabeledListItems.Any())
329-
{
330-
var labeledList = new LabeledList();
331-
foreach (var item in visitor.LabeledListItems.OrderBy(l => l.Label))
332-
{
333-
labeledList.Items.Add(item);
334-
}
335-
_newDocument.Insert(_newDocument.IndexOf(attributeEntry), labeledList);
336-
}
337-
}
261+
if (attributeEntry.Name != "xml-docs") return;
262+
263+
var value = attributeEntry.Value;
264+
265+
if (string.IsNullOrEmpty(value))
266+
{
267+
base.VisitAttributeEntry(attributeEntry);
268+
return;
269+
}
270+
271+
var parts = value.Split(':');
272+
var assemblyName = parts[0];
273+
var typeName = parts[1];
274+
275+
string xmlDocsFile;
276+
Assembly assembly;
277+
string assemblyNamespace;
278+
279+
//TODO: tidy this up
280+
switch (assemblyName.ToLowerInvariant())
281+
{
282+
case "elasticsearch.net":
283+
xmlDocsFile = Path.GetFullPath(Path.Combine(Program.BuildOutputPath, "Elasticsearch.Net", "net46", "Elasticsearch.Net.XML"));
284+
assembly = typeof(ElasticLowLevelClient).Assembly;
285+
assemblyNamespace = typeof(ElasticLowLevelClient).Namespace;
286+
break;
287+
default:
288+
xmlDocsFile = Path.GetFullPath(Path.Combine(Program.BuildOutputPath, "Nest", "net46", "Nest.XML"));
289+
assembly = typeof(ElasticClient).Assembly;
290+
assemblyNamespace = typeof(ElasticClient).Namespace;
291+
break;
292+
}
293+
294+
// build xml documentation file on the fly if it doesn't exist
295+
if (!File.Exists(xmlDocsFile))
296+
{
297+
var project = _projects[assemblyName];
298+
var compilation = project.GetCompilationAsync().Result;
299+
300+
using (var peStream = new MemoryStream())
301+
using (var commentStream = File.Create(xmlDocsFile))
302+
{
303+
var emitResult = compilation.Emit(peStream, null, commentStream);
304+
305+
if (!emitResult.Success)
306+
{
307+
var failures = emitResult.Diagnostics.Where(diagnostic =>
308+
diagnostic.IsWarningAsError ||
309+
diagnostic.Severity == DiagnosticSeverity.Error);
310+
311+
var builder = new StringBuilder($"Unable to emit compilation for: {assemblyName}");
312+
foreach (var diagnostic in failures)
313+
{
314+
builder.AppendLine($"{diagnostic.Id}: {diagnostic.GetMessage()}");
315+
}
316+
builder.AppendLine(new string('-', 30));
317+
318+
throw new Exception(builder.ToString());
319+
}
320+
}
321+
}
322+
323+
var assemblyMembers = DocReader.Read(assembly, xmlDocsFile);
324+
var type = assembly.GetType(assemblyNamespace + "." + typeName);
325+
var visitor = new XmlDocsVisitor(type);
326+
327+
visitor.VisitAssembly(assemblyMembers);
328+
if (visitor.LabeledListItems.Any())
329+
{
330+
var labeledList = new LabeledList();
331+
foreach (var item in visitor.LabeledListItems.OrderBy(l => l.Label))
332+
{
333+
labeledList.Items.Add(item);
334+
}
335+
_newDocument.Insert(_newDocument.IndexOf(attributeEntry), labeledList);
336+
}
338337
}
339338

340339
private void RemoveDocDirectoryAttribute(Document document)
@@ -354,7 +353,7 @@ private bool LastSectionTitleMatches(Func<string, bool> predicate)
354353
var builder = new StringBuilder();
355354
using (var visitor = new AsciiDocVisitor(new StringWriter(builder)))
356355
{
357-
visitor.Visit((InlineContainer)lastSectionTitle);
356+
visitor.VisitInlineContainer(lastSectionTitle);
358357
}
359358

360359
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
@@ -12,7 +12,7 @@
1212
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="2.3.2" />
1313
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
1414
<ProjectReference Include="..\..\Nest\Nest.csproj" />
15-
<PackageReference Include="AsciiDocNet" Version="1.0.0-alpha5" />
15+
<PackageReference Include="AsciiDocNet" Version="1.0.0-alpha6" />
1616
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.3.2" />
1717
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="2.3.2" />
1818
<PackageReference Include="Microsoft.Build" Version="15.3.409" />

0 commit comments

Comments
 (0)