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

comparereport.cs « DocStat « DocStat « tools - github.com/mono/api-doc-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 86c12c3ba732f4c9a88a2d14e0e910834389808d (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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Mono.Options;

namespace DocStat
{
    public class CompareReportCommand : ApiCommand
    {
        
        public override void Run(IEnumerable<string> args)
        {
            // throw new NotImplementedException();

            string updatedDir = "";
			string omitlist = "";
			string processlist = "";
			string pattern = "";

			List<string> extras = CommandUtils.ProcessFileArgs(args,
															   ref updatedDir,
															   ref omitlist,
															   ref processlist,
															   ref pattern);

            string oldFilesDir = "";
            bool typeOnly = false;
            string reportFile = "";

            var options = new OptionSet {
                {"previous=", (p) => oldFilesDir = p},
                {"typeonly", (t) => typeOnly = t != null},
                {"reportfile=", (r) => reportFile = r}
            };

            extras = options.Parse(extras);

            CommandUtils.ThrowOnFiniteExtras(extras);

			if (String.IsNullOrEmpty(oldFilesDir))
				throw new ArgumentException("You must supply a parallel directory from which to source new content with 'previous='.");

            if (String.IsNullOrEmpty(reportFile) || !reportFile.EndsWith(".csv"))
                throw new ArgumentException("'reportfile=' must be used, and its value must end with '.csv'.");

            string bareReportDir = Path.GetDirectoryName(Path.GetFullPath(reportFile));

            if (!Directory.Exists(bareReportDir))
                throw new ArgumentException(bareReportDir + " does not exist.");

            IEnumerable<string> updated = CommandUtils.GetFileList(processlist, omitlist, updatedDir, pattern);
			HashSet<string> filesToUseAsReference = new HashSet<string>(CommandUtils.GetFileList("", "", oldFilesDir, ""));

			updated =
				updated.Where((f) =>
								 filesToUseAsReference.Contains(ParallelXmlHelper.GetParallelFilePathFor(f,
																										 oldFilesDir,
																										 updatedDir)));


            foreach (string updatedXMLFile in updated)
            {
                // For each member in the updated files, report if the old one isn't present

                string oldXMLFile = ParallelXmlHelper.GetParallelFilePathFor(updatedXMLFile, oldFilesDir, updatedDir);

                bool completelyNew = !File.Exists(oldXMLFile);

                XDocument updatedXDoc = XDocument.Load(updatedXMLFile);
                XDocument oldXDoc = XDocument.Load(oldXMLFile);


            }
		}
    }
}