@jsdocs-io/extractor

  • Version 0.3.0
  • Published
  • 777 kB
  • 10 dependencies
  • AGPL-3.0-or-later license

Install

npm i @jsdocs-io/extractor
yarn add @jsdocs-io/extractor
pnpm add @jsdocs-io/extractor

Overview

Analyze and extract the API from npm packages

Index

Functions

Interfaces

Enums

Functions

function analyzeRegistryPackage

analyzeRegistryPackage: ({
name,
version,
registry,
mirrors,
ignoreLicense,
ignoreFilePatternOptimizations,
skipAPIExtraction,
}: {
name: string;
version?: string;
registry?: string;
mirrors?: string[];
ignoreLicense?: boolean;
ignoreFilePatternOptimizations?: boolean;
skipAPIExtraction?: boolean;
}) => Promise<RegistryPackageInfo>;
  • analyzeRegistryPackage analyzes a package hosted on a registry and tries to extract its public API.

    Parameter name

    package name

    Parameter version

    package version (default: latest)

    Parameter registry

    registry URL (default: npm registry)

    Parameter mirrors

    URLs of registry mirrors (default: npm registry mirrors)

    Parameter ignoreLicense

    if true, extract API from unlicensed or proprietary packages (default: false)

    Parameter ignoreFilePatternOptimizations

    if true, ignore file pattern optimizations for known npm packages (default: false)

    Parameter skipAPIExtraction

    if true, do not extract the API from the package (default: false)

    Example 1

    Analyze the latest version of package query-registry from the npm registry:

    import { analyzeRegistryPackage } from '@jsdocs-io/extractor';
    (async () => {
    const info = await analyzeRegistryPackage({ name: 'query-registry' });
    // Output: 'query-registry'
    console.log(info.manifest.name);
    // Output: 'string'
    console.log(typeof info.api?.overview);
    })();

    See Also

function isClassConstructorDeclaration

isClassConstructorDeclaration: (
declaration: Declaration
) => declaration is ClassConstructorDeclaration;

    function isClassDeclaration

    isClassDeclaration: (
    declaration: Declaration
    ) => declaration is ClassDeclaration;

      function isClassMethodDeclaration

      isClassMethodDeclaration: (
      declaration: Declaration
      ) => declaration is ClassMethodDeclaration;

        function isClassPropertyDeclaration

        isClassPropertyDeclaration: (
        declaration: Declaration
        ) => declaration is ClassPropertyDeclaration;

          function isEnumDeclaration

          isEnumDeclaration: (declaration: Declaration) => declaration is EnumDeclaration;

            function isEnumMemberDeclaration

            isEnumMemberDeclaration: (
            declaration: Declaration
            ) => declaration is EnumMemberDeclaration;

              function isFunctionDeclaration

              isFunctionDeclaration: (
              declaration: Declaration
              ) => declaration is FunctionDeclaration;

                function isInterfaceCallSignatureDeclaration

                isInterfaceCallSignatureDeclaration: (
                declaration: Declaration
                ) => declaration is InterfaceCallSignatureDeclaration;

                  function isInterfaceConstructSignatureDeclaration

                  isInterfaceConstructSignatureDeclaration: (
                  declaration: Declaration
                  ) => declaration is InterfaceConstructSignatureDeclaration;

                    function isInterfaceDeclaration

                    isInterfaceDeclaration: (
                    declaration: Declaration
                    ) => declaration is InterfaceDeclaration;

                      function isInterfaceIndexSignatureDeclaration

                      isInterfaceIndexSignatureDeclaration: (
                      declaration: Declaration
                      ) => declaration is InterfaceIndexSignatureDeclaration;

                        function isInterfaceMethodDeclaration

                        isInterfaceMethodDeclaration: (
                        declaration: Declaration
                        ) => declaration is InterfaceMethodDeclaration;

                          function isInterfacePropertyDeclaration

                          isInterfacePropertyDeclaration: (
                          declaration: Declaration
                          ) => declaration is InterfacePropertyDeclaration;

                            function isNamespaceDeclaration

                            isNamespaceDeclaration: (
                            declaration: Declaration
                            ) => declaration is NamespaceDeclaration;

                              function isTypeAliasDeclaration

                              isTypeAliasDeclaration: (
                              declaration: Declaration
                              ) => declaration is TypeAliasDeclaration;

                                function isVariableDeclaration

                                isVariableDeclaration: (
                                declaration: Declaration
                                ) => declaration is VariableDeclaration;

                                  Interfaces

                                  interface ClassConstructorDeclaration

                                  interface ClassConstructorDeclaration extends Declaration {}
                                  • ClassConstructorDeclaration represents a constructor declaration belonging to a class (for example, constructor() {...}).

                                  property kind

                                  readonly kind: DeclarationKinds.ClassConstructorDeclaration;

                                    interface ClassDeclaration

                                    interface ClassDeclaration extends Declaration {}
                                    • ClassDeclaration represents a class declaration (for example, class MyClass {...}).

                                    property constructors

                                    readonly constructors: ClassConstructorDeclaration[];
                                    • Class constructors

                                    property isAbstract

                                    readonly isAbstract: boolean;
                                    • If true, the class is abstract

                                    property kind

                                    readonly kind: DeclarationKinds.ClassDeclaration;

                                      property members

                                      readonly members: ClassMemberDeclarations;
                                      • Class members

                                      interface ClassMemberDeclarations

                                      interface ClassMemberDeclarations {}
                                      • ClassMemberDeclarations contains the members of a class.

                                      property methods

                                      readonly methods: ClassMethodDeclaration[];

                                        property properties

                                        readonly properties: ClassPropertyDeclaration[];

                                          interface ClassMethodDeclaration

                                          interface ClassMethodDeclaration extends Declaration {}
                                          • ClassMethodDeclaration represents a method defined in a class (for example, foo(): string {...}).

                                          property isStatic

                                          readonly isStatic: boolean;
                                          • If true, the method is static

                                          property kind

                                          readonly kind: DeclarationKinds.ClassMethodDeclaration;

                                            property type

                                            readonly type: string;
                                            • Method type (for example, () => string)

                                            interface ClassPropertyDeclaration

                                            interface ClassPropertyDeclaration extends Declaration {}
                                            • ClassPropertyDeclaration represents a property defined in a class either directly (for example, foo: string) or through an accessor (for example, get foo(): string {...}).

                                            property isStatic

                                            readonly isStatic: boolean;
                                            • If true, the property is static

                                            property kind

                                            readonly kind: DeclarationKinds.ClassPropertyDeclaration;

                                              property type

                                              readonly type: string;
                                              • Property type (for example, string)

                                              interface Declaration

                                              interface Declaration {}
                                              • Declaration contains the properties common to all declaration kinds.

                                              property docs

                                              readonly docs: string[];
                                              • Documentation comments describing the declaration

                                              property id

                                              readonly id: string;
                                              • Declaration ID

                                              property kind

                                              readonly kind: DeclarationKinds;
                                              • Declaration kind

                                              property name

                                              readonly name: string;
                                              • Export name

                                              property signature

                                              readonly signature: string;
                                              • Declaration's signature

                                              property source

                                              readonly source: DeclarationSource;
                                              • Location in the source code

                                              interface DeclarationSource

                                              interface DeclarationSource {}
                                              • DeclarationSource represents the location of a declaration in a source file.

                                              property filename

                                              readonly filename: string;
                                              • Filename

                                              property line

                                              readonly line: number;
                                              • Starting line number

                                              property unpkgURL

                                              readonly unpkgURL?: string;
                                              • URL on unpkg.com linking to the declaration

                                              property url

                                              readonly url?: string;
                                              • URL in a remote repository linking to the declaration

                                              interface EnumDeclaration

                                              interface EnumDeclaration extends Declaration {}
                                              • EnumDeclaration represents an enum declaration (for example, enum MyEnum {...}).

                                              property isConst

                                              readonly isConst: boolean;
                                              • If true, the enum is a constant enum.

                                              property kind

                                              readonly kind: DeclarationKinds.EnumDeclaration;

                                                property members

                                                readonly members: EnumMemberDeclaration[];
                                                • Enum members

                                                interface EnumMemberDeclaration

                                                interface EnumMemberDeclaration extends Declaration {}
                                                • EnumMemberDeclaration represents a member defined in an enum (for example, UP in enum MyEnum { UP, DOWN }).

                                                property kind

                                                readonly kind: DeclarationKinds.EnumMemberDeclaration;

                                                  property value

                                                  readonly value?: string | number;
                                                  • Member's constant value

                                                  interface FunctionDeclaration

                                                  interface FunctionDeclaration extends Declaration {}
                                                  • FunctionDeclaration represents a normal function declaration (for example, function myFunc() {...}) or a named function expression (for example, const myFunc = () => {...} or const myFunc = function() {...}).

                                                  property kind

                                                  readonly kind: DeclarationKinds.FunctionDeclaration;

                                                    property type

                                                    readonly type: string;
                                                    • Function type (for example, () => string)

                                                    interface InterfaceCallSignatureDeclaration

                                                    interface InterfaceCallSignatureDeclaration extends Declaration {}
                                                    • InterfaceCallSignatureDeclaration represents a call signature defined in an interface (for example, (foo: string): boolean).

                                                    property kind

                                                    readonly kind: DeclarationKinds.InterfaceCallSignatureDeclaration;

                                                      interface InterfaceConstructSignatureDeclaration

                                                      interface InterfaceConstructSignatureDeclaration extends Declaration {}
                                                      • InterfaceConstructSignatureDeclaration represents a construct signature defined in an interface (for example, new (foo: string)).

                                                      property kind

                                                      readonly kind: DeclarationKinds.InterfaceConstructSignatureDeclaration;

                                                        interface InterfaceDeclaration

                                                        interface InterfaceDeclaration extends Declaration {}
                                                        • InterfaceDeclaration represents an interface declaration (for example, interface MyInterface {...}).

                                                        property kind

                                                        readonly kind: DeclarationKinds.InterfaceDeclaration;

                                                          property members

                                                          readonly members: InterfaceMemberDeclarations;
                                                          • Interface members

                                                          interface InterfaceIndexSignatureDeclaration

                                                          interface InterfaceIndexSignatureDeclaration extends Declaration {}
                                                          • InterfaceIndexSignatureDeclaration represents an index signature defined in an interface (for example, [index: number]: string).

                                                          property kind

                                                          readonly kind: DeclarationKinds.InterfaceIndexSignatureDeclaration;

                                                            interface InterfaceMemberDeclarations

                                                            interface InterfaceMemberDeclarations {}
                                                            • InterfaceMemberDeclarations contains the members of an interface.

                                                            property callSignatures

                                                            readonly callSignatures: InterfaceCallSignatureDeclaration[];

                                                              property constructSignatures

                                                              readonly constructSignatures: InterfaceConstructSignatureDeclaration[];

                                                                property indexSignatures

                                                                readonly indexSignatures: InterfaceIndexSignatureDeclaration[];

                                                                  property methods

                                                                  readonly methods: InterfaceMethodDeclaration[];

                                                                    property properties

                                                                    readonly properties: InterfacePropertyDeclaration[];

                                                                      interface InterfaceMethodDeclaration

                                                                      interface InterfaceMethodDeclaration extends Declaration {}
                                                                      • InterfaceMethodDeclaration represents a method defined in an interface (for example, foo(): string in interface MyInterface { foo(): string }).

                                                                      property kind

                                                                      readonly kind: DeclarationKinds.InterfaceMethodDeclaration;

                                                                        property type

                                                                        readonly type: string;
                                                                        • Method signature type (for example, () => string)

                                                                        interface InterfacePropertyDeclaration

                                                                        interface InterfacePropertyDeclaration extends Declaration {}
                                                                        • InterfacePropertyDeclaration represents a property defined in an interface (for example, foo: string in interface MyInterface { foo: string }).

                                                                        property isOptional

                                                                        readonly isOptional: boolean;
                                                                        • If true, the property is optional

                                                                        property isReadonly

                                                                        readonly isReadonly: boolean;
                                                                        • If true, the property is readonly

                                                                        property kind

                                                                        readonly kind: DeclarationKinds.InterfacePropertyDeclaration;

                                                                          property type

                                                                          readonly type: string;
                                                                          • Property type (for example, string)

                                                                          interface ModuleDeclarations

                                                                          interface ModuleDeclarations {}
                                                                          • ModuleDeclarations contains the different kinds of declarations exported by a module (for example, a package, a module (file) or a namespace).

                                                                          property classes

                                                                          readonly classes: ClassDeclaration[];

                                                                            property enums

                                                                            readonly enums: EnumDeclaration[];

                                                                              property functions

                                                                              readonly functions: FunctionDeclaration[];

                                                                                property interfaces

                                                                                readonly interfaces: InterfaceDeclaration[];

                                                                                  property namespaces

                                                                                  readonly namespaces: NamespaceDeclaration[];

                                                                                    property typeAliases

                                                                                    readonly typeAliases: TypeAliasDeclaration[];

                                                                                      property variables

                                                                                      readonly variables: VariableDeclaration[];

                                                                                        interface NamespaceDeclaration

                                                                                        interface NamespaceDeclaration extends Declaration {}
                                                                                        • NamespaceDeclaration represents a namespace declaration (for example, namespace MyNamespace {...}).

                                                                                        property declarations

                                                                                        readonly declarations: ModuleDeclarations;
                                                                                        • Exported namespace declarations

                                                                                        property kind

                                                                                        readonly kind: DeclarationKinds.NamespaceDeclaration;

                                                                                          interface PackageAPI

                                                                                          interface PackageAPI {}

                                                                                          property declarations

                                                                                          readonly declarations: ModuleDeclarations;
                                                                                          • Exported package declarations

                                                                                          property files

                                                                                          readonly files: PackageFile[];
                                                                                          • Files containing the exported package declarations

                                                                                          property overview

                                                                                          readonly overview?: string;
                                                                                          • Main documentation comment describing the package

                                                                                          interface PackageFile

                                                                                          interface PackageFile {}
                                                                                          • PackageFile represents a file belonging to a package.

                                                                                          property filename

                                                                                          readonly filename: string;
                                                                                          • Filename

                                                                                          property isIndexFile

                                                                                          readonly isIndexFile?: boolean;
                                                                                          • If true, this file is the entry point to the package

                                                                                          property unpkgURL

                                                                                          readonly unpkgURL?: string;
                                                                                          • URL on unpkg.com linking to the file

                                                                                          property url

                                                                                          readonly url?: string;
                                                                                          • URL in a remote repository linking to the file

                                                                                          interface RegistryPackageInfo

                                                                                          interface RegistryPackageInfo {}

                                                                                          property api

                                                                                          readonly api?: PackageAPI;
                                                                                          • Public package API

                                                                                          property createdAt

                                                                                          readonly createdAt: string;
                                                                                          • Time at which this data was created

                                                                                          property elapsed

                                                                                          readonly elapsed: number;
                                                                                          • Package analysis duration in milliseconds

                                                                                          property id

                                                                                          readonly id: string;
                                                                                          • Package version ID (for example, foo@1.0.0 or @bar/baz@1.0.0)

                                                                                          property manifest

                                                                                          readonly manifest: PackageManifest;
                                                                                          • Package manifest from the registry

                                                                                          interface TypeAliasDeclaration

                                                                                          interface TypeAliasDeclaration extends Declaration {}
                                                                                          • TypeAliasDeclaration represents a type alias declaration (for example, type myType = ...).

                                                                                          property kind

                                                                                          readonly kind: DeclarationKinds.TypeAliasDeclaration;

                                                                                            interface VariableDeclaration

                                                                                            interface VariableDeclaration extends Declaration {}
                                                                                            • VariableDeclaration represents a variable declaration (for example, const myVar = ...).

                                                                                            property kind

                                                                                            readonly kind: DeclarationKinds.VariableDeclaration;

                                                                                              property type

                                                                                              readonly type: string;
                                                                                              • Variable type (for example, string)

                                                                                              property variableKind

                                                                                              readonly variableKind: string;
                                                                                              • Either var, let, or const

                                                                                              Enums

                                                                                              enum DeclarationKinds

                                                                                              enum DeclarationKinds {
                                                                                              VariableDeclaration = 'VariableDeclaration',
                                                                                              FunctionDeclaration = 'FunctionDeclaration',
                                                                                              ClassDeclaration = 'ClassDeclaration',
                                                                                              ClassConstructorDeclaration = 'ClassConstructorDeclaration',
                                                                                              ClassPropertyDeclaration = 'ClassPropertyDeclaration',
                                                                                              ClassMethodDeclaration = 'ClassMethodDeclaration',
                                                                                              InterfaceDeclaration = 'InterfaceDeclaration',
                                                                                              InterfacePropertyDeclaration = 'InterfacePropertyDeclaration',
                                                                                              InterfaceMethodDeclaration = 'InterfaceMethodDeclaration',
                                                                                              InterfaceConstructSignatureDeclaration = 'InterfaceConstructSignatureDeclaration',
                                                                                              InterfaceCallSignatureDeclaration = 'InterfaceCallSignatureDeclaration',
                                                                                              InterfaceIndexSignatureDeclaration = 'InterfaceIndexSignatureDeclaration',
                                                                                              EnumDeclaration = 'EnumDeclaration',
                                                                                              EnumMemberDeclaration = 'EnumMemberDeclaration',
                                                                                              TypeAliasDeclaration = 'TypeAliasDeclaration',
                                                                                              NamespaceDeclaration = 'NamespaceDeclaration',
                                                                                              }
                                                                                              • DeclarationKinds lists the possible kinds of declarations

                                                                                              member ClassConstructorDeclaration

                                                                                              ClassConstructorDeclaration = 'ClassConstructorDeclaration'

                                                                                                member ClassDeclaration

                                                                                                ClassDeclaration = 'ClassDeclaration'

                                                                                                  member ClassMethodDeclaration

                                                                                                  ClassMethodDeclaration = 'ClassMethodDeclaration'

                                                                                                    member ClassPropertyDeclaration

                                                                                                    ClassPropertyDeclaration = 'ClassPropertyDeclaration'

                                                                                                      member EnumDeclaration

                                                                                                      EnumDeclaration = 'EnumDeclaration'

                                                                                                        member EnumMemberDeclaration

                                                                                                        EnumMemberDeclaration = 'EnumMemberDeclaration'

                                                                                                          member FunctionDeclaration

                                                                                                          FunctionDeclaration = 'FunctionDeclaration'

                                                                                                            member InterfaceCallSignatureDeclaration

                                                                                                            InterfaceCallSignatureDeclaration = 'InterfaceCallSignatureDeclaration'

                                                                                                              member InterfaceConstructSignatureDeclaration

                                                                                                              InterfaceConstructSignatureDeclaration = 'InterfaceConstructSignatureDeclaration'

                                                                                                                member InterfaceDeclaration

                                                                                                                InterfaceDeclaration = 'InterfaceDeclaration'

                                                                                                                  member InterfaceIndexSignatureDeclaration

                                                                                                                  InterfaceIndexSignatureDeclaration = 'InterfaceIndexSignatureDeclaration'

                                                                                                                    member InterfaceMethodDeclaration

                                                                                                                    InterfaceMethodDeclaration = 'InterfaceMethodDeclaration'

                                                                                                                      member InterfacePropertyDeclaration

                                                                                                                      InterfacePropertyDeclaration = 'InterfacePropertyDeclaration'

                                                                                                                        member NamespaceDeclaration

                                                                                                                        NamespaceDeclaration = 'NamespaceDeclaration'

                                                                                                                          member TypeAliasDeclaration

                                                                                                                          TypeAliasDeclaration = 'TypeAliasDeclaration'

                                                                                                                            member VariableDeclaration

                                                                                                                            VariableDeclaration = 'VariableDeclaration'

                                                                                                                              Package Files (7)

                                                                                                                              Dependencies (10)

                                                                                                                              Dev Dependencies (29)

                                                                                                                              Peer Dependencies (0)

                                                                                                                              No peer dependencies.

                                                                                                                              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/@jsdocs-io/extractor.

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