Skip to content

Commit f4dd997

Browse files
committed
v1.0.0
1 parent bdc61c4 commit f4dd997

131 files changed

Lines changed: 56885 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,5 @@ paket-files/
260260
__pycache__/
261261
*.pyc
262262
release.chklist
263-
*.chklist
263+
*.chklist
264+
binaries*/

MarkupDoc.sln

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.106
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkupDoc", "MarkupDoc\MarkupDoc.csproj", "{59090B5D-23C0-4E51-BDF7-D534F39CC506}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleToDocument", "SampleToDocument\SampleToDocument.csproj", "{7918513B-574A-4397-B869-AAF6EC023150}"
9+
ProjectSection(ProjectDependencies) = postProject
10+
{59090B5D-23C0-4E51-BDF7-D534F39CC506} = {59090B5D-23C0-4E51-BDF7-D534F39CC506}
11+
EndProjectSection
12+
EndProject
13+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample2", "Sample2\Sample2.csproj", "{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}"
14+
ProjectSection(ProjectDependencies) = postProject
15+
{59090B5D-23C0-4E51-BDF7-D534F39CC506} = {59090B5D-23C0-4E51-BDF7-D534F39CC506}
16+
EndProjectSection
17+
EndProject
18+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{04F6A094-46BD-4E8F-862B-7021CB84238C}"
19+
ProjectSection(SolutionItems) = preProject
20+
changelog.md = changelog.md
21+
license.txt = license.txt
22+
readme.md = readme.md
23+
EndProjectSection
24+
EndProject
25+
Global
26+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
27+
Debug|Any CPU = Debug|Any CPU
28+
Release|Any CPU = Release|Any CPU
29+
EndGlobalSection
30+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
31+
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{7918513B-574A-4397-B869-AAF6EC023150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{7918513B-574A-4397-B869-AAF6EC023150}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{7918513B-574A-4397-B869-AAF6EC023150}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{7918513B-574A-4397-B869-AAF6EC023150}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Release|Any CPU.Build.0 = Release|Any CPU
43+
EndGlobalSection
44+
GlobalSection(SolutionProperties) = preSolution
45+
HideSolutionNode = FALSE
46+
EndGlobalSection
47+
GlobalSection(ExtensibilityGlobals) = postSolution
48+
SolutionGuid = {513A3BFE-D276-4926-B074-1140F6E6CC59}
49+
EndGlobalSection
50+
EndGlobal

MarkupDoc.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=markupdoc/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

MarkupDoc/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
5+
</startup>
6+
</configuration>

MarkupDoc/Application.cs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using net.adamec.dev.markupdoc.CodeModel;
5+
using net.adamec.dev.markupdoc.CodeModel.Builder;
6+
using net.adamec.dev.markupdoc.Markup;
7+
using net.adamec.dev.markupdoc.MsApiDoc;
8+
using net.adamec.dev.markupdoc.Options;
9+
10+
namespace net.adamec.dev.markupdoc
11+
{
12+
/// <summary>
13+
/// Main application class - encapsulates the documentation building logic
14+
/// </summary>
15+
public class Application
16+
{
17+
/// <summary>
18+
/// Output configuration
19+
/// </summary>
20+
public OutputOptions OutputOptions { get; }
21+
22+
/// <summary>
23+
/// CTOR with output configuration
24+
/// </summary>
25+
/// <param name="outputOptions">Output configuration</param>
26+
public Application(OutputOptions outputOptions)
27+
{
28+
OutputOptions = outputOptions;
29+
}
30+
31+
/// <summary>
32+
/// Runs the documentation building logic
33+
/// </summary>
34+
/// <param name="projectFile">Project file of C# project to build the documentation for</param>
35+
/// <returns>Async task</returns>
36+
public async Task RunAsync(string projectFile)
37+
{
38+
if (string.IsNullOrEmpty(projectFile)) throw new ArgumentNullException(nameof(projectFile));
39+
if (!File.Exists(projectFile)) throw new ArgumentException($"Project file {projectFile} doesn't exist");
40+
41+
var projectDir = new FileInfo(projectFile).DirectoryName;
42+
if (projectDir == null) throw new Exception($"Can't get the project directory from {projectFile}");
43+
44+
//Read MS API local documentation to get the links to MS API online documentation
45+
MsApiDocEngine.ReadLocalDoc();
46+
47+
//Build code model
48+
var root = await ModelBuilder.BuildFromProjectSourcesAsync(projectFile);
49+
50+
//Prepare for the output
51+
var targetBase = OutputOptions.Target; //full name w/o extension
52+
if (string.IsNullOrEmpty(targetBase)) targetBase = Path.Combine(projectDir, "doc"); //if not set, proj dir will be used and file doc.html/doc.md
53+
54+
var targetDir = new FileInfo(targetBase).DirectoryName;
55+
var targetFileBase = new FileInfo(targetBase).Name;
56+
57+
if (OutputOptions.SplitNs) root.ProcessingInfo.SplitFileType = SplitTypeEnum.Namespace;
58+
if (OutputOptions.SplitType) root.ProcessingInfo.SplitFileType = SplitTypeEnum.Type;
59+
60+
root.ProcessingInfo.BaseMainFile = targetFileBase;
61+
62+
//Generate markup outputs
63+
if (OutputOptions.Markdown)
64+
{
65+
var writer = new MarkupGenerator(
66+
// ReSharper disable once AssignNullToNotNullAttribute
67+
Path.Combine(targetDir, $"{targetFileBase}.{OutputOptions.MarkdownExtension}"), root,
68+
new MarkdownMarkupProvider(OutputOptions));
69+
await writer.WriteModelAsync(OutputOptions.Title);
70+
}
71+
72+
if (OutputOptions.Html)
73+
{
74+
var writer = new MarkupGenerator(
75+
// ReSharper disable once AssignNullToNotNullAttribute
76+
Path.Combine(targetDir, $"{targetFileBase}.{OutputOptions.HtmlExtension}"), root,
77+
new HtmlMarkupProvider(OutputOptions));
78+
79+
await writer.WriteModelAsync(OutputOptions.Title);
80+
}
81+
}
82+
}
83+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using net.adamec.dev.markupdoc.CodeModel.Builder;
4+
5+
namespace net.adamec.dev.markupdoc.CodeModel
6+
{
7+
/// <inheritdoc />
8+
/// <summary>
9+
/// Represents an assembly within the code model
10+
/// </summary>
11+
public class AssemblyMember : Member
12+
{
13+
/// <summary>
14+
/// List of namespaces within the assembly
15+
/// </summary>
16+
public IReadOnlyList<NamespaceMember> Namespaces { get; }
17+
/// <summary>
18+
/// List of all types (including interfaces, delegates, etc.) defined within the assembly
19+
/// </summary>
20+
public IReadOnlyList<TypeMember> AllTypes { get; }
21+
22+
/// <summary>
23+
/// CTOR - from builder
24+
/// </summary>
25+
/// <param name="builder">Builder</param>
26+
public AssemblyMember(AssemblyMemberBuilder builder):base(builder)
27+
{
28+
var namespaces = new List<NamespaceMember>();
29+
var types = new List<TypeMember>();
30+
var members = new List<Member>();
31+
foreach (var namespaceBuilder in builder.Namespaces)
32+
{
33+
namespaceBuilder.Root = builder.Root;
34+
namespaceBuilder.Assembly = this;
35+
var n = new NamespaceMember(namespaceBuilder);
36+
namespaces.Add(n);
37+
types.AddRange(n.AllMembers.OfType<TypeMember>());
38+
members.AddRange(n.AllMembers);
39+
}
40+
41+
Namespaces = namespaces;
42+
AllTypes = types;
43+
if(AllMembers is List<Member> allMembers) allMembers.AddRange(members);
44+
}
45+
}
46+
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Collections.Generic;
2+
3+
namespace net.adamec.dev.markupdoc.CodeModel.Builder
4+
{
5+
/// <inheritdoc />
6+
/// <summary>
7+
/// Builder for <see cref="AssemblyMember"/>
8+
/// </summary>
9+
public class AssemblyMemberBuilder : MemberBuilder
10+
{
11+
/// <inheritdoc />
12+
/// <summary>
13+
/// Kind (type) of the member
14+
/// </summary>
15+
public override MemberKindEnum MemberKind => MemberKindEnum.Assembly;
16+
/// <summary>
17+
/// List of namespaces within the assembly
18+
/// </summary>
19+
public List<NamespaceMemberBuilder> Namespaces { get; } = new List<NamespaceMemberBuilder>();
20+
21+
}
22+
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace net.adamec.dev.markupdoc.CodeModel.Builder
2+
{
3+
/// <inheritdoc />
4+
/// <summary>
5+
/// Builder for <see cref="EventMember"/>
6+
/// </summary>
7+
public class EventMemberBuilder : TypeContentMemberBuilder
8+
{
9+
/// <inheritdoc />
10+
/// <summary>
11+
/// Kind (type) of the member
12+
/// </summary>
13+
public override MemberKindEnum MemberKind => MemberKindEnum.Event;
14+
/// <summary>
15+
/// Flag whether the event has explicit implementation of add and remove accessors
16+
/// </summary>
17+
public bool HasExplicitAddAndRemove { get; set; }
18+
/// <summary>
19+
/// Delegate type (type reference) of the event handler
20+
/// </summary>
21+
public TypeRef TypeRef { get; set; }
22+
23+
24+
}
25+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
namespace net.adamec.dev.markupdoc.CodeModel.Builder
2+
{
3+
/// <inheritdoc />
4+
/// <summary>
5+
/// Builder for <see cref="FieldMember"/>
6+
/// </summary>
7+
public class FieldMemberBuilder : TypeContentMemberBuilder
8+
{
9+
/// <inheritdoc />
10+
/// <summary>
11+
/// Kind (type) of the member
12+
/// </summary>
13+
public override MemberKindEnum MemberKind => MemberKindEnum.Field;
14+
/// <summary>
15+
/// Flag whether the field is constant
16+
/// </summary>
17+
public bool IsConst { get; set; }
18+
/// <summary>
19+
/// Flag whether the field is read only
20+
/// </summary>
21+
public bool IsReadOnly { get; set; }
22+
/// <summary>
23+
/// Flag whether the field is volatile
24+
/// </summary>
25+
public bool IsVolatile { get; set; }
26+
/// <summary>
27+
/// The constant value of the field
28+
/// </summary>
29+
/// <remarks>The ConstantValue is not the definition (for example "2+customId") but the value is evaluated to the target type
30+
/// (for example 1002 if the customId in previous example is constant 1000).
31+
/// It's also necessary to apply the format when the constant value is to be presented in the output (for example add quotation marks to strings)</remarks>
32+
public object ConstantValue { get; set; }
33+
/// <summary>
34+
/// Type (type reference) of the field value
35+
/// </summary>
36+
public TypeRef TypeRef { get; set; }
37+
38+
39+
}
40+
}

0 commit comments

Comments
 (0)