-
Notifications
You must be signed in to change notification settings - Fork 21
Feature/exclude private #10
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
Open
tmonck
wants to merge
13
commits into
p1va:main
Choose a base branch
from
tmonck:feature/ExcludePrivate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e084c3f
Exclude private members and methods if told to in configuration
tmonck c830203
Exclude private properties.
tmonck 6da72f2
Add documentation in readme on how to configure.
tmonck 70a4a7f
Clean up extra line
tmonck a16f473
Add Exclude Private check to Class Documentation Strategy.
tmonck 8807ca3
Add class configuration to README
tmonck 6813be9
Remove extra character
tmonck 932e6b7
Fix to log only if we are actually skipping the node
tmonck 1f37881
Refactor things to have a bit more flexibility.
tmonck 38559bb
Use strategy to determine if it should be documented
tmonck cd411ab
Make sure the accessor matches exactly
tmonck a37c0d0
Merge branch 'main' into feature/ExcludePrivate
tmonck c938071
Fix it so that single word accessors (public) work properly
tmonck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/DotnetDocument/Extensions/MemberDeclarationSyntaxExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| using System; | ||
| using System.Linq; | ||
| using DotnetDocument.Configuration; | ||
| using DotnetDocument.Syntax; | ||
| using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
|
||
| namespace DotnetDocument.Extensions | ||
| { | ||
| public static class MemberDeclarationSyntaxExtensions | ||
| { | ||
| public static bool ShouldDocument(this MemberDeclarationSyntax node, MemberDocumentationOptionsBase options) | ||
| { | ||
| var shouldDocument = false; | ||
|
|
||
| foreach (var modifier in options.AccessModifiers) | ||
| { | ||
| var modifierArray = modifier.Split(" "); | ||
|
|
||
| if (node != null) | ||
| { | ||
| if (modifierArray.Length > 1) | ||
| { | ||
| if (node.Modifiers.Any(m => m.Text.Equals(modifierArray[0], StringComparison.Ordinal)) && | ||
| node.Modifiers.Any(m => m.Text.Equals(modifierArray[1], StringComparison.Ordinal)) && | ||
| !SyntaxUtils.IsDocumented(node)) | ||
| { | ||
| shouldDocument = true; | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| } | ||
| else | ||
| { | ||
| if (node.Modifiers.All(m => m.Text.Equals(modifier, StringComparison.Ordinal)) && | ||
| !SyntaxUtils.IsDocumented(node)) | ||
| { | ||
| shouldDocument = true; | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| if (node.Modifiers.Any() && node.Modifiers[0].Text.Equals(modifier, StringComparison.Ordinal) && | ||
| !SyntaxUtils.IsDocumented(node)) | ||
| { | ||
| shouldDocument = true; | ||
|
|
||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return shouldDocument; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 entirelyUh oh!
There was an error while loading. Please reload this page.
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
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 implementationThere 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.
I'm getting back into dotnet development day to day now. I'll look back at this and see if I can fix the issue.
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.
I've updated the logic which should allow for
publicto be in the list by itself. It does ensure if you use a single word accessor likepublicthat it's the first item in the modifiers for the node.