npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-doc-gen

v2.4.0

Published

Automagically generate your Angular documentation.

Downloads

29

Readme

ngx-doc-gen 📚 npm version

Automatically generate your library's API docs using Angular CLI or NX.

Credits

The initial spark was given by the folks from the Angular team (angular/components) who are using a perfectly working base implementation on documentation generation utilizing Dgeni.

Props to those who deserve it 🍻

Most of the code as well as the templates and styles originate from their repository.

📕 Installation / Configuration

Using NX:

npm install --save-dev ngx-doc gen
nx generate ngx-doc-gen:configure

Using Angular CLI

ng add ngx-doc-gen

Those calls will add a doc-gen target similiar to the build one to all touched library projects.

🤖 Generation

Using NX:

nx run <project>:doc-gen

Using Angular CLI:

ng doc-gen <project>

While generation is running ngx-doc-gen will scan the given library for its entrypoints - or entrypoint if there is just one - and extract the public API. The heavy lifting is done by Dgeni.

After extraction it categorizes your API in like modules, services, etc. - just like its done when looking at the Angular Material docs - and processes specific templates.

After everything is done ngx-doc-gen will output an HTML file per entrypoint into the output directory (read on for configuration).

📖 Configuration options (configure / ng add)

--projects

  • Type: string[]
  • Defines the libraries which should get configured for documentation generation
  • Will throw an error if a project is listed which does not exist in the workspace
  • Default: []
  • Example:
    • NX: ng generate ngx-doc-gen:configure --projects lib-a,lib-b
    • Angular CLI: ng add ngx-doc-gen --projects lib-a,lib-b
    • Both examples will only configure the given library projects

If not provided or left empty - the default - configure (Generator) and ng add (Angular CLI) will scan your workspace for all buildable library projects and condigures them for documentation generation.

⚙️ Generation options

Per CLI

--log-level

  • Type: 'error' | 'warn' | 'debug' | 'verbose'
  • Defines the log level Dgeni uses while generation
  • Default: 'warn'

--output-path

  • Type: Path
  • Defines the output path for the generated files (relative to working directory)
  • Default: 'docs'

--exclude-base

  • Type: string[]
  • Defines base clases to exclude from generation
  • Default: []
  • Example:
    • Your API contains a service extending Observable which would include members like subscribe() in your documentation. This could be prevented as follows:
    • --exclude-base Observable

--docs-public

  • Type: string
  • Tag to enforce documentation of usually private symbols. Only applies to symbols at least exported.
  • Default: docs-public

--docs-private

  • Type: string,
  • Tag to explicitly hide symbols from documentation.
  • Default: docs-private

--breaking-change

  • Type: string,
  • Tag indicating the version with which a deprecated symbol will get removed.
  • Default: breaking-change

Per workspace config (angular.json / workspace.json / project.json)

Every CLI parameter can also be bound to the doc-gen target in your workspace configuration so you don't have to pass them on every CLI call - see example below.

Some parameters can be passed by configuration only.

customTags

  • Type: TagDefinition[]
  • Configures tag definition for the Dgeni JSDoc processor not supported by JSDoc.
  • Default: []

| Property | Type | Description | |---------------|-----------|-------------| | name | string | Name of the tag (excluding the @) | | docProperty? | string | Property where the tag information should be attached to. | | multi? | boolean | Whether multiple instances of the tag can be used in the same comment. | | required? | boolean | Whether this tag is required for all API documents. |

// Example given for a project.json
...
"<project>": {
  "targets": {
    "doc-gen": {
      "executor": "ngx-doc-gen:generate",
      "options": {
        "logLevel": "verbose",
        "outputPath": "./docs/libs/<project>",
        "excludeBase": [
          "Observable"
        ],
        "customTags": [
          {
            "name": "example"
          }
        ]
      }
    }
  }
}
...

🎨 Styling

As the generated docs are just plain HTML files you apply whatever styling you want. For convinience ngx-doc-gen comes with two SCSS mixins.

core

Applies some general styles for font, spacing, borders, etc. Just include the mixing in your root stylesheet.

@use 'ngx-doc-gen/styles' as ngx-doc-gen;

@include ngx-doc-gen.core();

docs-theme

Applies some Angular Material touch. Just pass your Angular Material theme into the mixin.

@use 'ngx-doc-gen/styles/theming' as ngx-doc-gen;

@include ngx-doc-gen.docs-theme($theme);