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

fixsummaries.cs « DocStat « DocStat « tools - github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 42d116f1d8a1b1817456c49497abd652c43d907c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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);
				}

            }
			
                
        }
    }
}