-
Notifications
You must be signed in to change notification settings - Fork 20
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
|
||
/// <summary> | ||
/// Gets or inits the value of include type parameters | ||
/// </summary> | ||
public bool IncludeTypeParams { get; init; } = true; |
There was a problem hiding this comment.
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();
...
}
// 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); | ||
} |
There was a problem hiding this comment.
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);
}
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 |
No description provided.