Comments (2)
Interesting - all the data is coming from Roslyn, and Statiq Docs essentially converts Roslyn symbols representations to Statiq Document
s so we can more easily work with them. My guess is that the Docable theme doesn't know where to look for the value of these static readonly
fields. Probably won't be too hard to add that - can you paste some code here showing exactly the pattern that you're using (I can probably guess, but want to make sure I'm replicating the problem exactly).
from statiq.docs.
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:
Essentially, it aims to replicate Enum CustomerCode : T
where T
is anything, but it lacks some obvious features of enums such as being able to be used in a switch statement (values aren't constant), no flag support unless implemented manually, and so forth. Generally best used for when you need an explicit enumeration, such as where you'd use an enum
, but where using an enum
is not possible due to type restraints. These will be going away most likely when we get Discriminated Unions, but this is some time away.
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");
}
from statiq.docs.
Related Issues (20)
- Struct syntax shows unnecessary inheritance from ValueType
- Enum Docs sort members by name rather than by value
- <seealso> tags don't link to the specified member HOT 1
- Active class in table header rows HOT 1
- Add xrefs for all API symbols
- Support for Markdown format
- Verify doc comments specification HOT 1
- Feature Request: support XML <include> tags
- GetTypeLink fails for tuples HOT 6
- Add support for automatically linking symbols
- Add support for langword
- Add the props file from Statiq.Web to Statiq.Docs HOT 2
- AddAssemblyFiles to populate "API"?
- Source files are ignored by generator HOT 11
- Xrefs for API symbols should not contain whitespace
- Methods from base class not listed if base class is generic
- Example on Statiq.Docs output HOT 1
- File Casing issue when deploying to GH-Pages HOT 1
- [duplicate] xref API Reference Link Generation Issue Adding Extra Space HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from statiq.docs.