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-09-29 22:15:47 +0300
committerJoel Martinez <joelmartinez@gmail.com>2017-09-29 22:20:23 +0300
commit736b4ea95a22c9e1299a40b67ca4a7fabac89bc7 (patch)
tree5238307503bfa2cfdddfa7789dad2ad74463d6de /tools
parentf51d2af552e63de7d72555a5c61d9c2a28b7faa0 (diff)
Added command to fix some common summary errors.
Diffstat (limited to 'tools')
-rw-r--r--tools/DocStat/DocStat/DocStat.csproj1
-rw-r--r--tools/DocStat/DocStat/apistat.cs3
-rw-r--r--tools/DocStat/DocStat/fixsummaries.cs82
3 files changed, 85 insertions, 1 deletions
diff --git a/tools/DocStat/DocStat/DocStat.csproj b/tools/DocStat/DocStat/DocStat.csproj
index 6ba10b6a..dbb25ab4 100644
--- a/tools/DocStat/DocStat/DocStat.csproj
+++ b/tools/DocStat/DocStat/DocStat.csproj
@@ -38,6 +38,7 @@
<Link>Options.cs</Link>
</Compile>
<Compile Include="comparereport.cs" />
+ <Compile Include="fixsummaries.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Xml.Linq" />
diff --git a/tools/DocStat/DocStat/apistat.cs b/tools/DocStat/DocStat/apistat.cs
index 78ef5418..f03e2aca 100644
--- a/tools/DocStat/DocStat/apistat.cs
+++ b/tools/DocStat/DocStat/apistat.cs
@@ -31,7 +31,8 @@ namespace DocStat
{"remaining", new RemainingCommand() },
{"obsolete", new ObsoleteCommand() },
{"comparefix", new CompareFixCommand()},
- {"reportnew", new CompareReportCommand()}
+ {"reportnew", new CompareReportCommand()},
+ {"fixsummaries", new FixSummariesCommand()}
};
GetCommand(args.First()).Run(args);
diff --git a/tools/DocStat/DocStat/fixsummaries.cs b/tools/DocStat/DocStat/fixsummaries.cs
new file mode 100644
index 00000000..42d116f1
--- /dev/null
+++ b/tools/DocStat/DocStat/fixsummaries.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Xml.Linq;
+using Mono.Options;
+
+namespace DocStat
+{
+ public class FixSummariesCommand : ApiCommand
+ {
+ public FixSummariesCommand()
+ {
+ }
+
+ public override void Run(IEnumerable<string> args)
+ {
+ string rootdir = "";
+ string omitlist = "";
+ string processlist = "";
+ string pattern = "";
+ List<string> extras = CommandUtils.ProcessFileArgs(args,
+ ref rootdir,
+ ref omitlist,
+ ref processlist,
+ ref pattern
+ );
+ CommandUtils.ThrowOnFiniteExtras(extras);
+
+ foreach (string file in CommandUtils.GetFileList(processlist, omitlist, rootdir, pattern))
+ {
+ bool changed = false;
+ XDocument xdoc = new XDocument(XElement.Load(file));
+
+ XElement memberRoot = xdoc.Element("Type").Element("Members");
+ if (memberRoot == null || !memberRoot.Descendants().Any())
+ {
+ continue;
+ }
+
+
+ foreach (XElement m in memberRoot.Elements("Member"))
+ {
+ changed = false;
+ XElement summary = m.Element("Docs").Element("summary");
+
+
+ if (null == summary)
+ {
+ continue;
+ }
+
+ if (summary.IsEmpty || (summary.Value.Length == 0 && summary.Descendants().Count() == 0))
+ {
+ summary.Value = "To be added.";
+ changed = true;
+ continue;
+ }
+
+ IEnumerable<XElement> mistakeParams = summary.Descendants("param");
+
+ if (mistakeParams.Count() == 0)
+ {
+ continue;
+ }
+
+
+ mistakeParams.ToList().ForEach(e => e.Name = "paramref");
+ changed = true;
+
+ }
+
+ if (changed)
+ {
+ CommandUtils.WriteXDocument(xdoc, file);
+ }
+
+ }
+
+
+ }
+ }
+}