@latticejs/storybook-readme
Private set of storybook readme addon helpers to be used within @latticejs packages.
Api
withReadme
function(readme: String) => (function(sections: Array))
Adds aReadme
section tab for your Storybook.
Returns another function to be used as storybook HOC that injects some sections (joined) from readme
passed as argument. See Usage for more info.
You must include the tags <!-- start:section_name -->
and <!-- end:section_name -->
to indicate the start and the end of your readme section to be included.
Usage
withReadme
To load some sections of your readme:
import { withReadme } from '@latticejs/storybook-readme';
import Readme from 'path/to/your/README.md';
const loadSections = withReadme(Readme);
const withSomeReadmeSections = loadSections(['api', 'usage']);
export default ({ storiesOf }) => {
storiesOf('components', module)
.add(
'basic',
withSomeReadmeSections(() => (
<Basic />
))
);
};
To load all the content of Readme:
import { withReadme } from '@latticejs/storybook-readme';
import Readme from 'path/to/your/README.md';
const withAllReadme = withReadme(Readme);
export default ({ storiesOf }) => {
storiesOf('components', module)
.add(
'basic',
withAllReadme(() => (
<Basic />
))
);
};