Storybook README addon
NOTE: This README only for version ^5.0.0
. For older versions README_V4.md
All previous api should work correctly at ^5.0.0
and above. But vue users will need to change their import path, as vue commands have been moved to their own folder.
This addon is compatible with:
- React Storybook (React example storybook)
- Vue Storybook (Vue example storybook)
- Particularly HTML Storybook
Features:
- Automatically generate props table (only for React)
- 100% markdown support
- Code highlighting
- Possible to add docs to addons panel or around the story
- Accept multiple README (useful for hoc component - add component's and original component's README)
- Looks like Github's README
- Supports
<docs/>
tags for vue components (example-vue/components/MyButton/MyButton.vue).
Also it very useful because most projects and components already have README.md files. Now it is easy to add them into your Storybook.
Stories will be added with .addWithInfo method if Storybook Info Addon is installed.
Install
npm install --save-dev storybook-readme
or
yarn add --dev storybook-readme
Webpack Configuration for React Storybook
Nothing to do :)
Webpack Configuration for Vue Storybook
Only for Single File Components with <docs>
tag used for documentation.
module { storybookBaseConfigmodulerules;};
Define <docs>
tag inside vue module:
<docs>Docs inside vue module </docs> <template> <button class="button"> <slot></slot> </button></template>
Use it to define docs at story:
; ;
Setup
Register addon at .storybook/addons.js
;
NOTE: It is possible to set addon's panel title
; ;
Add decorator at .storybook/config.js
;; // for Vue storybook; // <---- vue subpackage // for HTML storybook; // <---- html subpackage ; { ;} ;
NOTE: for html storybook only sidebar docs are available.
Usage
Hope it is very simple.
;; ;; ;
It is possible to override docs for story
;; ;; ;
Full list of options
Will be applied for series of stories.
Global configuration
Will be applied for all stories.
NOTE: that global configuration
is applied only for content docs (docs around the story).
; // or @storybook/vue for vuejs; ; ;
Readme placeholders
<!-- STORY -->
placeholder for story<!-- SOURCE -->
placeholder for story source<!-- STORY_SOURCE -->
placeholder for story source<!-- PROPS -->
placeholder for props table. There are some issue with props parsing. Clarification issue#137<!-- STORY HIDE START -->
,<!-- STORY HIDE END -->
content enclosed by the tags won't be shown in stories
Button variants could be imported separately. \`\`\`js import { OutlinedButton, ContainedButton, TextButton } from 'Button'; \`\`\` <!-- PROPS --> Example: <!-- STORY --><!-- SOURCE --> <!-- STORY HIDE START --> content here won't be shown in stories <!-- STORY HIDE END --> Some docs after story
Emoji
Use shortcodes between colon to insert emoji into the docs. For example
Here is rocket 🚀
Here is rocket 🚀
List of all shortcodes could be found at Emojipedia or at Gist/rxaviers
- 🚀
- 😀
- 🐒
Feel free to suggest new features or report bugs :)
Api from v4.
Full docs for previous api are at README_V4.md
TL;DR:
Accepts README or array of README in markdown format. Multiple README is useful when you develop higher order components and want to add multiple READMEs along with the original component docs.
withReadme
Renders README at the addons panel.
;; // as HigherOrder Component;// as Decorator ;
withDocs
Renders README around the story.
;; // as HigherOrder Component;// as Decorator ;
doc
Renders README in main frame without story.
; ;