-
Notifications
You must be signed in to change notification settings - Fork 4.7k
docgen: Omit docblocks with private tag #15173
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
550c4a9
docgen: Omit docblocks with private tag
aduth 358e64a
Block API: Omit `children` documentation from README
aduth f39a644
Blocks: Documentation: Replace JSDoc link tag with see
aduth 01d3776
Blocks: Documentation: Mark node as private to omit from documentation
aduth e27a2f1
Merge branch 'master' into add/docgen-omit-private
aduth 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /** | ||
| * Given a symbol object and tag name(s), returns tag objects from the symbol | ||
| * matching the given name. | ||
| * | ||
| * @param {Object} symbol Symbol object. | ||
| * @param {...string} names Names of tags to return. | ||
| * | ||
| * @return {Object[]} Matching tag objects. | ||
| */ | ||
| function getSymbolTagsByName( symbol, ...names ) { | ||
| return symbol.tags.filter( ( tag ) => { | ||
| return names.some( ( name ) => name === tag.title ); | ||
| } ); | ||
| } | ||
|
|
||
| module.exports = getSymbolTagsByName; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| const getSymbolTagsByName = require( './get-symbol-tags-by-name' ); | ||
|
|
||
| /** | ||
| * Returns true if, given a symbol object, it contains a @private tag, or false | ||
| * otherwise. | ||
| * | ||
| * @param {Object} symbol Symbol object. | ||
| * | ||
| * @return {boolean} Whether symbol is private. | ||
| */ | ||
| const isSymbolPrivate = ( symbol ) => getSymbolTagsByName( symbol, 'private' ).length > 0; | ||
|
|
||
| module.exports = isSymbolPrivate; |
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 |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| const getTagsByName = ( tags, ...names ) => tags.filter( ( tag ) => names.some( ( name ) => name === tag.title ) ); | ||
|
||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| const getSymbolTagsByName = require( '../get-symbol-tags-by-name' ); | ||
|
|
||
| const cleanSpaces = ( paragraph ) => | ||
| paragraph ? | ||
|
|
@@ -57,7 +60,7 @@ const getSymbolHeading = ( text ) => { | |
| }; | ||
|
|
||
| module.exports = function( rootDir, docPath, symbols, headingTitle, headingStartIndex ) { | ||
| const docs = [ ]; | ||
| const docs = []; | ||
| let headingIndex = headingStartIndex || 1; | ||
| if ( headingTitle ) { | ||
| docs.push( getHeading( headingIndex, `${ headingTitle }` ) ); | ||
|
|
@@ -79,30 +82,30 @@ module.exports = function( rootDir, docPath, symbols, headingTitle, headingStart | |
| if ( symbols && symbols.length > 0 ) { | ||
| symbols.forEach( ( symbol ) => { | ||
| docs.push( getSymbolHeading( symbol.name ) ); | ||
| formatDeprecated( getTagsByName( symbol.tags, 'deprecated' ), docs ); | ||
| formatDeprecated( getSymbolTagsByName( symbol, 'deprecated' ), docs ); | ||
| formatDescription( symbol.description, docs ); | ||
| formatTag( | ||
| 'Related', | ||
| getTagsByName( symbol.tags, 'see', 'link' ), | ||
| getSymbolTagsByName( symbol, 'see', 'link' ), | ||
| ( tag ) => `\n- ${ tag.description }`, | ||
| docs | ||
| ); | ||
| formatExamples( getTagsByName( symbol.tags, 'example' ), docs ); | ||
| formatExamples( getSymbolTagsByName( symbol, 'example' ), docs ); | ||
| formatTag( | ||
| 'Type', | ||
| getTagsByName( symbol.tags, 'type' ), | ||
| getSymbolTagsByName( symbol, 'type' ), | ||
| ( tag ) => `\n- \`${ tag.type }\` ${ cleanSpaces( tag.description ) }`, | ||
| docs | ||
| ); | ||
| formatTag( | ||
| 'Parameters', | ||
| getTagsByName( symbol.tags, 'param' ), | ||
| getSymbolTagsByName( symbol, 'param' ), | ||
| ( tag ) => `\n- *${ tag.name }* \`${ tag.type }\`: ${ cleanSpaces( tag.description ) }`, | ||
| docs | ||
| ); | ||
| formatTag( | ||
| 'Returns', | ||
| getTagsByName( symbol.tags, 'return' ), | ||
| getSymbolTagsByName( symbol, 'return' ), | ||
| ( tag ) => `\n- \`${ tag.type }\`: ${ cleanSpaces( tag.description ) }`, | ||
| docs | ||
| ); | ||
|
|
||
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.