Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adamecr committed Dec 2, 2018
1 parent bdc61c4 commit f4dd997
Show file tree
Hide file tree
Showing 131 changed files with 56,885 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,5 @@ paket-files/
__pycache__/
*.pyc
release.chklist
*.chklist
*.chklist
binaries*/
50 changes: 50 additions & 0 deletions MarkupDoc.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.106
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MarkupDoc", "MarkupDoc\MarkupDoc.csproj", "{59090B5D-23C0-4E51-BDF7-D534F39CC506}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleToDocument", "SampleToDocument\SampleToDocument.csproj", "{7918513B-574A-4397-B869-AAF6EC023150}"
ProjectSection(ProjectDependencies) = postProject
{59090B5D-23C0-4E51-BDF7-D534F39CC506} = {59090B5D-23C0-4E51-BDF7-D534F39CC506}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample2", "Sample2\Sample2.csproj", "{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}"
ProjectSection(ProjectDependencies) = postProject
{59090B5D-23C0-4E51-BDF7-D534F39CC506} = {59090B5D-23C0-4E51-BDF7-D534F39CC506}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{04F6A094-46BD-4E8F-862B-7021CB84238C}"
ProjectSection(SolutionItems) = preProject
changelog.md = changelog.md
license.txt = license.txt
readme.md = readme.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59090B5D-23C0-4E51-BDF7-D534F39CC506}.Release|Any CPU.Build.0 = Release|Any CPU
{7918513B-574A-4397-B869-AAF6EC023150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7918513B-574A-4397-B869-AAF6EC023150}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7918513B-574A-4397-B869-AAF6EC023150}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7918513B-574A-4397-B869-AAF6EC023150}.Release|Any CPU.Build.0 = Release|Any CPU
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7558793E-F3ED-4949-BD00-ECDC83DD5DD2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {513A3BFE-D276-4926-B074-1140F6E6CC59}
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions MarkupDoc.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<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">
<s:Boolean x:Key="/Default/UserDictionary/Words/=markupdoc/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
6 changes: 6 additions & 0 deletions MarkupDoc/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
</startup>
</configuration>
83 changes: 83 additions & 0 deletions MarkupDoc/Application.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using System;
using System.IO;
using System.Threading.Tasks;
using net.adamec.dev.markupdoc.CodeModel;
using net.adamec.dev.markupdoc.CodeModel.Builder;
using net.adamec.dev.markupdoc.Markup;
using net.adamec.dev.markupdoc.MsApiDoc;
using net.adamec.dev.markupdoc.Options;

namespace net.adamec.dev.markupdoc
{
/// <summary>
/// Main application class - encapsulates the documentation building logic
/// </summary>
public class Application
{
/// <summary>
/// Output configuration
/// </summary>
public OutputOptions OutputOptions { get; }

/// <summary>
/// CTOR with output configuration
/// </summary>
/// <param name="outputOptions">Output configuration</param>
public Application(OutputOptions outputOptions)
{
OutputOptions = outputOptions;
}

/// <summary>
/// Runs the documentation building logic
/// </summary>
/// <param name="projectFile">Project file of C# project to build the documentation for</param>
/// <returns>Async task</returns>
public async Task RunAsync(string projectFile)
{
if (string.IsNullOrEmpty(projectFile)) throw new ArgumentNullException(nameof(projectFile));
if (!File.Exists(projectFile)) throw new ArgumentException($"Project file {projectFile} doesn't exist");

var projectDir = new FileInfo(projectFile).DirectoryName;
if (projectDir == null) throw new Exception($"Can't get the project directory from {projectFile}");

//Read MS API local documentation to get the links to MS API online documentation
MsApiDocEngine.ReadLocalDoc();

//Build code model
var root = await ModelBuilder.BuildFromProjectSourcesAsync(projectFile);

//Prepare for the output
var targetBase = OutputOptions.Target; //full name w/o extension
if (string.IsNullOrEmpty(targetBase)) targetBase = Path.Combine(projectDir, "doc"); //if not set, proj dir will be used and file doc.html/doc.md

var targetDir = new FileInfo(targetBase).DirectoryName;
var targetFileBase = new FileInfo(targetBase).Name;

if (OutputOptions.SplitNs) root.ProcessingInfo.SplitFileType = SplitTypeEnum.Namespace;
if (OutputOptions.SplitType) root.ProcessingInfo.SplitFileType = SplitTypeEnum.Type;

root.ProcessingInfo.BaseMainFile = targetFileBase;

//Generate markup outputs
if (OutputOptions.Markdown)
{
var writer = new MarkupGenerator(
// ReSharper disable once AssignNullToNotNullAttribute
Path.Combine(targetDir, $"{targetFileBase}.{OutputOptions.MarkdownExtension}"), root,
new MarkdownMarkupProvider(OutputOptions));
await writer.WriteModelAsync(OutputOptions.Title);
}

if (OutputOptions.Html)
{
var writer = new MarkupGenerator(
// ReSharper disable once AssignNullToNotNullAttribute
Path.Combine(targetDir, $"{targetFileBase}.{OutputOptions.HtmlExtension}"), root,
new HtmlMarkupProvider(OutputOptions));

await writer.WriteModelAsync(OutputOptions.Title);
}
}
}
}
47 changes: 47 additions & 0 deletions MarkupDoc/CodeModel/AssemblyMember.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Linq;
using net.adamec.dev.markupdoc.CodeModel.Builder;

namespace net.adamec.dev.markupdoc.CodeModel
{
/// <inheritdoc />
/// <summary>
/// Represents an assembly within the code model
/// </summary>
public class AssemblyMember : Member
{
/// <summary>
/// List of namespaces within the assembly
/// </summary>
public IReadOnlyList<NamespaceMember> Namespaces { get; }
/// <summary>
/// List of all types (including interfaces, delegates, etc.) defined within the assembly
/// </summary>
public IReadOnlyList<TypeMember> AllTypes { get; }

/// <summary>
/// CTOR - from builder
/// </summary>
/// <param name="builder">Builder</param>
public AssemblyMember(AssemblyMemberBuilder builder):base(builder)
{
var namespaces = new List<NamespaceMember>();
var types = new List<TypeMember>();
var members = new List<Member>();
foreach (var namespaceBuilder in builder.Namespaces)
{
namespaceBuilder.Root = builder.Root;
namespaceBuilder.Assembly = this;
var n = new NamespaceMember(namespaceBuilder);
namespaces.Add(n);
types.AddRange(n.AllMembers.OfType<TypeMember>());
members.AddRange(n.AllMembers);
}

Namespaces = namespaces;
AllTypes = types;
if(AllMembers is List<Member> allMembers) allMembers.AddRange(members);
}
}

}
23 changes: 23 additions & 0 deletions MarkupDoc/CodeModel/Builder/AssemblyMemberBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;

namespace net.adamec.dev.markupdoc.CodeModel.Builder
{
/// <inheritdoc />
/// <summary>
/// Builder for <see cref="AssemblyMember"/>
/// </summary>
public class AssemblyMemberBuilder : MemberBuilder
{
/// <inheritdoc />
/// <summary>
/// Kind (type) of the member
/// </summary>
public override MemberKindEnum MemberKind => MemberKindEnum.Assembly;
/// <summary>
/// List of namespaces within the assembly
/// </summary>
public List<NamespaceMemberBuilder> Namespaces { get; } = new List<NamespaceMemberBuilder>();

}

}
25 changes: 25 additions & 0 deletions MarkupDoc/CodeModel/Builder/EventMemberBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace net.adamec.dev.markupdoc.CodeModel.Builder
{
/// <inheritdoc />
/// <summary>
/// Builder for <see cref="EventMember"/>
/// </summary>
public class EventMemberBuilder : TypeContentMemberBuilder
{
/// <inheritdoc />
/// <summary>
/// Kind (type) of the member
/// </summary>
public override MemberKindEnum MemberKind => MemberKindEnum.Event;
/// <summary>
/// Flag whether the event has explicit implementation of add and remove accessors
/// </summary>
public bool HasExplicitAddAndRemove { get; set; }
/// <summary>
/// Delegate type (type reference) of the event handler
/// </summary>
public TypeRef TypeRef { get; set; }


}
}
40 changes: 40 additions & 0 deletions MarkupDoc/CodeModel/Builder/FieldMemberBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
namespace net.adamec.dev.markupdoc.CodeModel.Builder
{
/// <inheritdoc />
/// <summary>
/// Builder for <see cref="FieldMember"/>
/// </summary>
public class FieldMemberBuilder : TypeContentMemberBuilder
{
/// <inheritdoc />
/// <summary>
/// Kind (type) of the member
/// </summary>
public override MemberKindEnum MemberKind => MemberKindEnum.Field;
/// <summary>
/// Flag whether the field is constant
/// </summary>
public bool IsConst { get; set; }
/// <summary>
/// Flag whether the field is read only
/// </summary>
public bool IsReadOnly { get; set; }
/// <summary>
/// Flag whether the field is volatile
/// </summary>
public bool IsVolatile { get; set; }
/// <summary>
/// The constant value of the field
/// </summary>
/// <remarks>The ConstantValue is not the definition (for example "2+customId") but the value is evaluated to the target type
/// (for example 1002 if the customId in previous example is constant 1000).
/// 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>
public object ConstantValue { get; set; }
/// <summary>
/// Type (type reference) of the field value
/// </summary>
public TypeRef TypeRef { get; set; }


}
}
Loading

0 comments on commit f4dd997

Please sign in to comment.