generated from Avanade/avanade-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
48 lines (40 loc) · 1.81 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
// Copyright (c) Avanade. Licensed under the MIT License. See https://github.com/Avanade/NTangle
using NTangle.CodeGen.Config;
using OnRamp.Console;
using OnRamp.Utility;
using System;
using System.IO;
using Con = System.Console;
namespace NTangle.ArtefactGenerate.Tool
{
/// <summary>
/// Tool to generate the JSON Schema and Markdown documentation artefacts.
/// </summary>
internal class Program
{
/// <summary>
/// Main entry point.
/// </summary>
internal static void Main()
{
var di = new DirectoryInfo(CodeGenConsole.GetBaseExeDirectory());
var root = di.Parent.Parent;
if (root.Name != "NTangle")
throw new InvalidOperationException($"The inferred root path should be 'NTangle'; inferred '{root.FullName}' incorrectly.");
// First up, generate the JSON Schema.
var fn = Path.Combine(root.FullName, "schemas", "ntangle.json");
Con.WriteLine("JSON Schema Generation");
Con.WriteLine($" Generating: {fn}");
JsonSchemaGenerator.Generate<RootConfig>(fn, "NTangle - https://github.com/Avanade/ntangle");
Con.WriteLine(" Complete.");
Con.WriteLine("");
// Now, generate the corresponding markdown documentation files.
var dn = Path.Combine(root.FullName, "docs", "generated");
Con.WriteLine("Markdown Documentation Generation");
Con.WriteLine($" Directory: {dn}");
MarkdownDocumentationGenerator.Generate<RootConfig>((type, csa) => $"{csa.Name.ToLowerInvariant()}.md", directory: dn, includeExample: false, addBreaksBetweenSections: true, fileCreation: fn => Con.WriteLine($" Generating: {fn}"));
Con.WriteLine(" Complete.");
Con.WriteLine("");
}
}
}