Skip to content

Commit

Permalink
gen home
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed May 23, 2016
1 parent 4875206 commit 483b2ec
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
24 changes: 24 additions & 0 deletions MarkdownBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ public void HeaderWithCode(int level, string code)
sb.AppendLine();
}

public void HeaderWithLink(int level, string text, string url)
{
for (int i = 0; i < level; i++)
{
sb.Append("#");
}
sb.Append(" ");
Link(text, url);
sb.AppendLine();
}

public void Link(string text, string url)
{
sb.Append("[");
Expand Down Expand Up @@ -112,6 +123,19 @@ public void Table(string[] headers, IEnumerable<string[]> items)
sb.AppendLine();
}

public void List(string text) // nest zero
{
sb.Append("- ");
sb.AppendLine(text);
}

public void ListLink(string text, string url) // nest zero
{
sb.Append("- ");
Link(text, url);
sb.AppendLine();
}

public override string ToString()
{
return sb.ToString();
Expand Down
1 change: 1 addition & 0 deletions MarkdownGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class MarkdownableType

public string Namespace => type.Namespace;
public string Name => type.Name;
public string BeautifyName => Beautifier.BeautifyType(type);

public MarkdownableType(Type type, ILookup<string, XmlDocumentComment> commentLookup)
{
Expand Down
17 changes: 16 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace MarkdownWikiGenerator
Expand All @@ -20,18 +21,32 @@ static void Main(string[] args)

var types = MarkdownGenerator.Load(target);

foreach (var g in types.GroupBy(x => x.Namespace))
// 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))
{
if (!Directory.Exists("md")) Directory.CreateDirectory("md");

homeBuilder.HeaderWithLink(2, g.Key, g.Key);
homeBuilder.AppendLine();

var sb = new StringBuilder();
foreach (var item in g.OrderBy(x => x.Name))
{
homeBuilder.ListLink(MarkdownBuilder.MarkdownCodeQuote(item.BeautifyName), g.Key + "#" + Regex.Replace(item.Name.ToLower(), "`.+$", ""));

sb.Append(item.ToString());
}

File.WriteAllText(@"md\" + g.Key + ".md", sb.ToString());
homeBuilder.AppendLine();
}

// Gen Home
File.WriteAllText(@"md\Home.md", homeBuilder.ToString());
}
}
}

0 comments on commit 483b2ec

Please sign in to comment.