Dope Docs
:lipstick: :green_book: Storybook inspired Angular docs generator
What is this?
Dope Docs is a CLI and Library that will create beautiful documentation, styleguides, and demos for your Angular UI bits (components, directives, pipes). Perfect your component libs, and styleguides for your team.
Getting Starting
Dope docs supports Angular 2 and beyond only. Now, lets get your docs going so you can stop procrastinating :100:.
Installing
yarn add @angularclass/dope-docs
Creating docs
For every UI element you want to add, you'll create a doc for it. We follow the convention of [name].doc.ts
. And then for each doc, you'll add examples. Below we have a button, and it has multiple states, so we create an example for each state.
import { docsFor, DopeDoc } from '@angularclass/dope-docs'
export default docsFor(
'Dope Button',
'This button is so fire, yo have to use it. If you want the monies, use this button',
{inputs: [], outputs: []}
)
.example('primary', {
description: 'Default and primary button state',
showSource: true,
context: {
type: 'primary'
},
template: `
<dope-button [buttonStyle]="type">
click me
</dope-button>
`
})
.example('warning', {
template: `
<dope-button buttonStyle="warning">
click me
</dope-button>
`,
description: 'Warning button type'
})
.example()
Bootstrapping
Because DopeDocs is an Angular app, it must be bootstrapped with all your examples. So create a new entry file for it, like you would with an entry NgModule
.
import 'core-js'
import 'zone.js'
import { FormsModule } from '@angular/forms'
import { createDopeDocs } from '@angularclass/dope-docs'
import { UIModule } from './app/ui'
createDopeDocs({
ngModule: UIModule,
entryMarkdown: `# My Teams' Components`,
ngModuleImports: [
FormsModule
],
loadUIGuides() {
const context = (require as any).context('./', true, /\.doc\.ts/)
return context.keys().map(context).map((mod: any) => mod.default)
}
})
Setup build
Last step is to setup configuration. Create a dope.js
on your root file. Your Angular app probably has a specific build setup, so DopeDocs will use that setup to build itself and your App.
module.exports = {
webpackConfig: require('./webpack.config')
entry: './src/dope-docs.ts'
}
Inspiration
Contributing
PR's and issues welcome!
There aren't any tests associated with this, so your code will be look at carefully