bikesled
v0.4.8
Published
Build component-based documentation for any client-side resource in your web project.
Readme
Bikesled
Component-based documentation for any front-end resource
Inspired by Pattern Lab's atomic design principles, Bikesled greases the runners of documentation for any bikeshed-able web component. It does this by generating documentation at the component level, whether those components are built with simple HTML + CSS, with standard JavaScript constructors, or with more complex JavaScript frameworks.
Features:
- simple static site generation for your documentation
- annotations, template display, and data-mocking for each component
- markdown-based annotation engine usable by non-developers
- framework-agnostic components/custom component renderers
Usage:
Bikesled is available as an npm module, and can be installed as a dependency for your project with:
npm install -g bikesled ```
Bikesled is run as a command-line utility. Compile your documentation with:
bikesled build ```
- Bikesled will output a directory (by default) that contains separate HTML, CSS, and JS files that document the configured components. What you do with that directory is up to you.
- Bikesled works with your project's pre-existing ES6 module structure! All you need to do is configure which modules to
import, and Bikesled will use the resources available in your project to build your documentation. - Configure Bikesled with a
.bikesledrcfile in your target directory. Point to modules that already exist in your project, or point to a module directory filled with custom modules, annotations, and data. - Bikesled groups your components according to their file names, so be sure to follow these conventions when creating, annotating, and mocking data for your components:
Make sure that all components across directories have unique names.
Use kebab-case for all resources (e.g.
my-first-basic-component.js).All component files have either
.htmlor.jsfile extensions.All annotations have markdown (
.md) file extensions.All data files have
.jsonfile extensions.Group all related files automatically by giving related component files the same name (e.g.
my-first-basic-component.js,my-first-basic-component.json, andmy-first-basic-component.md).The exception to the previous rule: your annotation files (
*.md) may be numbered. If they are numbered, each file will be parsed in turn and presented as a list item in the final documentation. For example, if001-hello.mdcontainedHello, and002-hello.mdcontainedWorld, the output would be:1. Hello 2. World
CLI options:
If you'd like to use a
.bikesledrcconfiguration file outside of your working directory, you can pass Bikesled a path to your configuration file with-c:
bikesled build -c /path/to/.bikesledrc.json ```
To output the compiled files to a target directory other than your working directory, use the
-toption:
bikesled build -t /path/to/output/directory/ ```
Configuration:
The easiest way to configure Bikesled is to use a configuration file, named .bikesledrc by convention, but any JSON file should be acceptable with the -c command-line option.
An example configuration file might look like so:
{
"output": "./docs",
"title": "Bikesled Example Documentation",
"components": {
"main": "./components"
},
"renderers": [
{
"test": "backbone",
"src": "./renderers/backbone-view.js"
},
{
"test": "\\.js$",
"src": "./renderers/example-constructor.js"
}
],
"stylesheet": "./styles/style.css",
"inline": false
}outputpoints to an output directory for compiled HTML, CSS, and JS files. DEFAULT:./docstitlesets the page title for your documentation page. DEFAULT:Bikesled Example Documentationcomponentspoints to the different directories that contain components to be documented, bundled, and included in the final output.mainrefers to the default set of components, organized and named according to Bikesled's custom component naming conventions (outlined above)- You can assign a title to any other directory in your project, and all relevant pieces
import-ed into each component will be bundled along with the rest of your components.
renderersare standard,require-able node modules that return strings that are boostrapped into the final, bundled JavaScript file contained in your output directory. All renderers are passed theidreserved for a particular component as well as any data imported from associatedJSONfiles. By default, all.jsfiles use a renderer that looks something like this:var camelCase = require( "lodash/fp/camelCase" ); function DefaultRenderer( id, data ){ return `document.getElementById( "${id}" ).innerHTML= ${camelCase( id )}( ${data} );`; } module.exports = DefaultRenderer;You can connect your own renderers through the
renderersconfiguration option by providing a regexteststring and asrcpath to your renderer. The regex is applied to the file path of the component's.jsfile, and the first regex that passes will govern which renderer is applied to the component. If no regex applies to the file path in question, then the renderer will fall back to the default.stylesheetis the path to your stylesheet. All Bikesled-specific components are carefully scoped so as not to interfere with your component styles.inlineis a boolean value. If set toTRUE, all styles and JS will be in-lined into a single output HTML document. Default behavior isFALSE, which means that Bikesled will output separate HTML, CSS, and JS files into a target directory (calleddocsby default).
Contributing
All contributions are welcome, provided that the style rules configured in the attached .eslintrc are followed. The full source and example code can be found in Bikesled's GitHub repository.
