@dovenv/convert - API documentation β
Classes β
Convert β
Convertion class.
Example β
// convert ts files to markdown
const convert = new Convert()
await convert.ts2md({input: 'src/main.ts', output: 'README.md' })Implements β
ConvertInterface
Constructors β
new Convert() β
new Convert(): ConvertReturns β
Methods β
custom() β
custom(params: {
fn: (data: {
config: Config;
run: {
html2md: (params: ConvertPropsSuper) => Promise<ConvertResponse>;
jsdoc2md: (params: Jsdoc2MarkdownProps) => Promise<ConvertResponse>;
md2html: (params: ConvertPropsSuper) => Promise<ConvertResponse>;
openapi2md: (params: Openapi2MarkdownProps) => Promise<ConvertResponse>;
ts2html: (params: {
input: string | string[];
opts: {
hooks: {
after: ... | ...;
before: ... | ...;
};
name: string;
packageJsonPath: string;
transform: (content: string) => Promise<...>;
tsconfigPath: string;
typedoc: Partial<Omit<..., ...>>;
};
output: string;
}) => Promise<{
content: string;
id: path;
}[]>;
ts2md: (params: {
input: string | string[];
opts: {
hooks: {
after: ... | ...;
before: ... | ...;
};
name: string;
packageJsonPath: string;
transform: (content: string) => Promise<...>;
tsconfigPath: string;
typedoc: Partial<Omit<..., ...>>;
typedocMarkdown: Partial<PluginOptions>;
};
output: string;
}) => Promise<{
content: string;
id: path;
}[]>;
};
}) => Promise<void>;
}): Promise<void>Parameters β
| Parameter | Type | Description |
|---|---|---|
params | object | - |
params.fn | (data: { config: Config; run: { html2md: (params: ConvertPropsSuper) => Promise<ConvertResponse>; jsdoc2md: (params: Jsdoc2MarkdownProps) => Promise<ConvertResponse>; md2html: (params: ConvertPropsSuper) => Promise<ConvertResponse>; openapi2md: (params: Openapi2MarkdownProps) => Promise<ConvertResponse>; ts2html: (params: { input: string | string[]; opts: { hooks: { after: ... | ...; before: ... | ...; }; name: string; packageJsonPath: string; transform: (content: string) => Promise<...>; tsconfigPath: string; typedoc: Partial<Omit<..., ...>>; }; output: string; }) => Promise<{ content: string; id: path; }[]>; ts2md: (params: { input: string | string[]; opts: { hooks: { after: ... | ...; before: ... | ...; }; name: string; packageJsonPath: string; transform: (content: string) => Promise<...>; tsconfigPath: string; typedoc: Partial<Omit<..., ...>>; typedocMarkdown: Partial<PluginOptions>; }; output: string; }) => Promise<{ content: string; id: path; }[]>; }; }) => Promise<void> | Function to run your conversion. |
Returns β
Promise<void>
Implementation of β
ConvertInterface.custom
html2md() β
html2md(params: ConvertPropsSuper): Promise<ConvertResponse>Parameters β
| Parameter | Type |
|---|---|
params | ConvertPropsSuper |
Returns β
Promise<ConvertResponse>
Implementation of β
ConvertInterface.html2md
jsdoc2md() β
jsdoc2md(params: Jsdoc2MarkdownProps): Promise<ConvertResponse>Parameters β
| Parameter | Type |
|---|---|
params | Jsdoc2MarkdownProps |
Returns β
Promise<ConvertResponse>
Implementation of β
ConvertInterface.jsdoc2md
md2html() β
md2html(params: ConvertPropsSuper): Promise<ConvertResponse>Parameters β
| Parameter | Type |
|---|---|
params | ConvertPropsSuper |
Returns β
Promise<ConvertResponse>
Implementation of β
ConvertInterface.md2html
openapi2md() β
openapi2md(params: Openapi2MarkdownProps): Promise<ConvertResponse>Parameters β
| Parameter | Type |
|---|---|
params | Openapi2MarkdownProps |
Returns β
Promise<ConvertResponse>
Implementation of β
ConvertInterface.openapi2md
ts2html() β
ts2html(params: {
input: string | string[];
opts: {
hooks: {
after: () => string | Promise<string>;
before: () => string | Promise<string>;
};
name: string;
packageJsonPath: string;
transform: (content: string) => Promise<string>;
tsconfigPath: string;
typedoc: Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">>;
};
output: string;
}): Promise<{
content: string;
id: path;
}[]>Parameters β
| Parameter | Type | Description |
|---|---|---|
params | object | - |
params.input | string | string[] | Input patterns. Accepts glob patterns, urls, and strings. Examples [ 'https://pigeonposse.com', './docs/*.md', 'Just a simple string' ] './my/file' 'https://pigeonposse.com' 'my content string data' |
params.opts? | object | Options. See https://dovenv.pigeonposse.com/guide/plugin/convert |
params.opts.hooks? | object | Hooks. |
params.opts.hooks.after? | () => string | Promise<string> | - |
params.opts.hooks.before? | () => string | Promise<string> | - |
params.opts.name? | string | Name of your project. |
params.opts.packageJsonPath? | string | Package.json path. This path is used to extract specific properties from the package.json file. Default join( process.cwd(), "package.json" ) |
params.opts.transform? | (content: string) => Promise<string> | Transform function. |
params.opts.tsconfigPath? | string | Cuaton tsconfig path. Used for getting the ts config of the output. Default join( process.cwd(), "tsconfig.ts" ) |
params.opts.typedoc? | Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">> | Typedoc options. See https://typedoc.org/options/ |
params.output? | string | Output path. |
Returns β
Promise<{ content: string; id: path; }[]>
Implementation of β
ConvertInterface.ts2html
ts2md() β
ts2md(params: {
input: string | string[];
opts: {
hooks: {
after: () => string | Promise<string>;
before: () => string | Promise<string>;
};
name: string;
packageJsonPath: string;
transform: (content: string) => Promise<string>;
tsconfigPath: string;
typedoc: Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">>;
typedocMarkdown: Partial<PluginOptions>;
};
output: string;
}): Promise<{
content: string;
id: path;
}[]>Parameters β
| Parameter | Type | Description |
|---|---|---|
params | object | - |
params.input | string | string[] | Input patterns. Accepts glob patterns, urls, and strings. Examples [ 'https://pigeonposse.com', './docs/*.md', 'Just a simple string' ] './my/file' 'https://pigeonposse.com' 'my content string data' |
params.opts? | object | Options. See https://dovenv.pigeonposse.com/guide/plugin/convert |
params.opts.hooks? | object | Hooks. |
params.opts.hooks.after? | () => string | Promise<string> | - |
params.opts.hooks.before? | () => string | Promise<string> | - |
params.opts.name? | string | Name of your project. |
params.opts.packageJsonPath? | string | Package.json path. This path is used to extract specific properties from the package.json file. Default join( process.cwd(), "package.json" ) |
params.opts.transform? | (content: string) => Promise<string> | Transform function. |
params.opts.tsconfigPath? | string | Cuaton tsconfig path. Used for getting the ts config of the output. Default join( process.cwd(), "tsconfig.ts" ) |
params.opts.typedoc? | Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">> | Typedoc options. See https://typedoc.org/options/ |
params.opts.typedocMarkdown? | Partial<PluginOptions> | Typedoc markdown options. See - - https://typedoc-plugin-markdown.org/docs/options |
params.output? | string | Output path. |
Returns β
Promise<{ content: string; id: path; }[]>
Implementation of β
ConvertInterface.ts2md
Properties β
| Property | Type | Default value |
|---|---|---|
config | Config | {} |
Html2Markdown β
Extends β
ConvertSuper<Html2MarkdownProps>
Constructors β
new Html2Markdown() β
new Html2Markdown(props: ConvertPropsSuper): Html2MarkdownParameters β
| Parameter | Type |
|---|---|
props | ConvertPropsSuper |
Returns β
Overrides β
ConvertSuper<Html2MarkdownProps>.constructor
Methods β
run() β
run(): Promise<ConvertResponse>Returns β
Promise<ConvertResponse>
Properties β
| Property | Type | Overrides |
|---|---|---|
props | ConvertPropsSuper | ConvertSuper.props |
Jsdoc2Markdown β
Extends β
ConvertSuper<Jsdoc2MarkdownProps>
Implements β
ConvertSuperInterface
Constructors β
new Jsdoc2Markdown() β
new Jsdoc2Markdown(props: Jsdoc2MarkdownProps): Jsdoc2MarkdownParameters β
| Parameter | Type |
|---|---|
props | Jsdoc2MarkdownProps |
Returns β
Overrides β
ConvertSuper<Jsdoc2MarkdownProps>.constructor
Methods β
run() β
run(): Promise<ConvertResponse>Returns β
Promise<ConvertResponse>
Implementation of β
ConvertSuperInterface.run
Properties β
| Property | Type | Overrides |
|---|---|---|
props | Jsdoc2MarkdownProps | ConvertSuper.props |
Markdown2Html β
Extends β
ConvertSuper<Markdown2HtmlProps>
Implements β
ConvertSuperInterface
Constructors β
new Markdown2Html() β
new Markdown2Html(props: ConvertPropsSuper): Markdown2HtmlParameters β
| Parameter | Type |
|---|---|
props | ConvertPropsSuper |
Returns β
Overrides β
ConvertSuper<Markdown2HtmlProps>.constructor
Methods β
run() β
run(): Promise<ConvertResponse>Returns β
Promise<ConvertResponse>
Implementation of β
ConvertSuperInterface.run
Properties β
| Property | Type | Overrides |
|---|---|---|
props | ConvertPropsSuper | ConvertSuper.props |
MultipleConvert β
Constructors β
new MultipleConvert() β
new MultipleConvert(__namedParameters: {
opts: Config;
utils: CommandSuper;
}): MultipleConvertParameters β
| Parameter | Type |
|---|---|
__namedParameters | object |
__namedParameters.opts? | Config |
__namedParameters.utils | CommandSuper |
Returns β
Methods β
run() β
run(pattern?: string[]): Promise<undefined | Res>Parameters β
| Parameter | Type |
|---|---|
pattern? | string[] |
Returns β
Promise<undefined | Res>
Properties β
| Property | Type |
|---|---|
convert | Convert |
opts | undefined | Config |
utils | CommandSuper |
Openapi2Markdown β
Extends β
ConvertSuper<Openapi2MarkdownProps>
Implements β
ConvertSuperInterface
Constructors β
new Openapi2Markdown() β
new Openapi2Markdown(props: Openapi2MarkdownProps): Openapi2MarkdownParameters β
| Parameter | Type |
|---|---|
props | Openapi2MarkdownProps |
Returns β
Overrides β
ConvertSuper<Openapi2MarkdownProps>.constructor
Methods β
run() β
run(): Promise<ConvertResponse>Returns β
Promise<ConvertResponse>
Implementation of β
ConvertSuperInterface.run
Properties β
| Property | Type | Overrides |
|---|---|---|
props | Openapi2MarkdownProps | ConvertSuper.props |
Typescript2Markdown β
Extends β
TypescriptSuper<Typescript2MarkdownProps>
Implements β
ConvertSuperInterface
Constructors β
new Typescript2Markdown() β
new Typescript2Markdown(props: {
input: string | string[];
opts: {
hooks: {
after: () => string | Promise<string>;
before: () => string | Promise<string>;
};
name: string;
packageJsonPath: string;
transform: (content: string) => Promise<string>;
tsconfigPath: string;
typedoc: Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">>;
typedocMarkdown: Partial<PluginOptions>;
};
output: string;
}): Typescript2MarkdownParameters β
| Parameter | Type | Description |
|---|---|---|
props | object | - |
props.input | string | string[] | Input patterns. Accepts glob patterns, urls, and strings. Examples [ 'https://pigeonposse.com', './docs/*.md', 'Just a simple string' ] './my/file' 'https://pigeonposse.com' 'my content string data' |
props.opts? | object | Options. See https://dovenv.pigeonposse.com/guide/plugin/convert |
props.opts.hooks? | object | Hooks. |
props.opts.hooks.after? | () => string | Promise<string> | - |
props.opts.hooks.before? | () => string | Promise<string> | - |
props.opts.name? | string | Name of your project. |
props.opts.packageJsonPath? | string | Package.json path. This path is used to extract specific properties from the package.json file. Default join( process.cwd(), "package.json" ) |
props.opts.transform? | (content: string) => Promise<string> | Transform function. |
props.opts.tsconfigPath? | string | Cuaton tsconfig path. Used for getting the ts config of the output. Default join( process.cwd(), "tsconfig.ts" ) |
props.opts.typedoc? | Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">> | Typedoc options. See https://typedoc.org/options/ |
props.opts.typedocMarkdown? | Partial<PluginOptions> | Typedoc markdown options. See - - https://typedoc-plugin-markdown.org/docs/options |
props.output? | string | Output path. |
Returns β
Overrides β
TypescriptSuper<Typescript2MarkdownProps>.constructor
Methods β
run() β
run(): Promise<{
content: string;
id: path;
}[]>Returns β
Promise<{ content: string; id: path; }[]>
Implementation of β
ConvertSuperInterface.run
runTypedoc() β
runTypedoc<C>(customConf?: C): Promise<{
content: string;
id: path;
}[]>Type Parameters β
| Type Parameter |
|---|
C extends Record<string, unknown> |
Parameters β
| Parameter | Type |
|---|---|
customConf? | C |
Returns β
Promise<{ content: string; id: path; }[]>
Inherited from β
TypescriptSuper.runTypedoc
Properties β
| Property | Type | Description | Overrides |
|---|---|---|---|
props | { input: string | string[]; opts: { hooks: { after: () => string | Promise<string>; before: () => string | Promise<string>; }; name: string; packageJsonPath: string; transform: (content: string) => Promise<string>; tsconfigPath: string; typedoc: Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">>; typedocMarkdown: Partial<PluginOptions>; }; output: string; } | - | TypescriptSuper.props |
props.input | string | string[] | Input patterns. Accepts glob patterns, urls, and strings. Examples [ 'https://pigeonposse.com', './docs/*.md', 'Just a simple string' ] './my/file' 'https://pigeonposse.com' 'my content string data' | - |
props.opts? | { hooks: { after: () => string | Promise<string>; before: () => string | Promise<string>; }; name: string; packageJsonPath: string; transform: (content: string) => Promise<string>; tsconfigPath: string; typedoc: Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">>; typedocMarkdown: Partial<PluginOptions>; } | Options. See https://dovenv.pigeonposse.com/guide/plugin/convert | - |
props.opts.hooks? | { after: () => string | Promise<string>; before: () => string | Promise<string>; } | Hooks. | - |
props.opts.hooks.after? | () => string | Promise<string> | - | - |
props.opts.hooks.before? | () => string | Promise<string> | - | - |
props.opts.name? | string | Name of your project. | - |
props.opts.packageJsonPath? | string | Package.json path. This path is used to extract specific properties from the package.json file. Default join( process.cwd(), "package.json" ) | - |
props.opts.transform? | (content: string) => Promise<string> | Transform function. | - |
props.opts.tsconfigPath? | string | Cuaton tsconfig path. Used for getting the ts config of the output. Default join( process.cwd(), "tsconfig.ts" ) | - |
props.opts.typedoc? | Partial<Omit<TypeDocOptions, "plugin" | "tsconfig" | "entryPoints" | "out">> | Typedoc options. See https://typedoc.org/options/ | - |
props.opts.typedocMarkdown? | Partial<PluginOptions> | Typedoc markdown options. See - - https://typedoc-plugin-markdown.org/docs/options | - |
props.output? | string | Output path. | - |
Functions β
convertPlugin() β
function convertPlugin(conf?: Config): ConfigA plugin for dovenv to convert files from one format to another.
Parameters β
| Parameter | Type | Description |
|---|---|---|
conf? | Config | Configuration for the plugin. |
Returns β
Config
- The plugin.
Example β
import { defineConfig } from '@dovenv/core'
import { convertPlugin } from '@dovenv/convert'
export default defineConfig(
convertPlugin( {
exampleJSDOC: {
type: 'jsdoc2md',
input: 'examples/recourses/main.js',
output: 'build/jsdoc',
},
exampleTS: {
type: 'ts2md',
input: 'examples/recourses/main.ts',
output: 'build/ts',
},
exampleHTML: {
type: 'md2html',
input: 'https://raw.githubusercontent.com/pigeonposse/backan/refs/heads/main/README.md',
output: 'build/html',
},
} ),
)Type Aliases β
Config β
type Config: { [key in string]: ConfigValue };References β
default β
Renames and re-exports convertPlugin
