Skip to content

Commit 86a25b5

Browse files
committed
WIP Major design update
1 parent db12727 commit 86a25b5

Some content is hidden

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

49 files changed

+1222
-0
lines changed

ApiExtensions.cs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Statiq.CodeAnalysis;
2+
using Statiq.Docs.Pipelines;
3+
using System.Text;
4+
5+
namespace TurnerSoftware.Compendium;
6+
7+
public class ApiExtensions : Pipeline
8+
{
9+
public ApiExtensions()
10+
{
11+
Dependencies.Add(nameof(Api));
12+
13+
DependencyOf.Add(nameof(Statiq.Web.Pipelines.Content));
14+
15+
ProcessModules = new ModuleList(
16+
new ConcatDocuments(nameof(Api)),
17+
new ExecuteConfig(Config.FromDocument((doc, ctx) =>
18+
{
19+
var coreName = $"{doc.GetString(CodeAnalysisKeys.FullName)} {doc.GetString(CodeAnalysisKeys.SpecificKind)}";
20+
var title = coreName;
21+
22+
var containingNamespace = doc.GetDocument(CodeAnalysisKeys.ContainingNamespace);
23+
if (containingNamespace is not null)
24+
{
25+
title = $"{coreName} ({containingNamespace.GetString(Keys.Title)})";
26+
}
27+
28+
return doc.Clone(new Dictionary<string, object>()
29+
{
30+
[Keys.Title] = title
31+
});
32+
}))
33+
);
34+
}
35+
}

DocumentTable.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace TurnerSoftware.Compendium;
2+
3+
/// <summary>
4+
/// This model is used for the _DocumentTable partial that renders documents, titles, headers, and summaries as a table.
5+
/// </summary>
6+
public class DocumentTable
7+
{
8+
public IList<IDocument> Documents { get; set; }
9+
public string Title { get; set; }
10+
public string Header { get; set; }
11+
public bool HasSummary { get; set; }
12+
public bool LinkTypeArguments { get; set; } = true;
13+
}

Tailwind.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace TurnerSoftware.Compendium;
2+
3+
public class Tailwind : Pipeline
4+
{
5+
private const bool MinifyOutput = true;
6+
7+
private static string MinifyOutputArgument => MinifyOutput ? "--minify" : string.Empty;
8+
9+
public Tailwind()
10+
{
11+
InputModules = new ModuleList
12+
{
13+
new ReadFiles("**/*.tailwind.css")
14+
};
15+
16+
ProcessModules = new ModuleList
17+
{
18+
new StartProcess("dotnet", Config.FromDocument(d => $"tailwindcss -c theme/tailwind.config.js -i {d.Source} {MinifyOutputArgument}"))
19+
.ContinueOnError(Config.FromValue(true))
20+
.LogErrors(Config.FromValue(false)),
21+
new ReplaceDocuments(Config.FromDocument(d => d.Clone(d.Destination.ChangeExtension("min.css")).Yield()))
22+
};
23+
24+
OutputModules = new ModuleList
25+
{
26+
new WriteFiles()
27+
};
28+
}
29+
}

ThemeKeys.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace TurnerSoftware.Compendium;
2+
3+
public static class ThemeKeys
4+
{
5+
public const string ProjectName = nameof(ProjectName);
6+
public const string ProjectShortDescription = nameof(ProjectShortDescription);
7+
public const string RepositoryUrl = nameof(RepositoryUrl);
8+
public const string Layout = nameof(Layout);
9+
}

TurnerSoftware.Compendium.csproj

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<IsPackable>false</IsPackable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Statiq.Docs" Version="1.0.0-beta.5" />
12+
</ItemGroup>
13+
14+
</Project>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@foreach(IGrouping<string, IDocument> typeGroup
2+
in Outputs.FromPipeline(nameof(Statiq.Docs.Pipelines.Api))
3+
.Where(x => x.GetBool(CodeAnalysisKeys.IsResult)
4+
&& x.GetString(CodeAnalysisKeys.Kind) == "NamedType"
5+
&& Document.IdEquals(x.GetDocument(CodeAnalysisKeys.ContainingAssembly)))
6+
.GroupBy(x => x.GetString(CodeAnalysisKeys.SpecificKind))
7+
.OrderBy(x => x.Key))
8+
{
9+
@await Html.PartialAsync("Api/Section/_DocumentTable", new DocumentTable
10+
{
11+
Documents = typeGroup.OrderBy(x => x.GetString(CodeAnalysisKeys.DisplayName)).ToList(),
12+
Title = typeGroup.Key + " Types",
13+
Header = typeGroup.Key,
14+
HasSummary = true
15+
});
16+
}

input/Shared/Api/Kind/_Event.cshtml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@await Html.PartialAsync("Api/Section/_Definition")
2+
@await Html.PartialAsync("Api/Section/_Examples")
3+
@await Html.PartialAsync("Api/Section/_Remarks")
4+
@await Html.PartialAsync("Api/Section/_SeeAlso")

input/Shared/Api/Kind/_Field.cshtml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@await Html.PartialAsync("Api/Section/_Definition")
2+
@await Html.PartialAsync("Api/Section/_Examples")
3+
@await Html.PartialAsync("Api/Section/_Remarks")
4+
@await Html.PartialAsync("Api/Section/_Attributes")
5+
@await Html.PartialAsync("Api/Section/_ConstantValue")
6+
@await Html.PartialAsync("Api/Section/_SeeAlso")

input/Shared/Api/Kind/_Method.cshtml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@await Html.PartialAsync("Api/Section/_Definition")
2+
@await Html.PartialAsync("Api/Section/_Examples")
3+
@await Html.PartialAsync("Api/Section/_Remarks")
4+
@await Html.PartialAsync("Api/Section/_Attributes")
5+
@await Html.PartialAsync("Api/Section/_TypeParameters")
6+
@await Html.PartialAsync("Api/Section/_Parameters")
7+
@await Html.PartialAsync("Api/Section/_ReturnValue")
8+
@await Html.PartialAsync("Api/Section/_SeeAlso")
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@await Html.PartialAsync("Api/Section/_Definition")
2+
@await Html.PartialAsync("Api/Section/_Examples")
3+
@await Html.PartialAsync("Api/Section/_Remarks")
4+
@await Html.PartialAsync("Api/Section/_Attributes")
5+
@await Html.PartialAsync("Api/Section/_TypeParameters")
6+
@await Html.PartialAsync("Api/Section/_Constructors")
7+
@await Html.PartialAsync("Api/Section/_Events")
8+
@await Html.PartialAsync("Api/Section/_Fields")
9+
@await Html.PartialAsync("Api/Section/_Properties")
10+
@await Html.PartialAsync("Api/Section/_Methods")
11+
@await Html.PartialAsync("Api/Section/_Operators")
12+
@await Html.PartialAsync("Api/Section/_ExtensionMethods")
13+
@await Html.PartialAsync("Api/Section/_SeeAlso")
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
@{
2+
var pluralLookup = new Dictionary<string, string>()
3+
{
4+
["Class"] = "Classes",
5+
["Struct"] = "Structs",
6+
["Enum"] = "Enums"
7+
};
8+
9+
foreach (IGrouping<string, IDocument> typeGroup
10+
in Document.GetDocuments(CodeAnalysisKeys.MemberTypes)
11+
.Where(x => x.GetBool(CodeAnalysisKeys.IsResult) && x.GetString(CodeAnalysisKeys.Kind) == "NamedType")
12+
.GroupBy(x => x.GetString(CodeAnalysisKeys.SpecificKind)))
13+
{
14+
@await Html.PartialAsync("Api/Section/_DocumentTable", new DocumentTable
15+
{
16+
Documents = typeGroup.OrderBy(x => x.GetString(CodeAnalysisKeys.DisplayName)).ToList(),
17+
Title = pluralLookup.TryGetValue(typeGroup.Key, out var title) ? title : typeGroup.Key,
18+
Header = typeGroup.Key,
19+
HasSummary = true
20+
});
21+
}
22+
23+
@await Html.PartialAsync("Api/Section/_DocumentTable", new DocumentTable
24+
{
25+
Documents = Document.GetDocuments(CodeAnalysisKeys.MemberNamespaces)
26+
?.Where(x => x.GetBool(CodeAnalysisKeys.IsResult))
27+
.OrderBy(x => x.GetString(CodeAnalysisKeys.DisplayName))
28+
.ToList(),
29+
Title = "Namespaces",
30+
Header = "Namespace",
31+
HasSummary = true,
32+
LinkTypeArguments = false
33+
});
34+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@await Html.PartialAsync("Api/Section/_Definition")
2+
@await Html.PartialAsync("Api/Section/_Examples")
3+
@await Html.PartialAsync("Api/Section/_Remarks")
4+
@await Html.PartialAsync("Api/Section/_Attributes")
5+
@await Html.PartialAsync("Api/Section/_Parameters")
6+
@await Html.PartialAsync("Api/Section/_Value")
7+
@await Html.PartialAsync("Api/Section/_SeeAlso")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@{
2+
IReadOnlyList<IDocument> attributes = Document.GetDocumentList(CodeAnalysisKeys.Attributes);
3+
if (attributes?.Count > 0)
4+
{
5+
((List<(string, string)>)ViewData[Keys.Headings]).Add(("Attributes", "Attributes"));
6+
<h1 id="Attributes">Attributes</h1>
7+
<div class="table-responsive">
8+
<table class="table table-api table-striped table-hover two-cols">
9+
<thead>
10+
<tr>
11+
<th>Type</th>
12+
<th>Description</th>
13+
</tr>
14+
</thead>
15+
<tbody>
16+
@foreach (IDocument attribute in attributes)
17+
{
18+
IDocument type = attribute.GetDocument(CodeAnalysisKeys.Type);
19+
<tr>
20+
<td>@Context.GetTypeLink(type)</td>
21+
<td>@Html.Raw(type.GetString(CodeAnalysisKeys.Summary))</td>
22+
</tr>
23+
}
24+
</tbody>
25+
</table>
26+
</div>
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@using Microsoft.AspNetCore.Html
2+
3+
@if(Document.GetBool(CodeAnalysisKeys.HasConstantValue))
4+
{
5+
((List<(string, string)>)ViewData[Keys.Headings]).Add(("ConstantValue", "Constant Value"));
6+
object constantValue = Document.Get(CodeAnalysisKeys.ConstantValue);
7+
<h1 id="ConstantValue">Constant Value</h1>
8+
<div class="table-responsive">
9+
<table class="table table-api table-striped table-hover two-cols">
10+
<thead>
11+
<tr>
12+
<th>Value</th>
13+
<th>Type</th>
14+
</tr>
15+
</thead>
16+
<tbody>
17+
<tr>
18+
<td>@(new HtmlString(constantValue?.ToString() ?? "null"))</td>
19+
<td>@(new HtmlString(constantValue?.GetType().Name ?? string.Empty))</td>
20+
</tr>
21+
</tbody>
22+
</table>
23+
</div>
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@await Html.PartialAsync("Api/Section/_DocumentTable", new DocumentTable()
2+
{
3+
Documents = Document.GetDocumentList(CodeAnalysisKeys.Constructors)
4+
?.Where(x => x.GetBool(CodeAnalysisKeys.IsResult))
5+
.OrderBy(x => x.GetString(CodeAnalysisKeys.DisplayName))
6+
.ToList(),
7+
Title = "Constructors",
8+
Header = "Name",
9+
HasSummary = true,
10+
LinkTypeArguments = false
11+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@{
2+
var containingNamespace = Document.GetDocument(CodeAnalysisKeys.ContainingNamespace);
3+
var containingAssembly = Document.GetDocument(CodeAnalysisKeys.ContainingAssembly);
4+
5+
var summary = Document.GetString(CodeAnalysisKeys.Summary);
6+
var syntax = Document.GetString(CodeAnalysisKeys.Syntax);
7+
8+
var baseTypes = Document.GetDocumentList(CodeAnalysisKeys.BaseTypes);
9+
var derivedTypes = Document.GetDocumentList(CodeAnalysisKeys.DerivedTypes);
10+
var implements = Document.GetDocumentList(CodeAnalysisKeys.Implements);
11+
12+
((List<(string, string)>)ViewData[Keys.Headings]).Add(("Definition", "Definition"));
13+
<section>
14+
<h2 id="Definition">Definition</h2>
15+
<div class="text-sm opacity-80 mb-3">
16+
<dl>
17+
<dt class="inline-block">Namespace:</dt>
18+
<dd class="inline-block ml-2">@Context.GetTypeLink(containingNamespace)</dd>
19+
</dl>
20+
<dl>
21+
<dt class="inline-block">Assembly:</dt>
22+
<dd class="inline-block ml-2">@Context.GetTypeLink(containingAssembly)</dd>
23+
</dl>
24+
</div>
25+
26+
@if (!summary.IsNullOrWhiteSpace())
27+
{
28+
<div class="mb-3">@Html.Raw(summary)</div>
29+
}
30+
31+
@if (!syntax.IsNullOrWhiteSpace())
32+
{
33+
<pre><code class="language-csharp">@syntax</code></pre>
34+
}
35+
36+
@if (baseTypes?.Count > 0)
37+
{
38+
<dl>
39+
<dt class="inline-block">Inheritance</dt>
40+
<dd class="inline-block ml-2">
41+
@foreach (var baseType in baseTypes.Reverse())
42+
{
43+
@Context.GetTypeLink(baseType)
44+
<span class="relative top-[-2px] mx-0.5">→</span>
45+
}
46+
@Document.GetString(CodeAnalysisKeys.Name)
47+
</dd>
48+
</dl>
49+
}
50+
51+
@if (derivedTypes?.Count > 0)
52+
{
53+
<dl>
54+
<dt class="inline-block">Derived</dt>
55+
<dd class="inline-block ml-2">
56+
<ul class="list-unstyled">
57+
@foreach (IDocument derivedType in derivedTypes)
58+
{
59+
<li>@Context.GetTypeLink(derivedType)</li>
60+
}
61+
</ul>
62+
</dd>
63+
</dl>
64+
}
65+
66+
@if (implements?.Count > 0)
67+
{
68+
<dl>
69+
<dt class="inline-block">Implements</dt>
70+
<dd class="inline-block ml-2">
71+
<ul class="list-unstyled">
72+
@foreach (IDocument implementsDocument in implements)
73+
{
74+
var implementsContainingTypeDocument = implementsDocument.GetDocument(CodeAnalysisKeys.ContainingType);
75+
<li>@Context.GetTypeLink(implementsContainingTypeDocument)[email protected](implementsDocument)</li>
76+
}
77+
</ul>
78+
</dd>
79+
</dl>
80+
}
81+
</section>
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@inherits StatiqRazorPage<DocumentTable>
2+
3+
@{
4+
if(Model?.Documents?.Count > 0)
5+
{
6+
((List<(string, string)>)ViewData[Keys.Headings]).Add((Model.Title.Replace(" ", ""), Model.Title));
7+
<section>
8+
<h2 id="@(Model.Title.Replace(" ", ""))">@Model.Title</h2>
9+
<table>
10+
<tbody>
11+
@foreach(IDocument doc in Model.Documents)
12+
{
13+
<tr>
14+
<td>@Context.GetTypeLink(doc, Model.LinkTypeArguments)</td>
15+
<td>@Html.Raw(doc.GetString(CodeAnalysisKeys.Summary))</td>
16+
</tr>
17+
}
18+
</tbody>
19+
</table>
20+
</section>
21+
}
22+
}

0 commit comments

Comments
 (0)