-
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
Feature/exclude private #10
base: main
Are you sure you want to change the base?
Conversation
Just following up. If this should be a discussion prior to a PR let me know and I'll decline this PR and take the suggestion back to the current issue. |
Apologies for the late reply and thank you 🙏 for taking the time to look into this as it's by far the most requested feature. access_modifiers:
- public
- internal It is also worth knowing that things like Dry RunThe logic that detects which members need to be documented need to be refactored to avoid breaking the dry run functionality (e.g. returning non 0 exit code on private member without doc when configured that they shouldn't have any). This is because it assumes that if a member of a |
I agree with the pattern of people specifying what they want to include instead of what they want to exclude, I will update the code for that pattern. Since modifiers is an Array we will need to make sure if item in the list is something like |
@p1va I've pushed an update. I'm not sure if this is what you were looking for but it allows the strategy to determine if the node should be documented. It also works correctly for dry run such that if the node shouldn't be documented it's not printed out. Let me know your thoughts when you get some time. If you like it I still need to update the README to document the way you adjust what gets documented. |
|
||
foreach (var modifier in options.AccessModifiers) | ||
{ | ||
var modifierArray = modifier.Split(" "); |
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.
@tmonck I cloned your repo to try this out and this logic doesn't seem to work. For example, when I just had "public" in the access modifiers list in the config, the if (modifierArray.Length > 1)
statement gets skipped over entirely
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.
This is my workaround
private static readonly List<string> _accessorKeyWords =
[
"public",
"internal",
"private",
"protected"
];
public static bool ShouldDocument(this MemberDeclarationSyntax node, MemberDocumentationOptionsBase options)
{
var nodeModifiers = node.Modifiers.Select(m => m.Text)
.Where(mText=> _accessorKeyWords.Contains(mText));
return options.AccessModifiers.Any(m=>
{
var optionModifier = m.Split(' ');
return nodeModifiers.All(nodeModifier => optionModifier.Contains(nodeModifier));
});
}
This doesn't allow the user to specify other valid modifiers besides what's in _accessorKeyWords
(e.g. readonly
) so not sure if this works for your implementation
Should resolve #3. I am open to suggestions if you want this to look a little differently or prefer different names.