Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/DotnetDocument/Configuration/DocumentationOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ public ExtendedSummaryDocumentationOptions()
/// Gets or inits the value of the include inheritance
/// </summary>
public bool IncludeInheritance { get; init; } = true;

/// <summary>
/// Gets or inits the value of include type parameters
/// </summary>
public bool IncludeTypeParams { get; init; } = true;
Comment on lines +356 to +360
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do something similar to what has been done for the MethodDocumentationOptions class here and add the ParamsDocumentationOptions options directly on the ClassDocumentationOptions like

public class ClassDocumentationOptions : MemberDocumentationOptionsBase
{
    ...
    
    /// <summary>
    /// Gets or sets the value of the type parameters
    /// </summary>
    public ParamsDocumentationOptions TypeParameters { get; set; } = new();
    
    ...
}

}

/// <summary>
Expand Down
11 changes: 11 additions & 0 deletions src/DotnetDocument/Strategies/ClassDocumentationStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public override ClassDeclarationSyntax Apply(ClassDeclarationSyntax node)
.For(node)
.WithSummary(summary);

// If type params has to be included
if (_options.Summary.IncludeTypeParams)
{
var typeParams = SyntaxUtils
.ExtractTypeParams(node.TypeParameterList)
.Select(x => (x, string.Empty))
.ToList();

builder.WithTypeParams(typeParams);
}
Comment on lines +73 to +82
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with the approach mentioned in the above comment this one could become

// If type params has to be included
if (_options.TypeParameters.Enabled)
{
    // Extract type params and generate a description
    var typeParams = SyntaxUtils
        .ExtractTypeParams(node.TypeParameterList)
        .Select(p => (p, _formatter
            .FormatName(_options.TypeParameters.Template, (TemplateKeys.Name, p))));

    builder.WithTypeParams(typeParams);
}


// If inheritance has to be included
if (_options.Summary.IncludeInheritance)
{
Expand Down