Skip to content

Commit 46acd2a

Browse files
Mpdreamzrusscam
authored andcommitted
update to alpha6 on the 6.x branch (#3089)
(cherry picked from commit 9265d9c)
1 parent f6622d5 commit 46acd2a

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
{
@@ -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());

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)