Skip to content
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

Add type params for class documentation. #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Selectorsvt
Copy link
Contributor

No description provided.

@Selectorsvt
Copy link
Contributor Author

@p1va

Copy link
Owner

@p1va p1va left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time to improve this 🙏
I think we could reuse some of the existing configuration for this so that we gain template capability

Comment on lines +356 to +360

/// <summary>
/// Gets or inits the value of include type parameters
/// </summary>
public bool IncludeTypeParams { get; init; } = true;
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();
    
    ...
}

Comment on lines +73 to +82
// 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);
}
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);
}

@p1va
Copy link
Owner

p1va commented Oct 30, 2021

Is generating something like this what you are looking for?

    /// <summary>
    /// The generic class
    /// </summary>
    /// <typeparam name="TResult">The result</typeparam>
    public class GenericClass<TResult> where TResult : class
    {
        
    }
    
    /// <summary>
    /// The another generic class
    /// </summary>
    /// <typeparam name="TRequest">The request</typeparam>
    /// <typeparam name="TResponse">The response</typeparam>
    public class AnotherGenericClass<TRequest, TResponse>
    {
        
    }

@Selectorsvt
Copy link
Contributor Author

Selectorsvt commented Oct 30, 2021

Is generating something like this what you are looking for?

    /// <summary>
    /// The generic class
    /// </summary>
    /// <typeparam name="TResult">The result</typeparam>
    public class GenericClass<TResult> where TResult : class
    {
        
    }
    
    /// <summary>
    /// The another generic class
    /// </summary>
    /// <typeparam name="TRequest">The request</typeparam>
    /// <typeparam name="TResponse">The response</typeparam>
    public class AnotherGenericClass<TRequest, TResponse>
    {
        
    }

Yes. Thanks for fast respond

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants