react-docgen-typescript

  • Version 2.4.0
  • Published
  • 263 kB
  • No dependencies
  • MIT license

Install

npm i react-docgen-typescript
yarn add react-docgen-typescript
pnpm add react-docgen-typescript

Overview

[![Build Status](https://github.com/styleguidist/react-docgen-typescript/actions/workflows/nodejs.yml/badge.svg)](https://github.com/styleguidist/react-docgen-typescript/actions/workflows/nodejs.yml)

Index

Functions

function getDefaultExportForFile

getDefaultExportForFile: (source: ts.SourceFile) => string;

    function parse

    parse: (
    filePathOrPaths: string | string[],
    parserOpts?: ParserOptions
    ) => ComponentDoc[];
    • Parses a file with default TS options

      Parameter filePathOrPaths

      component file that should be parsed

      Parameter parserOpts

      options used to parse the files

    function withCompilerOptions

    withCompilerOptions: (
    compilerOptions: ts.CompilerOptions,
    parserOpts?: ParserOptions
    ) => FileParser;
    • Constructs a parser for a specified set of TS compiler options.

    function withCustomConfig

    withCustomConfig: (
    tsconfigPath: string,
    parserOpts: ParserOptions
    ) => FileParser;
    • Constructs a parser for a specified tsconfig file.

    function withDefaultConfig

    withDefaultConfig: (parserOpts?: ParserOptions) => FileParser;
    • Constructs a parser for a default configuration.

    Classes

    class Parser

    class Parser {}

      constructor

      constructor(program: ts.Program, opts: ParserOptions);

        method extractDefaultPropsFromComponent

        extractDefaultPropsFromComponent: (
        symbol: ts.Symbol,
        source: ts.SourceFile
        ) => {};

          method extractMembersFromType

          extractMembersFromType: (type: ts.Type) => ts.Symbol[];

            method extractPropsFromTypeIfStatefulComponent

            extractPropsFromTypeIfStatefulComponent: (type: ts.Type) => ts.Symbol | null;

              method extractPropsFromTypeIfStatelessComponent

              extractPropsFromTypeIfStatelessComponent: (type: ts.Type) => ts.Symbol | null;

                method findDocComment

                findDocComment: (symbol: ts.Symbol) => JSDoc;

                  method getCallSignature

                  getCallSignature: (symbol: ts.Symbol) => ts.Signature;

                    method getComponentExports

                    getComponentExports: (
                    exp: ts.Symbol
                    ) => { symbol: ts.Symbol; exports: ts.SymbolTable } | undefined;
                    • Attempts to gather a symbol's exports. Some symbol's like default exports are aliased, so we need to get the real symbol.

                      Parameter exp

                      symbol

                    method getComponentInfo

                    getComponentInfo: (
                    exp: ts.Symbol,
                    source: ts.SourceFile,
                    componentNameResolver?: ComponentNameResolver,
                    customComponentTypes?: ParserOptions['customComponentTypes']
                    ) => ComponentDoc | null;

                      method getDocgenType

                      getDocgenType: (propType: ts.Type, isRequired: boolean) => PropItemType;

                        method getFullJsDocComment

                        getFullJsDocComment: (symbol: ts.Symbol) => JSDoc;
                        • Extracts a full JsDoc comment from a symbol, even though TypeScript has broken down the JsDoc comment into plain text and JsDoc tags.

                        method getFunctionStatement

                        getFunctionStatement: (
                        statement: ts.Statement
                        ) =>
                        | ts.ArrowFunction
                        | ts.FunctionExpression
                        | ts.FunctionDeclaration
                        | undefined;

                          method getLiteralValueFromImportSpecifier

                          getLiteralValueFromImportSpecifier: (
                          property: ts.ImportSpecifier
                          ) => string | boolean | number | null | undefined;

                            method getLiteralValueFromPropertyAssignment

                            getLiteralValueFromPropertyAssignment: (
                            property: ts.PropertyAssignment | ts.BindingElement
                            ) => string | boolean | number | null | undefined;

                              method getMethodsInfo

                              getMethodsInfo: (type: ts.Type) => Method[];

                                method getModifiers

                                getModifiers: (member: ts.Symbol) => string[];

                                  method getParameterInfo

                                  getParameterInfo: (callSignature: ts.Signature) => MethodParameter[];

                                    method getPropMap

                                    getPropMap: (
                                    properties: ts.NodeArray<any>
                                    ) => StringIndexedObject<string | boolean | number | null>;

                                      method getPropsInfo

                                      getPropsInfo: (
                                      propsObj: ts.Symbol,
                                      defaultProps?: StringIndexedObject<string>
                                      ) => Props;

                                        method getReturnDescription

                                        getReturnDescription: (symbol: ts.Symbol) => SymbolDisplayPart[] | undefined;

                                          method getTypeSymbol

                                          getTypeSymbol: (exp: ts.Symbol) => ts.Symbol;

                                            method isPlainObjectType

                                            isPlainObjectType: (exp: ts.Symbol) => boolean;

                                              method isTaggedPublic

                                              isTaggedPublic: (symbol: ts.Symbol) => boolean;

                                                Interfaces

                                                interface ComponentDoc

                                                interface ComponentDoc {}

                                                  property description

                                                  description: string;

                                                    property displayName

                                                    displayName: string;

                                                      property expression

                                                      expression?: ts.Symbol;

                                                        property filePath

                                                        filePath: string;

                                                          property methods

                                                          methods: Method[];

                                                            property props

                                                            props: Props;

                                                              property rootExpression

                                                              rootExpression?: ts.Symbol;

                                                                property tags

                                                                tags?: StringIndexedObject<string>;

                                                                  interface FileParser

                                                                  interface FileParser {}

                                                                    method parse

                                                                    parse: (filePathOrPaths: string | string[]) => ComponentDoc[];

                                                                      method parseWithProgramProvider

                                                                      parseWithProgramProvider: (
                                                                      filePathOrPaths: string | string[],
                                                                      programProvider?: () => ts.Program
                                                                      ) => ComponentDoc[];

                                                                        interface ParserOptions

                                                                        interface ParserOptions {}

                                                                          property componentNameResolver

                                                                          componentNameResolver?: ComponentNameResolver;

                                                                            property customComponentTypes

                                                                            customComponentTypes?: string[];

                                                                              property propFilter

                                                                              propFilter?: StaticPropFilter | PropFilter;

                                                                                property savePropValueAsString

                                                                                savePropValueAsString?: boolean;

                                                                                  property shouldExtractLiteralValuesFromEnum

                                                                                  shouldExtractLiteralValuesFromEnum?: boolean;

                                                                                    property shouldExtractValuesFromUnion

                                                                                    shouldExtractValuesFromUnion?: boolean;

                                                                                      property shouldIncludeExpression

                                                                                      shouldIncludeExpression?: boolean;

                                                                                        property shouldIncludePropTagMap

                                                                                        shouldIncludePropTagMap?: boolean;

                                                                                          property shouldRemoveUndefinedFromOptional

                                                                                          shouldRemoveUndefinedFromOptional?: boolean;

                                                                                            property shouldSortUnions

                                                                                            shouldSortUnions?: boolean;

                                                                                              property skipChildrenPropWithoutDoc

                                                                                              skipChildrenPropWithoutDoc?: boolean;

                                                                                                interface PropItem

                                                                                                interface PropItem {}

                                                                                                  property declarations

                                                                                                  declarations?: ParentType[];

                                                                                                    property defaultValue

                                                                                                    defaultValue: any;

                                                                                                      property description

                                                                                                      description: string;

                                                                                                        property name

                                                                                                        name: string;

                                                                                                          property parent

                                                                                                          parent?: ParentType;

                                                                                                            property required

                                                                                                            required: boolean;

                                                                                                              property tags

                                                                                                              tags?: {};

                                                                                                                property type

                                                                                                                type: PropItemType;

                                                                                                                  interface PropItemType

                                                                                                                  interface PropItemType {}

                                                                                                                    property name

                                                                                                                    name: string;

                                                                                                                      property raw

                                                                                                                      raw?: string;

                                                                                                                        property value

                                                                                                                        value?: any;

                                                                                                                          interface Props

                                                                                                                          interface Props extends StringIndexedObject<PropItem> {}

                                                                                                                            Package Files (2)

                                                                                                                            Dependencies (0)

                                                                                                                            No dependencies.

                                                                                                                            Dev Dependencies (19)

                                                                                                                            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/react-docgen-typescript.

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