Socket
Book a DemoInstallSign in
Socket

@boundstate/ng-docs

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boundstate/ng-docs

Docs generator for Angular libraries.

latest
Source
npmnpm
Version
0.0.9
Version published
Maintainers
2
Created
Source

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

FAQs

Package last updated on 22 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts