0.0.9 • Published 4 years ago

@boundstate/ng-docs-cli v0.0.9

Weekly downloads
32
License
MIT
Repository
gitlab
Last release
4 years ago

ng-docs

Docs generator for Angular libraries.

Quick start

$ npm i -D @boundstate/ng-docs @boundstate/ng-docs-cli

The following assumes you use Angular CLI to generate a library, and your workspace is setup like this:

├── projects/
│   └── my-lib/     (library)
├── src/            (app)

Use the CLI to generate docs for your library and write the output to your app. Add this to your build scripts (e.g. package.json) so that it's run before ng serve and ng build commands:

ng-docs --base=projects/my-lib src/app/docs.ts

Modify your app to display the docs:

import {DocsModule} from '@boundstate/ng-docs';

import {docs} from './docs'; // generated docs

@Component({
  selector: 'app-root',
  template: `<ngd-app></ngd-app>`,
})
export class AppComponent {}

@NgModule({
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    DocsModule.forRoot(docs),
  ],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

Demos

You can include demos in your app by creating demo modules and passing them to DocsModule.forRoot():

DocsModule.forRoot(docs, {demos: [
  HelloWorldDemoModule,
]}),

Your demo modules must use the @Demo() decorator:

import {Component, NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {Demo} from '@boundstate/ng-docs';

import {MyLibModule} from 'my-lib';

@Component({template: '<app-hello-world color="purple"></app-hello-world>'})
export class HelloWorldDemoComponent {}

@Demo({
  id: 'hello-world',
  name: 'Hello World',
  related: ['HelloWorldComponent'],
})
@NgModule({
  imports: [
    MyLibModule,
    RouterModule.forChild([{path: '', component: HelloWorldDemoComponent}]),
  ],
  declarations: [HelloWorldDemoComponent],
})
export class HelloWorldDemoModule {}

Known issues

Demo modules will not load in AOT builds: https://github.com/angular/angular-cli/issues/4192

Workaround: disable AOT

Development

Running the demo

$ npm run build:lib
$ npm start
0.0.9

4 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago