docusaurus-plugin-openapi-docs
Version:
OpenAPI plugin for Docusaurus.
58 lines (57 loc) • 2.18 kB
TypeScript
/**
* Represents an external JSON file to be written alongside the MDX.
*/
export interface ExternalFile {
/** The filename for the JSON file (relative to outputDir) */
filename: string;
/** The JSON content to write */
content: string;
}
/**
* Result of running MDX generation with externalization.
*/
export interface ExternalizationResult<T> {
/** The result of the generation function */
result: T;
/** External JSON files to write */
files: ExternalFile[];
}
/**
* Runs a function with externalization enabled.
* Any calls to create() within the function will externalize eligible component props.
*
* @param baseFilename - Base filename for the MDX file (without extension)
* @param fn - Function to run with externalization enabled
* @returns The function result and any external files that were collected
*
* @example
* const { result: mdx, files } = runWithExternalization("add-pet", () => {
* return createApiPageMD(item);
* });
*/
export declare function runWithExternalization<T>(baseFilename: string, fn: () => T): ExternalizationResult<T>;
/**
* Children in the plugin does not accept DOM elements, when compared with Children in the theme.
* It is designed for rendering HTML as strings.
*/
export type Children = string | undefined | (string | string[] | undefined)[];
export type Props = Record<string, any> & {
children?: Children;
};
export type Options = {
inline?: boolean;
};
/**
* Creates a JSX component string with the given tag, props, and options.
* When called within runWithExternalization(), props for eligible
* components are externalized to a single JSON file and spread.
*/
export declare function create(tag: string, props: Props, options?: Options): string;
export declare function guard<T>(value: T | undefined, cb: (value: T) => Children): string;
export declare function render(children: Children): string;
export declare const lessThan: RegExp;
export declare const greaterThan: RegExp;
export declare const codeFence: RegExp;
export declare const curlyBrackets: RegExp;
export declare const codeBlock: RegExp;
export declare function clean(value: string | undefined): string;