@jsdocs-io/extractor
- Version 2.0.0
- Published
- 116 kB
- 9 dependencies
- AGPL-3.0-or-later license
Install
npm i @jsdocs-io/extractoryarn add @jsdocs-io/extractorpnpm add @jsdocs-io/extractorOverview
The API extractor for npm packages powering jsdocs.io
Index
Functions
Classes
Interfaces
Type Aliases
Functions
function getPackageApi
getPackageApi: ({ pkg, subpath, maxDepth, bun,}: GetPackageApiOptions) => Promise<PackageApi>;getPackageApiextracts the API from a package.If the extraction succeeds,
getPackageApireturns a PackageApi object. If the extraction fails,getPackageApithrows 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 getPackageApi({pkg: "foo", // Extract API from npm package `foo` [Required]subpath: ".", // Select subpath `.` (root subpath) [Optional]maxDepth: 5, // Maximum depth for analyzing nested namespaces [Optional]bun: new Bun() // Bun package manager instance [Optional]});console.log(JSON.stringify(packageApi, null, 2));
function getPackageJson
getPackageJson: (dir: string) => Promise<NormalizedPackageJson>;getPackageJsonreturns thepackage.jsonfile found in the given directory.
function getPackageTypes
getPackageTypes: ({ pkgJson, subpath,}: GetPackageTypesOptions) => string | undefined;getPackageTypesreturns the TypeScript type definition file (e.g.,index.d.ts) that acts as the entry point for the package at the given subpath.
Classes
class Bun
class Bun {}Bunis a wrapper for the Bun package manager.
constructor
constructor(bunCmd?: string);method add
add: (pkg: string, cwd: string) => Promise<string[]>;addinstalls the given package in the given directory and returns a list of all installed packages (e.g.,["foo@1.0.0"]).See Also
Interfaces
interface BaseDeclaration
interface BaseDeclaration {}BaseDeclarationcontains the properties common to extracted declarations.
property docs
docs: string[];List of associated JSDoc comments.
property file
file: string;Name of the file where the declaration is defined.
property id
id: string;Unique ID.
property line
line: number;Line number where the declaration is defined.
property name
name: string;Export name (may differ from the original name).
property signature
signature: string;Declaration signature.
interface ExtractedClass
interface ExtractedClass extends BaseDeclaration {}property constructors
constructors: ExtractedClassConstructor[];property kind
kind: 'class';property methods
methods: ExtractedClassMethod[];property properties
properties: ExtractedClassProperty[];interface ExtractedClassConstructor
interface ExtractedClassConstructor extends BaseDeclaration {}property kind
kind: 'class-constructor';interface ExtractedClassMethod
interface ExtractedClassMethod extends BaseDeclaration {}property kind
kind: 'class-method';interface ExtractedClassProperty
interface ExtractedClassProperty extends BaseDeclaration {}property kind
kind: 'class-property';interface ExtractedEnum
interface ExtractedEnum extends BaseDeclaration {}interface ExtractedEnumMember
interface ExtractedEnumMember extends BaseDeclaration {}property kind
kind: 'enum-member';interface ExtractedFunction
interface ExtractedFunction extends BaseDeclaration {}property kind
kind: 'function';interface ExtractedInterface
interface ExtractedInterface extends BaseDeclaration {}property callSignatures
callSignatures: ExtractedInterfaceCallSignature[];property constructSignatures
constructSignatures: ExtractedInterfaceConstructSignature[];property getAccessors
getAccessors: ExtractedInterfaceGetAccessor[];property indexSignatures
indexSignatures: ExtractedInterfaceIndexSignature[];property kind
kind: 'interface';property methods
methods: ExtractedInterfaceMethod[];property properties
properties: ExtractedInterfaceProperty[];property setAccessors
setAccessors: ExtractedInterfaceSetAccessor[];interface ExtractedInterfaceCallSignature
interface ExtractedInterfaceCallSignature extends BaseDeclaration {}property kind
kind: 'interface-call-signature';interface ExtractedInterfaceConstructSignature
interface ExtractedInterfaceConstructSignature extends BaseDeclaration {}property kind
kind: 'interface-construct-signature';interface ExtractedInterfaceGetAccessor
interface ExtractedInterfaceGetAccessor extends BaseDeclaration {}property kind
kind: 'interface-get-accessor';interface ExtractedInterfaceIndexSignature
interface ExtractedInterfaceIndexSignature extends BaseDeclaration {}property kind
kind: 'interface-index-signature';interface ExtractedInterfaceMethod
interface ExtractedInterfaceMethod extends BaseDeclaration {}property kind
kind: 'interface-method';interface ExtractedInterfaceProperty
interface ExtractedInterfaceProperty extends BaseDeclaration {}property kind
kind: 'interface-property';interface ExtractedInterfaceSetAccessor
interface ExtractedInterfaceSetAccessor extends BaseDeclaration {}property kind
kind: 'interface-set-accessor';interface ExtractedNamespace
interface ExtractedNamespace extends BaseDeclaration {}property declarations
declarations: ExtractedDeclaration[];property kind
kind: 'namespace';interface ExtractedTypeAlias
interface ExtractedTypeAlias extends BaseDeclaration {}property kind
kind: 'type';interface ExtractedVariable
interface ExtractedVariable extends BaseDeclaration {}property kind
kind: 'variable';interface GetPackageApiOptions
interface GetPackageApiOptions {}GetPackageApiOptionscontains the options for calling getPackageApi.
property bun
bun?: Bun;Bun instance used to install the package.
property maxDepth
maxDepth?: number;Packages can have deeply nested modules and namespaces.
Use
maxDepthto limit the depth of the extraction. Declarations nested at levels deeper than this value will be ignored.
property pkg
pkg: string;Package to extract the API from.
This can be either a package name (e.g.,
foo,@foo/bar) or any other query that can be passed tobun add(e.g.,foo@1.0.0).See Also
property subpath
subpath?: string;Specific subpath to consider in a package.
If a package has multiple entrypoints listed in the
exportsmap property of itspackage.json, usesubpathto select a specific one by its name (e.g.,someFeature).See Also
interface GetPackageTypesOptions
interface GetPackageTypesOptions {}GetPackageTypesOptionscontains the options for calling getPackageTypes.
interface PackageApi
interface PackageApi {}PackageApicontains the data extracted from a package by calling getPackageApi.
property analyzedAt
analyzedAt: string;Timestamp of when the package was analyzed.
property analyzedIn
analyzedIn: number;Package analysis duration in milliseconds.
property declarations
declarations: ExtractedDeclaration[];Declarations exported (or re-exported) by the package.
property dependencies
dependencies: string[];All packages resolved and installed when installing the package (included).
Example 1
```ts // Installing
foobrings in alsobarandbazas dependencies. ["foo@1.0.0", "bar@2.0.0", "baz@3.0.0"] ```
property name
name: string;Package name (e.g.,
foo,@foo/bar).
property overview
overview?: string;Package description extracted from the
typesfile if a JSDoc comment with the@packageDocumentationtag is found.
property subpath
subpath: string;Package subpath selected when extracting the API (e.g.,
.,someFeature).See Also
property types
types?: string;Type declarations file, resolved from the selected
subpath, that acts as the entrypoint for the package (e.g.,index.d.ts).
property version
version: string;Package version number (e.g.,
1.0.0).
Type Aliases
type AllExtractedDeclaration
type AllExtractedDeclaration = | ExtractedVariable | ExtractedFunction | ExtractedClass | ExtractedClassConstructor | ExtractedClassProperty | ExtractedClassMethod | ExtractedInterface | ExtractedInterfaceProperty | ExtractedInterfaceMethod | ExtractedInterfaceConstructSignature | ExtractedInterfaceCallSignature | ExtractedInterfaceIndexSignature | ExtractedInterfaceGetAccessor | ExtractedInterfaceSetAccessor | ExtractedEnum | ExtractedEnumMember | ExtractedTypeAlias | ExtractedNamespace;AllExtractedDeclarationis 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'];AllExtractedDeclarationKindis the union of all literal discriminators used to detect the kind of declaration.
type ExtractedDeclaration
type ExtractedDeclaration = | ExtractedVariable | ExtractedFunction | ExtractedClass | ExtractedInterface | ExtractedEnum | ExtractedTypeAlias | ExtractedNamespace;ExtractedDeclarationis the union of all possible top-level declarations that can be extracted from a package, module, or namespace.
type ExtractedDeclarationKind
type ExtractedDeclarationKind = ExtractedDeclaration['kind'];ExtractedDeclarationKindis the union of all literal discriminators used to detect the kind of top-level declaration.
Package Files (6)
Dependencies (9)
Dev Dependencies (11)
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 4912 ms. - Missing or incorrect documentation? Open an issue for this package.
