Skip to content

LLM Resources

@dovenv/examples - API documentation โ€‹

Classes โ€‹

Examples โ€‹

Constructors โ€‹

new Examples() โ€‹
ts
new Examples(data: {
  opts: Config;
  utils: CommandSuper;
 }): Examples
Parameters โ€‹
ParameterType
dataobject
data.opts?Config
data.utilsCommandSuper
Returns โ€‹

Examples

Methods โ€‹

fromConfig() โ€‹
ts
fromConfig(data: {
  config: ExampleProps<ExampleProps>;
  desc: string;
  input: string | ExampleProps<ExampleProps>;
  output: string;
  title: string | false;
}): Promise<string>
Parameters โ€‹
ParameterTypeDescription
dataobject-
data.config?ExampleProps<ExampleProps>Override your config input.
data.desc?stringDescription. Default 'Examples'
data.inputstring | ExampleProps<ExampleProps>Input of your config (path or config object). Path formats: JSON, YAML, TOML JS etc.
data.output?stringWrite a output if you want
data.title?string | falseH1 for markdown. Default 'Examples'
Returns โ€‹

Promise<string>

fromCustom() โ€‹
ts
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 โ€‹
ParameterTypeDescription
dataExampleCustomPropsObject containing the function to execute with the handlers.
Returns โ€‹

Promise<unknown>

A promise that resolves to the result of the executed function.

fromJsdoc() โ€‹
ts
fromJsdoc(data: {
  desc: string;
  input: string[];
  opts: Options;
  output: string;
  title: string | false;
}): Promise<string>

Process jsdoc examples.

Parameters โ€‹
ParameterTypeDescription
dataobjectExample data.
data.desc?stringDescription. Default 'Examples'
data.inputstring[]Input pattern.
data.opts?OptionsOptions for input patterns
data.output?stringWrite a output if you want
data.title?string | falseH1 for markdown. Default 'Examples'
Returns โ€‹

Promise<string>

Resolved example content.

See โ€‹

https://github.com/jsdoc2md/jsdoc-api/blob/master/docs/api.md

fromMultiple() โ€‹
ts
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 โ€‹
ParameterTypeDescription
dataobjectExample data.
data.config?Omit<{ config: ExampleProps<ExampleProps>; desc: string; input: string | ExampleProps<ExampleProps>; output: string; title: string | false; }, "output">-
data.desc?stringDescription. Default 'Examples'
data.jsdoc?Omit<{ desc: string; input: string[]; opts: Options; output: string; title: string | false; }, "output">-
data.output?stringWrite a output if you want
data.path?Omit<{ desc: string; input: string[]; opts: Options; output: string; title: string | false; }, "output">-
data.title?string | falseH1 for markdown. Default 'Examples'
Returns โ€‹

Promise<string>

Resolved example content.

fromPath() โ€‹
ts
fromPath(data: {
  desc: string;
  input: string[];
  opts: Options;
  output: string;
  title: string | false;
}): Promise<string>
Parameters โ€‹
ParameterTypeDescription
dataobject-
data.desc?stringDescription. Default 'Examples'
data.inputstring[]Input pattern.
data.opts?OptionsOptions for input patterns
data.output?stringWrite a output if you want
data.title?string | falseH1 for markdown. Default 'Examples'
Returns โ€‹

Promise<string>

get() โ€‹
ts
get(data: ConfigValue): Promise<any>

Get a custom Example content template.

Perfect method to be used outside an Dovenv environment.

Parameters โ€‹
ParameterTypeDescription
dataConfigValueConfiguration object.
Returns โ€‹

Promise<any>

A promise that resolves to the processed content as a string.

run() โ€‹
ts
run(pattern?: string[]): Promise<undefined | {}>

Process examples from the configuration object.

Parameters โ€‹
ParameterTypeDescription
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 โ€‹

PropertyTypeDefault value
const__moduleconsts
optsundefined | Configundefined

Functions โ€‹

examplesPlugin() โ€‹

ts
function examplesPlugin(conf?: Config): Config

A plugin for dovenv providing tools for managing example paths.

Parameters โ€‹

ParameterTypeDescription
conf?ConfigConfiguration for the plugin.

Returns โ€‹

Config

  • The plugin configuration with custom examples.

Type Aliases โ€‹

Config โ€‹

ts
type Config: { [key in string]: ConfigValue };

ExampleConfigFileProps โ€‹

ts
type ExampleConfigFileProps: Prettify<Shared & {
  config: ExampleConfig;
  input: string | ExampleConfig;
}>;

ExampleCustomProps โ€‹

ts
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 โ€‹

NameType
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 โ€‹

ts
type ExampleJsdocProps: ExamplePathProps;

ExampleMultipleProps โ€‹

ts
type ExampleMultipleProps: Prettify<Shared & {
  config: Omit<ExampleConfigFileProps, "output">;
  jsdoc: Omit<ExampleJsdocProps, "output">;
  path: Omit<ExamplePathProps, "output">;
}>;

ExamplePathProps โ€‹

ts
type ExamplePathProps: Prettify<Shared & {
  input: string[];
  opts: Parameters<typeof getPaths>[1];
}>;

References โ€‹

default โ€‹

Renames and re-exports examplesPlugin