Better support and tools for multiple exported components per file #283
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.
This is more of an experiment but I'd like to know what your thoughts are on this.
There's a few things going on in this PR:
<div />
@example
markdown by sectionA few notes on a couple of things mentioned above:
Allow for import statements in examples
When you export named components from a module, Styleguidist will require you to reference them within the module e.g
By allowing the use of import, the example can have an example of how the component might actually be imported in real world usage, and of course it is then able to correctly locate the component:
Unfortunately, as you can see in the PR, the way I have done this is with some major hackery. I am more interested however with whether you think this is a good idea, and if so we can then look into refactoring.
Ability to import
@example
by sectionJust like wanting to have multiple small components per file, it might be desirable to have all of the documentation for these components in one file as well. This is difficult because if you create a
Readme.md
, it will be displayed for every component in the single file.I've solved this by taking advantage of the existing ability to import an external example with
@example
, but now you can reference a section/anchor in that markdown file.e.g:
This enables all of the documentation for relevant components to be in one place, which is great for small components with a minimal API.
Let me know what your thoughts are, thanks!