@dovenv/examples
- API documentation โ
Classes โ
Examples โ
Constructors โ
new Examples() โ
new Examples(data: {
opts: Config;
utils: CommandSuper;
}): Examples
Parameters โ
Parameter | Type |
---|---|
data | object |
data.opts ? | Config |
data.utils | CommandSuper |
Returns โ
Methods โ
fromConfig() โ
fromConfig(data: {
config: ExampleProps<ExampleProps>;
desc: string;
input: string | ExampleProps<ExampleProps>;
output: string;
title: string | false;
}): Promise<string>
Parameters โ
Parameter | Type | Description |
---|---|---|
data | object | - |
data.config ? | ExampleProps <ExampleProps > | Override your config input. |
data.desc ? | string | Description. Default 'Examples' |
data.input | string | ExampleProps <ExampleProps > | Input of your config (path or config object). Path formats: JSON, YAML, TOML JS etc. |
data.output ? | string | Write a output if you want |
data.title ? | string | false | H1 for markdown. Default 'Examples' |
Returns โ
Promise
<string
>
fromCustom() โ
fromCustom(data: ExampleCustomProps): Promise<unknown>
Processes custom example data using provided handlers.
This method allows dynamic processing of example data based on the type by binding specific handler functions for each type. The function received in the data parameter is invoked with an object containing these handlers.
Parameters โ
Parameter | Type | Description |
---|---|---|
data | ExampleCustomProps | Object containing the function to execute with the handlers. |
Returns โ
Promise
<unknown
>
A promise that resolves to the result of the executed function.
fromJsdoc() โ
fromJsdoc(data: {
desc: string;
input: string[];
opts: Options;
output: string;
title: string | false;
}): Promise<string>
Process jsdoc examples.
Parameters โ
Parameter | Type | Description |
---|---|---|
data | object | Example data. |
data.desc ? | string | Description. Default 'Examples' |
data.input | string [] | Input pattern. |
data.opts ? | Options | Options for input patterns |
data.output ? | string | Write a output if you want |
data.title ? | string | false | H1 for markdown. Default 'Examples' |
Returns โ
Promise
<string
>
Resolved example content.
See โ
https://github.com/jsdoc2md/jsdoc-api/blob/master/docs/api.md
fromMultiple() โ
fromMultiple(data: {
config: Omit<{
config: ExampleProps<ExampleProps>;
desc: string;
input: string | ExampleProps<ExampleProps>;
output: string;
title: string | false;
}, "output">;
desc: string;
jsdoc: Omit<{
desc: string;
input: string[];
opts: Options;
output: string;
title: string | false;
}, "output">;
output: string;
path: Omit<{
desc: string;
input: string[];
opts: Options;
output: string;
title: string | false;
}, "output">;
title: string | false;
}): Promise<string>
Process multiple examples.
Parameters โ
Parameter | Type | Description |
---|---|---|
data | object | Example data. |
data.config ? | Omit <{ config : ExampleProps <ExampleProps >; desc : string ; input : string | ExampleProps <ExampleProps >; output : string ; title : string | false ; }, "output" > | - |
data.desc ? | string | Description. Default 'Examples' |
data.jsdoc ? | Omit <{ desc : string ; input : string []; opts : Options ; output : string ; title : string | false ; }, "output" > | - |
data.output ? | string | Write a output if you want |
data.path ? | Omit <{ desc : string ; input : string []; opts : Options ; output : string ; title : string | false ; }, "output" > | - |
data.title ? | string | false | H1 for markdown. Default 'Examples' |
Returns โ
Promise
<string
>
Resolved example content.
fromPath() โ
fromPath(data: {
desc: string;
input: string[];
opts: Options;
output: string;
title: string | false;
}): Promise<string>
Parameters โ
Parameter | Type | Description |
---|---|---|
data | object | - |
data.desc ? | string | Description. Default 'Examples' |
data.input | string [] | Input pattern. |
data.opts ? | Options | Options for input patterns |
data.output ? | string | Write a output if you want |
data.title ? | string | false | H1 for markdown. Default 'Examples' |
Returns โ
Promise
<string
>
get() โ
get(data: ConfigValue): Promise<any>
Get a custom Example content template.
Perfect method to be used outside an Dovenv
environment.
Parameters โ
Parameter | Type | Description |
---|---|---|
data | ConfigValue | Configuration object. |
Returns โ
Promise
<any
>
A promise that resolves to the processed content as a string.
run() โ
run(pattern?: string[]): Promise<undefined | {}>
Process examples from the configuration object.
Parameters โ
Parameter | Type | Description |
---|---|---|
pattern ? | string [] | An array of examples names to process. If not provided, all examples will be processed. |
Returns โ
Promise
<undefined
| {}>
A promise that resolves to an object containing the content of each processed example.
Properties โ
Property | Type | Default value |
---|---|---|
const | __module | consts |
opts | undefined | Config | undefined |
Functions โ
examplesPlugin() โ
function examplesPlugin(conf?: Config): Config
A plugin for dovenv
providing tools for managing example paths.
Parameters โ
Parameter | Type | Description |
---|---|---|
conf ? | Config | Configuration for the plugin. |
Returns โ
Config
- The plugin configuration with custom examples.
Type Aliases โ
Config โ
type Config: { [key in string]: ConfigValue };
ExampleConfigFileProps โ
type ExampleConfigFileProps: Prettify<Shared & {
config: ExampleConfig;
input: string | ExampleConfig;
}>;
ExampleCustomProps โ
type ExampleCustomProps: {
fn: (data: {
config: DovenvConfig;
run: {
config: (data: ExampleConfigFileProps) => Promise<string>;
jsdoc: (data: ExampleJsdocProps) => Promise<string>;
multiple: (data: ExampleMultipleProps) => Promise<string>;
path: (data: ExamplePathProps) => Promise<string>;
};
}) => Promise<unknown>;
};
Type declaration โ
Name | Type |
---|---|
fn | (data : { config : DovenvConfig ; run : { config : (data : ExampleConfigFileProps ) => Promise <string >; jsdoc : (data : ExampleJsdocProps ) => Promise <string >; multiple : (data : ExampleMultipleProps ) => Promise <string >; path : (data : ExamplePathProps ) => Promise <string >; }; }) => Promise <unknown > |
ExampleJsdocProps โ
type ExampleJsdocProps: ExamplePathProps;
ExampleMultipleProps โ
type ExampleMultipleProps: Prettify<Shared & {
config: Omit<ExampleConfigFileProps, "output">;
jsdoc: Omit<ExampleJsdocProps, "output">;
path: Omit<ExamplePathProps, "output">;
}>;
ExamplePathProps โ
type ExamplePathProps: Prettify<Shared & {
input: string[];
opts: Parameters<typeof getPaths>[1];
}>;
References โ
default โ
Renames and re-exports examplesPlugin