forked from neuecc/MarkdownGenerator
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
71 lines (62 loc) · 2.39 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace MarkdownWikiGenerator
{
class Program
{
// 0 = dll src path, 1 = dest root
static void Main(string[] args)
{
// put dll & xml on same diretory.
string target="";
string dest = "md";
string namespaceMatch = string.Empty;
if (args.Length == 1)
{
target = args[0];
}
else if (args.Length == 2)
{
target = args[0];
dest = args[1];
}
else if (args.Length == 3)
{
target = args[0];
dest = args[1];
namespaceMatch = args[2];
}
var types = MarkdownGenerator.Load(target, namespaceMatch);
// Home Markdown Builder
var homeBuilder = new MarkdownBuilder();
homeBuilder.Header(1, "References");
homeBuilder.AppendLine();
foreach (var g in types.GroupBy(x => x.Namespace).OrderBy(x => x.Key))
{
var namescapeDirectoryPath = Path.Combine(dest, g.Key.Replace('.','\\'));
if (!Directory.Exists(namescapeDirectoryPath))
Directory.CreateDirectory(namescapeDirectoryPath);
homeBuilder.HeaderWithLink(2, g.Key, g.Key);
homeBuilder.AppendLine();
foreach (var item in g.OrderBy(x => x.Name))
{
var sb = new StringBuilder();
homeBuilder.ListLink(MarkdownBuilder.MarkdownCodeQuote(item.BeautifyName), Path.Combine(g.Key.Replace('.', '\\'), item.Name + ".md"));
sb.Append(item.ToString());
var fileName = item.FullName.Replace(g.Key, "").TrimStart('.');
var fullFileName = Path.Combine(namescapeDirectoryPath, fileName) + ".md";
File.WriteAllText(fullFileName, sb.ToString());
item.GenerateMethodDocuments(namescapeDirectoryPath);
}
homeBuilder.AppendLine();
}
// Gen Home
File.WriteAllText(Path.Combine(dest, "Home.md"), homeBuilder.ToString());
}
}
}