vue-docgen-api

  • Version 4.79.1
  • Published
  • 808 kB
  • 12 dependencies
  • MIT license

Install

npm i vue-docgen-api
yarn add vue-docgen-api
pnpm add vue-docgen-api

Overview

Toolbox to extract information from Vue component files for documentation generation purposes.

Index

Functions

function getDocblock

getDocblock: (
path: NodePath,
{ commentIndex }?: { commentIndex?: number }
) => string | null;
  • Given a path, this function returns the closest preceding docblock if it exists.

function getDoclets

getDoclets: (str: string) => DocBlockTags;
  • Given a string, this functions returns an object with two keys: - tags an array of tags {title: tagname, content: } - description whatever is left once the tags are removed

function getProperties

getProperties: (path: NodePath, id: string) => NodePath[];

    function parse

    parse: (
    filePath: string,
    opts?: DocGenOptions | { [alias: string]: string }
    ) => Promise<ComponentDoc>;
    • Parse the component at filePath and return props, public methods, events and slots

      Parameter filePath

      absolute path of the parsed file

      Parameter opts

    function parseMulti

    parseMulti: (filePath: string, opts?: DocGenOptions) => Promise<ComponentDoc[]>;
    • Parse all the components at filePath and returns an array of their props, public methods, events and slot

      Parameter filePath

      absolute path of the parsed file

      Parameter opts

    function parseSource

    parseSource: (
    source: string,
    filePath: string,
    opts?: DocGenOptions | { [alias: string]: string }
    ) => Promise<ComponentDoc>;
    • Parse the source assuming that it is located at filePath and return props, public methods, events and slots

      Parameter source

      source code to be parsed

      Parameter filePath

      absolute path of the parsed file

      Parameter opts

    Classes

    class Documentation

    class Documentation {}

      constructor

      constructor(fullFilePath: string);

        property componentFullfilePath

        readonly componentFullfilePath: string;

          property sourceFiles

          readonly sourceFiles: Set<string>;

            method get

            get: (key: string) => any;

              method getEventDescriptor

              getEventDescriptor: (eventName: string) => EventDescriptor;

                method getExposeDescriptor

                getExposeDescriptor: (exposedName: string) => ExposeDescriptor;

                  method getMethodDescriptor

                  getMethodDescriptor: (methodName: string) => MethodDescriptor;

                    method getPropDescriptor

                    getPropDescriptor: (propName: string) => PropDescriptor;

                      method getSlotDescriptor

                      getSlotDescriptor: (slotName: string) => SlotDescriptor;

                        method set

                        set: (key: string, value: any) => void;

                          method setDocsBlocks

                          setDocsBlocks: (docsBlocks: string[]) => void;

                            method setOrigin

                            setOrigin: (origin: Descriptor) => void;

                              method toObject

                              toObject: () => ComponentDoc;

                                Interfaces

                                interface DocGenOptions

                                interface DocGenOptions {}

                                  property addScriptHandlers

                                  addScriptHandlers?: ScriptHandler[];
                                  • Handlers that will be added at the end of the script analysis

                                  property addTemplateHandlers

                                  addTemplateHandlers?: TemplateHandler[];
                                  • Handlers that will be added at the end of the template analysis

                                  property alias

                                  alias?: {
                                  [alias: string]: string | string[];
                                  };
                                  • What alias should be replaced in requires and imports

                                  property jsx

                                  jsx?: boolean;
                                  • Does parsed components use jsx? true - if you do not disable it, babel will fail with (<any>window).$

                                  property modules

                                  modules?: string[];
                                  • What directories should be searched when resolving modules

                                  property nameFilter

                                  nameFilter?: string[];
                                  • Which exported variables should be looked at undefined - means treat all exports

                                  property pugOptions

                                  pugOptions?: PugOptions;
                                  • all pug options passed to the pug compiler if you use it

                                  property scriptHandlers

                                  scriptHandlers?: ScriptHandler[];
                                  • Handlers that will replace the main script analysis

                                  property scriptPreHandlers

                                  scriptPreHandlers?: ScriptHandler[];
                                  • Handlers that will replace the extend and mixins analyzer They will be run before the main component analysis to avoid bleeding onto the main

                                  property templateHandlers

                                  templateHandlers?: TemplateHandler[];
                                  • Handlers that will replace the template analysis

                                  property validExtends

                                  validExtends?: (fullFilePath: string) => boolean;
                                  • Should extended components be parsed? fullFilePath=>!/[\\/]node_modules[\\/]/.test(fullFilePath)

                                  interface ParseOptions

                                  interface ParseOptions extends DocGenOptions, Descriptor {}

                                    property filePath

                                    filePath: string;

                                      property lang

                                      lang?: 'ts' | 'js';
                                      • In what language is the component written undefined - let the system decide

                                      property validExtends

                                      validExtends: (fullFilePath: string) => boolean;

                                        interface TemplateParserOptions

                                        interface TemplateParserOptions {}

                                          property functional

                                          functional: boolean;

                                            Type Aliases

                                            type ScriptHandler

                                            type ScriptHandler = (
                                            doc: Documentation,
                                            componentDefinition: NodePath,
                                            ast: bt.File,
                                            opt: ParseOptions,
                                            deps: {
                                            parseFile: ParseFileFunction;
                                            addDefaultAndExecuteHandlers: HandlerExecutorsFunction;
                                            }
                                            ) => Promise<void>;

                                              type TemplateHandler

                                              type TemplateHandler = (
                                              documentation: Documentation,
                                              templateAst: TemplateChildNode,
                                              siblings: TemplateChildNode[],
                                              options: TemplateParserOptions
                                              ) => void;

                                                Namespaces

                                                namespace ScriptHandlers

                                                module 'dist/script-handlers/index.d.ts' {}

                                                  variable defaultHandlers

                                                  const defaultHandlers: ScriptHandler[];

                                                    variable extendsHandler

                                                    const extendsHandler: ScriptHandler;
                                                    • Returns documentation of the component referenced in the extends property of the component

                                                    variable mixinsHandler

                                                    const mixinsHandler: ScriptHandler;
                                                    • Look in the mixin section of a component. Parse the file mixins point to. Add the necessary info to the current doc object. Must be run first as mixins do not override components.

                                                    variable preHandlers

                                                    const preHandlers: ScriptHandler[];

                                                      function classDisplayNameHandler

                                                      classDisplayNameHandler: (
                                                      documentation: Documentation,
                                                      path: NodePath
                                                      ) => Promise<void>;
                                                      • Extracts the name of the component from a class-style component

                                                        Parameter documentation

                                                        Parameter path

                                                      function classEventHandler

                                                      classEventHandler: (
                                                      documentation: Documentation,
                                                      path: NodePath,
                                                      astPath: bt.File
                                                      ) => Promise<void>;
                                                      • Extracts all events from a class-style component code

                                                        Parameter documentation

                                                        Parameter path

                                                        Parameter astPath

                                                      function classMethodHandler

                                                      classMethodHandler: (
                                                      documentation: Documentation,
                                                      path: NodePath
                                                      ) => Promise<void>;
                                                      • Extracts all information about methods in a class-style Component

                                                        Parameter documentation

                                                        Parameter path

                                                      function classPropHandler

                                                      classPropHandler: (
                                                      documentation: Documentation,
                                                      path: NodePath<bt.ClassDeclaration>,
                                                      ast: bt.File,
                                                      opt: ParseOptions
                                                      ) => Promise<void>;
                                                      • Extracts prop information from a class-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      function componentHandler

                                                      componentHandler: (
                                                      documentation: Documentation,
                                                      path: NodePath
                                                      ) => Promise<void>;
                                                      • Extracts prop information from an object-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      function displayNameHandler

                                                      displayNameHandler: (
                                                      documentation: Documentation,
                                                      compDef: NodePath
                                                      ) => Promise<void>;
                                                      • Extracts component name from an object-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      function eventHandler

                                                      eventHandler: (
                                                      documentation: Documentation,
                                                      path: NodePath,
                                                      astPath: bt.File
                                                      ) => Promise<void>;
                                                      • Extracts events information from a VueJs component wether it's a class based component or an option based one

                                                        Parameter documentation

                                                        Parameter path

                                                        Parameter astPath

                                                      function methodHandler

                                                      methodHandler: (documentation: Documentation, path: NodePath) => Promise<void>;
                                                      • Extracts methods information from an object-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      function propHandler

                                                      propHandler: (
                                                      documentation: Documentation,
                                                      path: NodePath,
                                                      ast: bt.File,
                                                      opt: ParseOptions
                                                      ) => Promise<void>;
                                                      • Extract props information form an object-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      function slotHandler

                                                      slotHandler: (documentation: Documentation, path: NodePath) => Promise<void>;
                                                      • Extract slots information form the render function of an object-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      function slotHandlerFunctional

                                                      slotHandlerFunctional: (
                                                      documentation: Documentation,
                                                      path: NodePath
                                                      ) => Promise<void>;
                                                      • Extract slots information form the render function of an object-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      function slotHandlerLitteral

                                                      slotHandlerLitteral: (
                                                      documentation: Documentation,
                                                      path: NodePath
                                                      ) => Promise<void>;
                                                      • Extract slots information from the render or setup function of an object-style VueJs component

                                                        Parameter documentation

                                                        Parameter path

                                                      namespace TemplateHandlers

                                                      module 'dist/template-handlers/index.d.ts' {}

                                                        variable _default

                                                        const _default: ((
                                                        documentation: Documentation,
                                                        templateAst: TemplateChildNode,
                                                        siblings: TemplateChildNode[],
                                                        options: TemplateParserOptions
                                                        ) => void)[];

                                                          Package Files (23)

                                                          Dependencies (12)

                                                          Dev Dependencies (16)

                                                          Peer Dependencies (1)

                                                          Badge

                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/vue-docgen-api.

                                                          • Markdown
                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/vue-docgen-api)
                                                          • HTML
                                                            <a href="https://www.jsdocs.io/package/vue-docgen-api"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>