| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Fork of React Style Guide generator react-styleguidist with integration to SourceJS platform.
Original styleguidist example. (example with SourceJS will be available later)
To add automatically generated React props docs use sourcejs-react-docgen plugin. Check SourceJS React bundle example for more insights.
cd sourcejs-project npm install sourcejs-react-styleguidist --save
Add custom markdown renderer conf into SourceJS options.js file:
module.exports = {
core: {
processMd: {
languageRenderers: {
jsx: require('sourcejs-react-styleguidist/core/lang-jsx').processExample
}
}
}
};After re-running your SourceJS app, plugin will be loaded automatically.
Configure path to components in SourceJS options.js file:
module.exports = {
plugins: {
reactStyleguidist: {
rootDir: './relative/path/to/components',
components: './**/*.jsx'
}
}
};See Configuration section below for the list of available options.
Examples are written in Markdown where any code blocks will be rendered as a react components. By default any readme.md in the component folder is treated as an examples file but you can change it with the getExampleFilename option.
React component example: ```jsx <Button size="large">Push Me</Button> ``` Any [Markdown](http://daringfireball.net/projects/markdown/): * Foo; * bar; * baz.
SourceJS plugins are loaded together with main application, adding additional initialization steps or changing rendering flow using middleware integration. With this plugin, in development mode, SourceJS in enhanced with webpack middleware, that builds all the React examples on demand and listens to file changes for hot-reloading.
In production mode webpack is not triggered, expecting that bundle is already built (read configuration section for more).
Rendering flow with this plugins looks like this:
Use SourceJS options.js for deep plugin configuration.
enabled Type: Boolean Set to false, if wan't to disable plugin load with SourceJS app.
preBuild Type: Boolean Set to true, if you wan't to automatically build webpack bundle in production mode right after app starts.
rootDir Type: String, required Your components sources root folder (eg. ./lib). Should not point to a folder with the node_modules folder.
components Type: String or Function, required
If your components look like components/Button.jsx or components/Button/Button.jsx or components/Button/index.jsx:
components: './components/**/*.jsx'If your components look like components/Button/Button.js + components/Button/index.js:
components: function(config, glob) {
return glob.sync(config.rootDir + '/components/**/*.js').filter(function(module) {
return /\/[A-Z][a-z]*\.js$/.test(module);
});
},highlightTheme Type: String, default: base16-light CodeMirror theme name to use for syntax highlighting in examples.
getExampleFilename Type: Function, default: finds readme.md in the component folder Function that returns examples file path for a given component path.
For example, instead of readme.md you can use ComponentName.examples.md:
getExampleFilename: function(componentpath) {
return componentpath.replace(/\.jsx?$/, '.examples.md');
}updateWebpackConfig Type: Function, optional Function that allows you to modify Webpack config for style guide:
updateWebpackConfig: function(webpackConfig, env) {
if (env === 'development') {
/* ... modify config ... */
}
return webpackConfig;
}Running app with NODE_ENV=production, initial webpack build won't be triggered. To properly prepare production environment, first run react-styleguidist build command, and only after that run application:
NODE_ENV=production node ./node_modules/sourcejs-react-styleguidist/core/build.js NODE_ENV=production npm start
Note: this command should be ran from SourceJS root folder, where node_modules is placed.
Alternatively, you can set preBuild to true in plugin configuration, to build webpack bundle once app is ran in production mode. This will require less build steps, but may cause higher load in production environment container.
Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.
The MIT License, see the included license.md file.
| Back | FazBrowse Home | New Git URL |