-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for type-safe enum pattern. #59
Comments
Interesting - all the data is coming from Roslyn, and Statiq Docs essentially converts Roslyn symbols representations to Statiq |
I'm using a slightly modified version of Docable. Layout is mostly the same, but I've changed some properties here and there. section/_Properties.cshtml @{
IReadOnlyList<IDocument> properties = Document.GetDocumentList(CodeAnalysisKeys.Members)
?.Where(x => x.GetBool(CodeAnalysisKeys.IsResult) && x.GetString(CodeAnalysisKeys.Kind) == "Property")
.OrderBy(x => x.GetString(CodeAnalysisKeys.DisplayName))
.ToList()
?? new List<IDocument>();
if (properties?.Count > 0)
{
List<(string, string)> headings = (List<(string, string)>?)ViewData[Keys.Headings] ?? new List<(string, string)>();
headings.Add(("properties", "Properties"));
ViewData[Keys.Headings] = headings;
<h2 id="properties">Properties</h2>
<div class="table-responsive">
<table class="table table-api table-striped table-hover three-cols">
<thead>
<tr>
<th>Name</th>
<th>Property Type</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (IDocument property in properties)
{
<tr>
<td>@Context.GetTypeLink(property, false)</td>
<td>@Context.GetTypeLink(property.GetDocument(CodeAnalysisKeys.Type))</td>
<td>
<div>@Html.Raw(property.GetString(CodeAnalysisKeys.Summary))</div>
@{
IDocument containingType = property.GetDocument(CodeAnalysisKeys.ContainingType);
if (!Document.IdEquals(containingType))
{
<div><small><em>Inherited from @Context.GetTypeLink(containingType)</em></small></div>
}
if (property.GetBool(CodeAnalysisKeys.IsStatic))
{
<div><small><em>static</em></small></div>
}
}
</td>
</tr>
}
</tbody>
</table>
</div>
}
} section/_ConstantValue.cshtml @using Microsoft.AspNetCore.Html;
@if (Document.GetBool(CodeAnalysisKeys.ConstantValue))
{
List<(string, string)> headings = (List<(string, string)>?)ViewData[Keys.Headings] ?? new List<(string, string)>();
headings.Add(("constant-value", "Constant Value"));
ViewData[Keys.Headings] = headings;
var constantValue = Document.Get(CodeAnalysisKeys.ConstantValue);
<h2 id="constant-value">Constant Value</h2>
<div class="table-responsive">
<table class="table table-api table-striped table-hover two-cols">
<thead>
<tr>
<th>Value</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>@(new HtmlString(constantValue?.ToString() ?? "null"))</td>
<td>@(new HtmlString(constantValue?.GetType().Name ?? string.Empty))</td>
</tr>
</tbody>
</table>
</div>
} Edit: Here's a small type-safe enum example: public sealed class CustomerCode
{
public string Code { get; }
private CustomerCode(string code)
{
Code = code
}
public static readonly CustomerCode Contoso = new("Con01");
public static readonly CustomerCode Microsoft = new ("Msft01");
} |
I am building docs for my Electronic Data Interchange library. One of the files in this library uses the type-safe enum pattern in order to define Currency Codes.
When the API docs are rendered for this class, the
static readonly
members are listed, however their values are not readily available even after clicking on them. Where is the value of this property stored and how can it be recovered for viewing?The text was updated successfully, but these errors were encountered: