Open glopesdev opened 3 months ago
I have looked into the DocFX template system for ways to customize the left-hand side TOC and couldn't find anything that could be used to achieve this.
TOC categories are inserted by following lines. https://github.com/dotnet/docfx/blob/e5889cfca07be7509b80e41fa93fac5577d233ca/src/Docfx.Dotnet/DotnetApiCatalog.Toc.cs#L220-L230
TocNode
contains symbols
data so it can implement Custom Category
feature by using this information.
Though it'll requires some code refactoring.
It looks like the current feature for API page output format might be implemented here:
Suggested code seems to be used for Namespace API pages. (e.g. https://dotnet.github.io/docfx/api/Docfx.html)
Is your feature request related to a problem? Please describe.
The API page output format is a great way to help organize large project reference documentation by grouping types into categories, e.g.
Classes
andEnums
. However, in some domains it would be great to have support for additional custom groups, e.g.Attributes
orTypeConverters
.Describe the solution you'd like
It would be great if there was a way to specify new custom categories, and provide filters for types to be included in them, e.g. similar to
hasAttribute
infilter.yml
.For example, in the YAML below we would be able to specify that all classes with the
AttributeUsageAttribute
would be grouped under a new custom API page type group calledAttributes
.Describe alternatives you've considered
I have looked into the DocFX template system for ways to customize the left-hand side TOC and couldn't find anything that could be used to achieve this.
It is unclear from the current docs and template code how the grouping in the API page templates is even achieved in the current DocFX template system, but it could be another way to do it, as long as there are ways to specify the relevant conditionals.
Additional context
It looks like the current feature for API page output format might be implemented here:
https://github.com/dotnet/docfx/blob/7734a8912414ff6745ea96257f688625135c53fc/src/Docfx.Dotnet/DotnetApiCatalog.ApiPage.cs#L181-L185
Apparently the
t
in this lambda is an instance ofINamedTypeSymbol
from the Roslyn analyzers. If this is the case, it should be possible to add additional predicates to test custom attributes using theISymbol.GetAttributes
method, e.g. something like: