Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMike Norman <mike.norman@xamarin.com>2017-07-19 23:07:43 +0300
committerJoel Martinez <joelmartinez@gmail.com>2017-07-20 00:10:26 +0300
commitf1fb82a858bd6ccfcab960cada354c4ba5ee5515 (patch)
tree24f6878509dc4e0b5659dc9ffb8a4271a047098a /tools
parentb347c0bd1b2fcd28aa89ca2cf54e2cafac4708b2 (diff)
Forced check for TBA as default for comparereport, added 'no-check-TBA' option
Diffstat (limited to 'tools')
-rw-r--r--tools/DocStat/DocStat.Tests/CommandUtilsTests.cs21
-rw-r--r--tools/DocStat/DocStat.Tests/DocStat.Tests.csproj7
-rw-r--r--tools/DocStat/DocStat/CommandUtils.cs23
-rw-r--r--tools/DocStat/DocStat/comparereport.cs35
4 files changed, 76 insertions, 10 deletions
diff --git a/tools/DocStat/DocStat.Tests/CommandUtilsTests.cs b/tools/DocStat/DocStat.Tests/CommandUtilsTests.cs
new file mode 100644
index 00000000..c3c57baf
--- /dev/null
+++ b/tools/DocStat/DocStat.Tests/CommandUtilsTests.cs
@@ -0,0 +1,21 @@
+using NUnit.Framework;
+using System;
+namespace DocStat.Tests
+{
+ [TestFixture]
+ public class CommandUtilsTests
+ {
+ [Test]
+ public void CSVStringWith2()
+ {
+ Assert.AreEqual(@"""{0}"",""{1}""", CommandUtils.CSVFormatString(2));
+ }
+
+ [Test]
+ public void CSVStringWithIndexArray()
+ {
+ Assert.AreEqual(@"""{1}"",""{0}""",
+ CommandUtils.CSVFormatString(2, new int[] { 1, 0 }));
+ }
+ }
+}
diff --git a/tools/DocStat/DocStat.Tests/DocStat.Tests.csproj b/tools/DocStat/DocStat.Tests/DocStat.Tests.csproj
index 2a48d3cd..d8e6c822 100644
--- a/tools/DocStat/DocStat.Tests/DocStat.Tests.csproj
+++ b/tools/DocStat/DocStat.Tests/DocStat.Tests.csproj
@@ -34,6 +34,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="EcmaXmlHelperTests.cs" />
+ <Compile Include="CommandUtilsTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -46,6 +47,12 @@
<None Include="TestData\currentxml\newType.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+ <None Include="TestData\currentxml\AVAssetImageGeneratorCompletionHandler.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Include="TestData\oldxml\AVAssetImageGeneratorCompletionHandler.xml">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<Folder Include="TestData\" />
diff --git a/tools/DocStat/DocStat/CommandUtils.cs b/tools/DocStat/DocStat/CommandUtils.cs
index 8d4686fe..8affcdee 100644
--- a/tools/DocStat/DocStat/CommandUtils.cs
+++ b/tools/DocStat/DocStat/CommandUtils.cs
@@ -200,6 +200,29 @@ namespace DocStat
);
}
+ public static string CSVFormatString(int numColumns, int[] order = null)
+ {
+ if (null != order && order.Length != numColumns)
+ throw new ArgumentException(String.Format("Column order array had {0} entries, but {1} columns are needed.",
+ order.Length.ToString(),
+ numColumns.ToString()));
+ Func<int, int> indexFor = null;
+
+ if (null != order)
+ {
+ indexFor = (int i) => order[i];
+ }
+ else
+ {
+ indexFor = (int i) => i;
+ }
+
+ string[] cols = new string[numColumns];
+ for (int i = 0; i < numColumns; i++)
+ cols[i] = "\"{" + indexFor(i) + "}\"";
+
+ return String.Join(",", cols);
+ }
}
}
diff --git a/tools/DocStat/DocStat/comparereport.cs b/tools/DocStat/DocStat/comparereport.cs
index 60cd06ea..c692282f 100644
--- a/tools/DocStat/DocStat/comparereport.cs
+++ b/tools/DocStat/DocStat/comparereport.cs
@@ -28,11 +28,13 @@ namespace DocStat
string oldFilesDir = "";
bool typeOnly = false;
string reportFile = "";
+ bool nosigil = false;
var options = new OptionSet {
{"previous=", (p) => oldFilesDir = p},
{"typeonly", (t) => typeOnly = t != null},
- {"reportfile=", (r) => reportFile = r}
+ {"reportfile=", (r) => reportFile = r},
+ { "no-check-TBA", (t) => nosigil = t != null }
};
extras = options.Parse(extras);
@@ -53,25 +55,34 @@ namespace DocStat
IEnumerable<string> updated = CommandUtils.GetFileList(processlist, omitlist, updatedDir, pattern);
StreamWriter reportStream = new StreamWriter(reportFile);
- reportStream.WriteLine(@"""File Name"",""Type"",""Member""");
- string threeColumnFormatString = @"""{0}"",""{1}"",""{2}""";
- string twoColumnFormatString = @"""{0}"",""{1}""";
+ reportStream.WriteLine(String.Format(CommandUtils.CSVFormatString(3), "File Name", "Type", "Member"));
Action<XElement> Write = null;
Action<XElement> WriteSubsequent = (XElement e) =>
{
- reportStream.WriteLine(threeColumnFormatString, "", "", e.Attribute("MemberName").Value);
+ reportStream.WriteLine(CommandUtils.CSVFormatString(3), "", "", e.Attribute("MemberName").Value);
};
+ Func<XElement, bool> hasSigil = null;
+
+ if (nosigil)
+ {
+ hasSigil = (XElement e) => true;
+ }
+ else
+ {
+ hasSigil = (XElement e) => e.Element("Docs").Element("summary").Value == "To be added.";
+ }
+
foreach (string updatedXMLFile in updated)
{
XDocument updatedXDoc = XDocument.Load(updatedXMLFile);
Action<string> WriteFileLine = (string fname) =>
{
- reportStream.WriteLine(twoColumnFormatString,
+ reportStream.WriteLine(CommandUtils.CSVFormatString(2),
fname,
updatedXDoc.Element("Type").Attribute("FullName").Value);
Write = WriteSubsequent;
@@ -79,7 +90,7 @@ namespace DocStat
Write = (XElement e) =>
{
- reportStream.WriteLine(twoColumnFormatString,
+ reportStream.WriteLine(CommandUtils.CSVFormatString(2),
updatedXMLFile,
updatedXDoc.Element("Type").Attribute("FullName").Value);
WriteSubsequent(e);
@@ -90,10 +101,14 @@ namespace DocStat
XDocument oldXDoc = File.Exists(oldXMLFile) ? XDocument.Load(oldXMLFile) : null;
if (null == oldXDoc)
WriteFileLine(updatedXMLFile);
-
- foreach (XElement e in EcmaXmlHelper.NewMembers(updatedXDoc, oldXDoc))
+
+ IEnumerable<XElement> newMembers = EcmaXmlHelper.NewMembers(updatedXDoc, oldXDoc);
+ if (null != newMembers && newMembers.Count() > 0)
{
- Write(e);
+ foreach (XElement e in newMembers.Where((f) => hasSigil(f)))
+ {
+ Write(e);
+ }
}
}
reportStream.Flush();