# angular-docgen

> A toolkit to extract information from Angular components for documentation generation.

Latest version **1.3.2** (published 2020-05-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install angular-docgen
pnpm add angular-docgen
yarn add angular-docgen
bun add angular-docgen
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2020-05-01 |
| First published | 2019-03-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 0 |
| Unpacked size | 35.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | thatguynamedandy |
| Maintainers | thatguynamedandy |
| Keywords | angular, pattern-library, documentation-generation |

## Links

- npm: https://www.npmjs.com/package/angular-docgen
- Repository: https://github.com/thatguynamedandy/angular-docgen
- Homepage: https://github.com/thatguynamedandy/angular-docgen#readme
- Issues: https://github.com/thatguynamedandy/angular-docgen/issues
- npm.io page: https://npm.io/package/angular-docgen

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 1.3.2 (latest) — 2020-05-01
- 1.3.1 — 2019-04-24
- 1.3.0 — 2019-04-24
- 1.2.0 — 2019-04-18
- 1.1.0 — 2019-04-18
- 1.0.1 — 2019-04-11
- 1.0.0-alpha.3 — 2019-04-10
- 1.0.0-alpha.2 — 2019-03-26
- 1.0.0-alpha.1 — 2019-03-26
- 1.0.0-alpha.0 — 2019-03-19

## README

# Angular Docgen

This is a low level library for parsing Angular components into JSON, inspired heavily by [react-docgen](https://github.com/react/react-docgen). The intended use case is for documenting design systems where you want full control over the visuals.

Use in conjunction with [angular-docgen-loader](https://github.com/thatguynamedandy/angular-docgen-loader) to load the component definitions into your angular project.

### Sample input

```ts
import { Component, Input } from "@angular/core";

/**
 * A nice button component
 */
@Component({
  selector: "my-button",
  templateUrl: "template.html",
  styleUrls: ["styles1.css", "styles2.css"]
})
export class Button {
  /**
   * Is button disabled
   */
  @Input() disabled: boolean = false;

  /**
   * Button variant
   */
  @Input() variant: "primary" | "secondary" = "primary";

  /**
   * onClick output
   */
  @Output() onClick = new EventEmitter<boolean>();
}
```

### Sample output

```json
{
  "component": {
    "name": "Button",
    "description": "A nice button component",
    "templateUrl": "template.html",
    "selector": "my-button",
    "styleUrls": [
      "styles1.css",
      "styles2.css",
    ],
  },
  "inputs": [{
    "description": "Is button disabled",
    "name": "disabled",
    "type": "boolean",
    "value": false
  }, {
    "description": "Button variant",
    "name": "type",
    "variant": "string",
    "options": ["primary", "secondary"],
    "value": "primary"
  }],
  "outputs": [{
    "description": "onClick output",
    "name": "onClick",
    "value": "new EventEmitter<boolean>()",
  }]
}
```
It works by using the typescript parser to parse an Angular component file into an Abstract Syntax Tree (AST).

If you fancy a go at working with this I recommend using the wonderful [astexplorer.net](astexplorer.net). Paste the sample component in, use the Typescript loader and then you can see the AST that you need to navigate.

---
_Source: https://npm.io/package/angular-docgen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
