0.0.4 • Published 2 years ago

cem-plugin-type-descriptions-markdown v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

cem-plugin-type-descriptions-markdown

Appends Markdown documents to function parameter and return types and class field types.

Options

OptionTypeRequiredDescription
typeTablesDirstringyesAbsolute path to the directory holding the type docs.
quietboolnoSuppress logs

Example

custom-elements-manifest.config.js

import { fileURLToPath } from 'url';
import { typeDescriptionsMarkdownPlugin } from 'cem-plugin-type-descriptions-markdown';

export default {
  plugins: [
    typeDescriptionsMarkdownPlugin({
      typeTablesDir: fileURLToPath(new URL('../../docs/type-tables/', import.meta.url)),
    }),
  ]
}

docs/type-tables/BigBagOfProperties.md

| Option     | Type   | Description |
| ---------- | ------ | ----------- |
| name       | string | The name of the thing |
| shoeSize   | number | Act your age |

src/shoe-sizer.ts

interface BigBagOfProperties {
  name?: string;
  shoeSize?: number;
}

/** @element shoe-sizer */
export class ShoeSizer {
  /** @summary Shoe Size options */
  declare options: BigBagOfProperties;
}

Output

{
  "schemaVersion": "1.0.0",
  "readme": "",
  "modules": [
    {
      "kind": "javascript-module",
      "path": "src/shoe-sizer.js",
      "declarations": [
        {
          "kind": "class",
          "name": "ShoeSizer",
          "description": "",
          "members": [
            {
              "kind": "field",
              "name": "options",
              "summary": "Shoe Size options",
              "description": "| Option     | Type   | Description |\n| ---------- | ------ | ----------- |\n| name       | string | The name of the thing |\n| shoeSize   | number | Act your age |",
              "type": {
                "text": "BigBagOfProperties"
              }
            }
          ],
          "tagName": "shoe-sizer",
          "customElement": true
        }
      ],
      "exports": [
        {
          "kind": "js",
          "name": "ShoeSizer",
          "declaration": {
            "name": "ShoeSizer",
            "module": "src/shoe-sizer.js"
          }
        }
      ]
    }
  ]
}