Skip to content
This repository was archived by the owner on Feb 28, 2022. It is now read-only.

Added workaround to support Enum documentation for C++ #28

Open
wants to merge 1 commit into
base: azuredocs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ private static string RemoveArgs(string original)

protected void FillSummary(ArticleItemYaml yaml, XElement node)
{
yaml.Summary = node.NullableElement("briefdescription").NullableInnerXml() + ParseSummaryFromDetailedDescription(node.NullableElement("detaileddescription"));
yaml.Summary = node.NullableElement("briefdescription").NullableInnerXml() + ParseSummaryFromDetailedDescription(node.NullableElement("detaileddescription"))
+ EnumValueAsSummary(node);
if (yaml.Summary == string.Empty)
{
yaml.Summary = null;
Expand Down Expand Up @@ -449,6 +450,23 @@ private string ParseReturnDescription(XElement detailedDescription)
return returnValue.NullableInnerXml();
}

// Only for c++ language.
private string EnumValueAsSummary(XElement enumMember)
{
string language = (string) enumMember.Parent?.Parent?.Attribute("language");
if ( (string.Equals(language, "c++", StringComparison.OrdinalIgnoreCase) && string.Equals(language, "cplusplus", StringComparison.OrdinalIgnoreCase)) || (string)enumMember.Attribute("kind") != "enum")
{
return null;
}
string rowValues = "";

foreach (var node in enumMember.Elements("enumvalue"))
{
rowValues += "<tr><td>" + node.Element("name").NullableInnerXml() + "</td><td>" + node.Element("briefdescription").NullableInnerXml() + node.Element("detaileddescription").NullableInnerXml() + "</td></tr>";
}
return $"<table><tr><th>Name</th><th>Description</th></tr>{rowValues}</table>"; ;
}

/// <summary>
/// <code>
/// <detailedDescription>
Expand Down Expand Up @@ -508,6 +526,10 @@ private static int ParseStartline(string startlineStr)
{
type = MemberType.Field;
}
else if (kind.Contains("enum"))
{
type = MemberType.Enum;
}
//else if (kind.Contains("friend"))
//{
// type = MemberType.Friend;
Expand Down
38 changes: 38 additions & 0 deletions test/code2yaml.Tests/Code2YamlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,44 @@ public void checkIndentation() {
Assert.Equal("<p>App's summary</p>\r\n<p>\r\n <ul>\r\n <li>\r\n <p>Test ScalarStyle for Summary of reference view model. </p>\r\n </li>\r\n </ul>\r\n</p>".Replace("\r\n", "\n"), referenceItem.Summary.Replace("\r\n", "\n"));
}

[Fact]
public void TestMetadataFromCPlusPlusProject()
{
// arrange
var outputFolder = Path.Combine(_workingFolder, "output");
var config = new ConfigModel
{
InputPaths = new List<string> { "TestData/cplusplus" },
Language = "cplusplus",
OutputPath = outputFolder,
};
var context = new BuildContext();
context.SetSharedObject(Constants.Constants.Config, config);
var procedure = new StepCollection(
new RunDoxygen(),
new PreprocessXml(),
new ScanHierarchy(),
new TaskParallel(
new List<IStep>
{
new GenerateToc { NameGenerator = NameGeneratorFactory.Create(config.Language) },
new GenerateArticles { Generator = ArticleGeneratorFactory.Create(config.Language) },
}));

// act
procedure.RunAsync(context).Wait();

// assert
var outputPathStruct = Path.Combine(outputFolder, "Check.CheckStruct1.yml");
var outputPathClass = Path.Combine(outputFolder, "Check.CheckClass1.yml");
var outputPathamespace = Path.Combine(outputFolder, "Check.yml");
var outputToc = Path.Combine(outputFolder, "toc.yml");
Assert.True(File.Exists(outputPathStruct));
Assert.True(File.Exists(outputPathClass));
Assert.True(File.Exists(outputPathamespace));
Assert.True(File.Exists(outputToc));
}

public void Dispose()
{
try
Expand Down