mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Docs redesign (#728)
* Adding a dark mode * Adding reference for types to summary pages * Adding API Reference * Adding modifiers to methods/fields/etc * Minimizing files input * Caching a lot of the output pages * Cache only for each execution * Adding API references to existing docs
This commit is contained in:
59
docs/input/api/Sections/_Fields.cshtml
Normal file
59
docs/input/api/Sections/_Fields.cshtml
Normal file
@ -0,0 +1,59 @@
|
||||
@using Statiq.CodeAnalysis
|
||||
@using Microsoft.AspNetCore.Html
|
||||
@using Docs.Extensions
|
||||
@{
|
||||
var isEnum = Document.GetString(CodeAnalysisKeys.SpecificKind) == "Enum";
|
||||
IReadOnlyList<IDocument> fields;
|
||||
if (isEnum)
|
||||
{
|
||||
fields = Document.GetDocumentList(CodeAnalysisKeys.Members)?.Where(x => x.GetBool(CodeAnalysisKeys.IsResult) && x.GetString(CodeAnalysisKeys.Kind) == "Field")
|
||||
.OrderBy(x => x.Get(CodeAnalysisKeys.ConstantValue) as int? ?? 0)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
fields = Document.GetDocumentList(CodeAnalysisKeys.Members)?.Where(x => x.GetBool(CodeAnalysisKeys.IsResult) && x.GetString(CodeAnalysisKeys.Kind) == "Field")
|
||||
.OrderBy(x => x.GetString(CodeAnalysisKeys.DisplayName))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
if (fields?.Count > 0)
|
||||
{
|
||||
<h3>Fields</h3>
|
||||
<div class="doc-summary">
|
||||
<div>
|
||||
<dl>
|
||||
@foreach (var field in fields)
|
||||
{
|
||||
<div>
|
||||
<dt>
|
||||
|
||||
<div class="flex flex-row">
|
||||
<div class="w-4/5">
|
||||
@if (isEnum)
|
||||
{
|
||||
@Context.GetTypeLink(field, false)
|
||||
}
|
||||
else
|
||||
{
|
||||
@field.GetModifiers() @Context.GetTypeLink(field.GetDocument(CodeAnalysisKeys.Type))
|
||||
@Context.GetTypeLink(field, false)
|
||||
}
|
||||
</div>
|
||||
<div>
|
||||
@(field.GetBool(CodeAnalysisKeys.HasConstantValue) ? new HtmlString(field.Get(CodeAnalysisKeys.ConstantValue)?.ToString() ?? "null") : new HtmlString(string.Empty))
|
||||
</div>
|
||||
</div>
|
||||
</dt>
|
||||
<dd>
|
||||
@Html.Raw(field.GetString(CodeAnalysisKeys.Summary))
|
||||
</dd>
|
||||
</div>
|
||||
}
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user