# @polymer/iron-doc-viewer

> Elements for rendering Polymer component documentation.

Latest version **4.0.1** (published 2018-09-14) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @polymer/iron-doc-viewer
pnpm add @polymer/iron-doc-viewer
yarn add @polymer/iron-doc-viewer
bun add @polymer/iron-doc-viewer
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2018-09-14 |
| First published | 2016-02-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 961.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 18 |
| Author | The Polymer Authors |
| Maintainers | aomarks, azakus, bicknellr, emarquez, justinfagnani, keanulee, notwaldorf, polymer-devs, samli, sorvell, usergenic |
| Keywords | web-component, web-components, polymer |

## Links

- npm: https://www.npmjs.com/package/@polymer/iron-doc-viewer
- Repository: https://github.com/PolymerElements/iron-doc-viewer
- Homepage: https://github.com/PolymerElements/iron-doc-viewer/
- Issues: https://github.com/PolymerElements/iron-doc-viewer/issues
- npm.io page: https://npm.io/package/@polymer/iron-doc-viewer

## Dependencies (5)

- [@polymer/polymer](https://npm.io/package/@polymer/polymer.md) ^3.0.0
- [@polymer/paper-styles](https://npm.io/package/@polymer/paper-styles.md) ^3.0.0-pre.26
- [@polymer/iron-location](https://npm.io/package/@polymer/iron-location.md) ^3.0.0-pre.26
- [@polymer/prism-element](https://npm.io/package/@polymer/prism-element.md) ^3.0.0-pre.26
- [@polymer/marked-element](https://npm.io/package/@polymer/marked-element.md) ^3.0.0-pre.26

## Recent versions

- 4.0.1 (latest) — 2018-09-14
- 3.0.0-pre.20 (next) — 2018-06-23
- 1.1.0-pre.3 (preview) — 2017-01-24
- 4.0.0 — 2018-09-13
- 4.0.0-pre.4 — 2018-09-12
- 4.0.0-pre.3 — 2018-08-29
- 4.0.0-pre.2 — 2018-08-29
- 4.0.0-pre.1 — 2018-08-25
- 4.0.0-pre.0 — 2018-08-25
- 3.0.0-pre.21 — 2018-06-23
- 3.0.0-pre.19 — 2018-05-09
- 3.0.0-pre.18 — 2018-05-09
- 3.0.0-pre.17 — 2018-05-08
- 3.0.0-pre.16 — 2018-05-04
- 3.0.0-pre.15 — 2018-05-02
- … 17 more at https://npm.io/package/@polymer/iron-doc-viewer/versions

## README

[![Published on NPM](https://img.shields.io/npm/v/@polymer/iron-doc-viewer.svg)](https://www.npmjs.com/package/@polymer/iron-doc-viewer)
[![Build status](https://travis-ci.org/PolymerElements/iron-doc-viewer.svg?branch=master)](https://travis-ci.org/PolymerElements/iron-doc-viewer)
[![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://webcomponents.org/element/@polymer/iron-doc-viewer)

## &lt;iron-doc-viewer&gt;

A collection of elements that display documentation about custom elements,
mixins, classes, and more using the JSON descriptor format produced by [Polymer
Analyzer](https://github.com/Polymer/polymer-analyzer).

See:
[Documentation](https://www.webcomponents.org/element/@polymer/iron-doc-viewer),
[Demo](https://www.webcomponents.org/element/@polymer/iron-doc-viewer/demo/demo/index.html).

You may also be interested in
[`<iron-component-page>`](https://github.com/PolymerElements/iron-component-page),
which composes the iron-doc elements into a more complete documentation
browser.

### Elements

* `<iron-doc-nav>` Show a table-of-contents.
* `<iron-doc-viewer>` Manage routing and delegate to a child doc element.
* `<iron-doc-element>` Show docs about a custom element.
* `<iron-doc-behavior>` Show docs about a Polymer behavior.
* `<iron-doc-namespace>` Show docs about a JavaScript namespace.
* `<iron-doc-class>` Show docs about a JavaScript class.
* `<iron-doc-mixin>` Show docs about a JavaScript mixin.

## Usage

### Installation
```
npm install --save @polymer/iron-doc-viewer
```

### In an html file
```html
<html>
  <head>
    <script type="module">
      import '@polymer/polymer/lib/elements/dom-bind.js';
      import '@polymer/iron-ajax/iron-ajax.js';
      import '@polymer/iron-doc-viewer/iron-doc-viewer.js';
    </script>
  </head>

  <body>
    <dom-bind>
      <template>
        <iron-ajax
          auto
          url="./analysis.json"
          last-response="{{descriptor}}">
        </iron-ajax>

        <iron-doc-viewer
          descriptor="[[descriptor]]"
          root-namespace="MyNamespace">
        </iron-doc-viewer>
      </template>
    </dom-bind>
  </body>
</html>
```

### In a Polymer 3 element
```js
import {PolymerElement, html} from '@polymer/polymer';
import '@polymer/iron-doc-viewer/iron-doc-viewer.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
      <iron-doc-viewer
        descriptor="[[descriptor]]"
        root-namespace="MyNamespace">
      </iron-doc-viewer>
    `;
  },

  static get properties() {
    return {
      descriptor: {
        type: Object,
        value: {
          // Analyzer descriptor goes here.
        }
      }
    };
  }
}

customElements.define('sample-element', SampleElement);
```

### Routing

`<iron-doc-viewer>` handles URL routing to provide permanent addresses for all
locations in the documentation tree, including scroll anchor targets.

By default it uses the URL fragment for routing (e.g.
`docs.html#/elements/my-element#property-foo`), in order to support simple
static file hosts.

To use the real URL path for routing, set the `base-href` property to the
server mount point, omitting the trailing slash (e.g. `/api/docs` or *empty
string* for the root path). Note that this requires a host that serves the
application from all paths that should be handled by the doc viewer.

### Styling

The iron-doc elements come with an optional material-design default theme that
must be explicitly included as custom style:

```html
<script type="module">
  import '@polymer/iron-doc-viewer/default-theme.js';
</script>

<custom-style>
  <style is="custom-style" include="iron-doc-default-theme"></style>
</custom-style>
```

The following custom properties and mixins are available for styling:

Custom property | Description | Default
----------------|-------------|----------
`--iron-doc-accent-color` | Color for emphasis (e.g. hyperlink hover). | `#1565c0`
`--iron-doc-font-body` | Mixin applied to non-code text. | `{}`
`--iron-doc-font-code` | Mixin applied to code snippets. | `{}`
`--iron-doc-title` | Mixin applied to page titles. | `{}`
`--iron-doc-heading` | Mixin applied to section headings. | `{}`

## Contributing
If you want to send a PR to this element, here are
the instructions for running the tests and demo locally:

### Installation
```sh
git clone https://github.com/PolymerElements/iron-doc-viewer
cd iron-doc-viewer
npm install
npm install -g polymer-cli
```

### Running the demo locally
```sh
polymer serve --npm
open http://127.0.0.1:<port>/demo/
```

### Running the tests
```sh
polymer test --npm
```

---
_Source: https://npm.io/package/@polymer/iron-doc-viewer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
