-
Notifications
You must be signed in to change notification settings - Fork 0
feat(plugin): docgen parsing #4
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
Conversation
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
- https://github.com/Rich-Harris/magic-string#sgeneratemap-options- Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
Closed
1 task
40ce18f
to
e81fd06
Compare
- https://github.com/styleguidist/react-docgen-typescript/blob/v2.2.2/src/parser.ts#L350-L355 Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
e81fd06
to
b3d524e
Compare
flexdevelopment
approved these changes
Jul 29, 2022
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.
lgtm 👍🏾
unicornware
added a commit
that referenced
this pull request
Jul 31, 2022
* feat(options): `sourcemap?` - https://github.com/Rich-Harris/magic-string#sgeneratemap-options- Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc> * refactor(options): drop `name` - https://github.com/styleguidist/react-docgen-typescript/blob/v2.2.2/src/parser.ts#L350-L355 Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc> * feat(ts): `PluginReactDocgenTypeScript` Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc> * feat(plugin): `transform` Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
3 tasks
3 tasks
This was referenced Aug 16, 2022
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
scope:docgen
react-docgen-typescript integration
scope:plugin
plugin implementation
type:feat
new features and improvements
type:task
project tasks
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.
Description
✨ Features
Options?.sourcemap
Allows users to pass custom sourcemap options (
Omit<SourceMapOptions, 'source'>
),true
to use plugin defaults, orfalse
to disable sourcemap generation. Defaults totrue
.interface PluginReactDocgenTypeScript extends vite.Plugin
For the developers like me...aka the anal TypeScript developers 😅💙
Implemented
PluginReactDocgenTypeScript.transform
Parses modules for component docgen info. Build hook
transform
is called on each module request and can be used to augment individual modules. The hook receives two arguments: the module code to transform (which may already include transforms applied by other plugins),code
, and the path to the module,id
.For successfully parsed and transformed modules, the function will return an updated version of
code
that includes logic to add a__docgenInfo
property to each component exported fromid
. Ifoptions.sourcemap
is truthy, the function will also return a version 3 sourcemap.If
id
doesn't meet filtering requirements (set byoptions.exclude
andoptions.include
), the function will returnundefined
. Ifid
does end up being parsed, but doesn't yield any docgen information,null
will be returned instead.♻️ Code Improvements
Removed
Options?.name
The plugin assumes
doc.displayName
is the component name when setting__docgenInfo
. Thename
option allows users to generate component names instead (see 🔨 options #1). This option is not needed because the docgen parser already allows users to generate component display names:Users exporting multiple components from
id
should passoptions.componentNameResolver
, use@visibleName
in JSDoc comments, and/or passoptions.customComponentTypes
. If using@visibleName
,eslint-plugin-jsdoc
users may need to also update their eslint config:Tests
Additional context
Resolve issue with first displayName always being used styleguidist/react-docgen-typescript#441
This PR will allow users exporting multiple components to forego passing
options.componentNameResolver
, using@visibleName
in JSDoc comments, and/or passingoptions.customComponentTypes
:Linked issues
closes #2
Submission checklist
PR:
(e.g:PR: User authentication
)Update index.md
)next