@jsdocs-io/extractor
- Version 1.0.0
- Published
- 97.4 kB
- 12 dependencies
- AGPL-3.0-or-later license
Install
npm i @jsdocs-io/extractor
yarn add @jsdocs-io/extractor
pnpm add @jsdocs-io/extractor
Overview
The API extractor for npm packages powering jsdocs.io
Index
Variables
Functions
Type Aliases
- AllExtractedDeclaration
- AllExtractedDeclarationKind
- ExtractedClass
- ExtractedClassConstructor
- ExtractedClassMethod
- ExtractedClassProperty
- ExtractedDeclaration
- ExtractedDeclarationKind
- ExtractedEnum
- ExtractedEnumMember
- ExtractedFunction
- ExtractedInterface
- ExtractedInterfaceCallSignature
- ExtractedInterfaceConstructSignature
- ExtractedInterfaceGetAccessor
- ExtractedInterfaceIndexSignature
- ExtractedInterfaceMethod
- ExtractedInterfaceProperty
- ExtractedInterfaceSetAccessor
- ExtractedNamespace
- ExtractedTypeAlias
- ExtractedVariable
- ExtractPackageApiOptions
- PackageApi
Variables
variable InstallPackageError_base
const InstallPackageError_base: new <A extends Record<string, any> = {}>( args: void | { readonly [P in keyof A as P extends '_tag' ? never : P]: A[P] }) => any;
variable PackageDeclarationsError_base
const PackageDeclarationsError_base: new <A extends Record<string, any> = {}>( args: void | { readonly [P in keyof A as P extends '_tag' ? never : P]: A[P] }) => any;
variable PackageJsonError_base
const PackageJsonError_base: new <A extends Record<string, any> = {}>( args: void | { readonly [P in keyof A as P extends '_tag' ? never : P]: A[P] }) => any;
variable PackageManager_base
const PackageManager_base: Context.TagClass< PackageManager, 'PackageManager', { readonly installPackage: ({ pkg, cwd, }: InstallPackageOptions) => Effect.Effect<string[], InstallPackageError>; }>;
variable PackageNameError_base
const PackageNameError_base: new <A extends Record<string, any> = {}>( args: void | { readonly [P in keyof A as P extends '_tag' ? never : P]: A[P] }) => any;
variable PackageTypesError_base
const PackageTypesError_base: new <A extends Record<string, any> = {}>( args: void | { readonly [P in keyof A as P extends '_tag' ? never : P]: A[P] }) => any;
variable ProjectError_base
const ProjectError_base: new <A extends Record<string, any> = {}>( args: void | { readonly [P in keyof A as P extends '_tag' ? never : P]: A[P] }) => any;
variable WorkDirError_base
const WorkDirError_base: new <A extends Record<string, any> = {}>( args: void | { readonly [P in keyof A as P extends '_tag' ? never : P]: A[P] }) => any;
Functions
function extractPackageApi
extractPackageApi: ({ pkg, subpath, maxDepth, bunPath,}: ExtractPackageApiOptions) => Promise<PackageApi>;
extractPackageApi
extracts the API from a package.If the extraction succeeds,
extractPackageApi
returns a PackageApi object. If the extraction fails,extractPackageApi
throws an error.Warning: The extraction process is slow and blocks the main thread, using workers is recommended.
Parameter options
Returns
A PackageApi object
Example 1
const packageApi = await extractPackageApi({pkg: "foo", // Extract API from npm package `foo` [Required]subpath: ".", // Select subpath `.` (root subpath) [Optional]maxDepth: 5, // Maximum depth for analyzing nested namespaces [Optional]bunPath: "bun" // Absolute path to the `bun` executable [Optional]});console.log(JSON.stringify(packageApi, null, 2));
Type Aliases
type AllExtractedDeclaration
type AllExtractedDeclaration = | ExtractedVariable | ExtractedFunction | ExtractedClass | ExtractedClassConstructor | ExtractedClassProperty | ExtractedClassMethod | ExtractedInterface | ExtractedInterfaceProperty | ExtractedInterfaceMethod | ExtractedInterfaceConstructSignature | ExtractedInterfaceCallSignature | ExtractedInterfaceIndexSignature | ExtractedInterfaceGetAccessor | ExtractedInterfaceSetAccessor | ExtractedEnum | ExtractedEnumMember | ExtractedTypeAlias | ExtractedNamespace;
AllExtractedDeclaration
is the union of all possible declarations that can be extracted, with some being found only in other declarations (e.g., class method declarations are found only in a class declaration).
type AllExtractedDeclarationKind
type AllExtractedDeclarationKind = AllExtractedDeclaration['kind'];
AllExtractedDeclarationKind
is the union of all discriminators used to detect the kind of declaration.
type ExtractedClass
type ExtractedClass = { kind: 'class'; id: string; name: string; docs: string[]; file: string; line: number; signature: string; constructors: ExtractedClassConstructor[]; properties: ExtractedClassProperty[]; methods: ExtractedClassMethod[];};
type ExtractedClassConstructor
type ExtractedClassConstructor = { kind: 'class-constructor'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedClassMethod
type ExtractedClassMethod = { kind: 'class-method'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedClassProperty
type ExtractedClassProperty = { kind: 'class-property'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedDeclaration
type ExtractedDeclaration = | ExtractedVariable | ExtractedFunction | ExtractedClass | ExtractedInterface | ExtractedEnum | ExtractedTypeAlias | ExtractedNamespace;
ExtractedDeclaration
is the union of all possible top-level declarations that can be extracted from a package, module or namespace.
type ExtractedDeclarationKind
type ExtractedDeclarationKind = ExtractedDeclaration['kind'];
ExtractedDeclarationKind
is the union of all discriminators used to detect the kind of top-level declaration.
type ExtractedEnum
type ExtractedEnum = { kind: 'enum'; id: string; name: string; docs: string[]; file: string; line: number; signature: string; members: ExtractedEnumMember[];};
type ExtractedEnumMember
type ExtractedEnumMember = { kind: 'enum-member'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedFunction
type ExtractedFunction = { kind: 'function'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedInterface
type ExtractedInterface = { kind: 'interface'; id: string; name: string; docs: string[]; file: string; line: number; signature: string; properties: ExtractedInterfaceProperty[]; methods: ExtractedInterfaceMethod[]; constructSignatures: ExtractedInterfaceConstructSignature[]; callSignatures: ExtractedInterfaceCallSignature[]; indexSignatures: ExtractedInterfaceIndexSignature[]; getAccessors: ExtractedInterfaceGetAccessor[]; setAccessors: ExtractedInterfaceSetAccessor[];};
type ExtractedInterfaceCallSignature
type ExtractedInterfaceCallSignature = { kind: 'interface-call-signature'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedInterfaceConstructSignature
type ExtractedInterfaceConstructSignature = { kind: 'interface-construct-signature'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedInterfaceGetAccessor
type ExtractedInterfaceGetAccessor = { kind: 'interface-get-accessor'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedInterfaceIndexSignature
type ExtractedInterfaceIndexSignature = { kind: 'interface-index-signature'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedInterfaceMethod
type ExtractedInterfaceMethod = { kind: 'interface-method'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedInterfaceProperty
type ExtractedInterfaceProperty = { kind: 'interface-property'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedInterfaceSetAccessor
type ExtractedInterfaceSetAccessor = { kind: 'interface-set-accessor'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedNamespace
type ExtractedNamespace = { kind: 'namespace'; id: string; name: string; docs: string[]; file: string; line: number; signature: string; declarations: ExtractedDeclaration[];};
type ExtractedTypeAlias
type ExtractedTypeAlias = { kind: 'type'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractedVariable
type ExtractedVariable = { kind: 'variable'; id: string; name: string; docs: string[]; file: string; line: number; signature: string;};
type ExtractPackageApiOptions
type ExtractPackageApiOptions = { /** Package to extract the API from.
This can be either a package name (e.g., `foo`) or any other query that can be passed to `bun add` (e.g., `foo@1.0.0`).
@see {@link https://bun.sh/docs/cli/add | Bun docs} */ pkg: string; /** Specific subpath to consider in a package.
If a package has multiple entrypoints listed in the `exports` property of its `package.json`, use `subpath` to select a specific one by its name (e.g., `someFeature`).
@defaultValue `.` (package root)
@see {@link https://nodejs.org/api/packages.html#subpath-exports | Node.js docs} @see {@link https://github.com/lukeed/resolve.exports | resolve.exports docs} */ subpath?: string; /** Packages can have deeply nested modules and namespaces.
Use `maxDepth` to limit the depth of the extraction. Declarations nested at levels deeper than this value will be ignored.
@defaultValue 5 */ maxDepth?: number; /** Absolute path to the `bun` executable. Used to locate bun if it's not in `PATH`.
@defaultValue `bun` */ bunPath?: string;};
ExtractPackageApiOptions
contains all the options for calling extractPackageApi.
type PackageApi
type PackageApi = { /** Package name (e.g., `foo`). */ name: string; /** Package version number (e.g., `1.0.0`). */ version: string; /** Package subpath selected when extracting the API (e.g., `.`, `someFeature`).
@see {@link ExtractPackageApiOptions.subpath} @see {@link https://nodejs.org/api/packages.html#subpath-exports | Node.js docs} */ subpath: string; /** Type declarations file, resolved from the selected `subpath`, that acts as the entrypoint for the package (e.g., `index.d.ts`). */ types: string; /** Package description extracted from the `types` file if a JSDoc comment with the `@packageDocumentation` tag is found. */ overview: string | undefined; /** Declarations exported (or re-exported) by the package. */ declarations: ExtractedDeclaration[]; /** All packages resolved and installed when installing the package (included).
@example ```ts ["foo@1.0.0", "bar@2.0.0", "baz@3.0.0"] ``` */ packages: string[]; /** Timestamp of when the package was analyzed. */ analyzedAt: string; /** Package analysis duration in milliseconds. */ analyzedIn: number;};
PackageApi
contains all the information extracted from a package.
Package Files (1)
Dependencies (12)
Dev Dependencies (10)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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[](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>
- Updated .
Package analyzed in 4139 ms. - Missing or incorrect documentation? Open an issue for this package.