Class: Doc
Hierarchy
-
↳
Doc
Constructors
constructor
• new Doc(url
, docs
): Doc
Parameters
Name | Type |
---|---|
url | string |
docs | Documentation |
Returns
Overrides
Defined in
lib/Doc.ts:46
Properties
baseURL
• Readonly
baseURL: string
= 'https://discord.js.org'
The documentation base URL.
Defined in
lib/Doc.ts:25
branch
• Readonly
branch: string
The branch dissected from the url.
Defined in
lib/Doc.ts:37
children
• children: Map
<string
, DocParam
| DocEvent
| DocProp
| DocMethod
>
The children that belong to this element
Inherited from
Defined in
lib/elements/Base.ts:16
docType
• docType: null
| DocTypes
The type of this element
Inherited from
Defined in
lib/elements/Base.ts:19
name
• name: null
| string
The name of this element
Inherited from
Defined in
lib/elements/Base.ts:22
project
• Readonly
project: string
The project dissected from the url.
Defined in
lib/Doc.ts:29
repo
• Readonly
repo: string
The repository dissected from the url.
Defined in
lib/Doc.ts:33
url
• Readonly
url: string
The raw URL of the JSON that was fetched
Defined in
lib/Doc.ts:41
globalOptions
▪ Static
globalOptions: DocParserGlobalOptions
Global options to configure the Doc output
Defined in
lib/Doc.ts:192
Accessors
baseDocsURL
• get
baseDocsURL(): string
Returns
string
Defined in
lib/Doc.ts:64
classes
• get
classes(): null
| DocClass
[]
The stored Classes for this current documentation source
Returns
null
| DocClass
[]
Inherited from
DocBase.classes
Defined in
lib/elements/Base.ts:82
events
• get
events(): null
| DocEvent
[]
The stored Events for this current documentation source
Returns
null
| DocEvent
[]
Inherited from
DocBase.events
Defined in
lib/elements/Base.ts:129
functions
• get
functions(): null
| DocFunction
[]
The stored Functions for this current documentation source
Returns
null
| DocFunction
[]
Inherited from
DocBase.functions
Defined in
lib/elements/Base.ts:89
interfaces
• get
interfaces(): null
| DocInterface
[]
The stored Interfaces for this current documentation source
Returns
null
| DocInterface
[]
Inherited from
DocBase.interfaces
Defined in
lib/elements/Base.ts:105
methods
• get
methods(): null
| DocMethod
[]
The stored Methods for this current documentation source
Returns
null
| DocMethod
[]
Inherited from
DocBase.methods
Defined in
lib/elements/Base.ts:121
params
• get
params(): null
| DocParam
[]
The stored Params for this current documentation source
Returns
null
| DocParam
[]
Inherited from
DocBase.params
Defined in
lib/elements/Base.ts:137
props
• get
props(): null
| DocProp
[]
The stored Props for this current documentation source
Returns
null
| DocProp
[]
Inherited from
DocBase.props
Defined in
lib/elements/Base.ts:113
repoURL
• get
repoURL(): string
Returns
string
Defined in
lib/Doc.ts:60
typedefs
• get
typedefs(): null
| DocTypedef
[]
The stored Typedefs for this current documentation source
Returns
null
| DocTypedef
[]
Inherited from
DocBase.typedefs
Defined in
lib/elements/Base.ts:97
Methods
get
▸ get(...terms
): null
| DocElement
Gets the documentation for one element.
Parameters
Name | Type | Description |
---|---|---|
...terms | (string | (null | DocElement )[])[] | The terms that lead to the element to get. Use multiple terms to get a nested element. |
Returns
null
| DocElement
Either the element or null if it doesn't exist.
Example
doc.get('message');
doc.get('message', 'guild');
doc.get('message', 'guild', 'members');
Defined in
lib/Doc.ts:79
search
▸ search(query
, searchOptions?
): null
| DocElement
[]
Searches the documentation for elements matching the provided search query.
This uses the Jaro Winkler Distance algorithm to fuzzily match your query against any potential matches. The minimum threshold for a match is 80%
Parameters
Name | Type | Description |
---|---|---|
query | string | The query to use in the fuzzy search. |
searchOptions | SearchOptions | Additional options to pass to the search function. |
Returns
null
| DocElement
[]
The top 10 hits from the search.
Example
doc.search('message.guild');
doc.search('message.client');
doc.search('message.guild.members');
Defined in
lib/Doc.ts:131
fetch
▸ fetch(sourceName
, fetchOptions?
): Promise
<Doc
>
Fetches the documentation JSON file and builds up a Doc object.
Parameters
Name | Type | Description |
---|---|---|
sourceName | SourcesStringUnion | The name of the source to fetch. |
fetchOptions | FetchOptions | Additional options to pass to the fetch function. |
Returns
Promise
<Doc
>
An instance of Doc
Example
const { Doc } = require('discordjs-docs-parser');
const doc = await Doc.fetch('stable');
Example
import { Doc } from 'discordjs-docs-parser';
const doc = await Doc.fetch('collection', { force: true });
Defined in
lib/Doc.ts:226
setGlobalOptions
▸ setGlobalOptions(options
): void
Sets the Doc.globalOptions. You can provide a partial of the options to update.
Parameters
Name | Type | Description |
---|---|---|
options | Partial <DocParserGlobalOptions > | The DocParserGlobalOptions to set |
Returns
void
Defined in
lib/Doc.ts:201