/** * @see {@link extractExamplesFromDocument} */ export type ExtractExamplesFromDocumentOptions = { /** * If `true`, the value returned by `extractExamplesFromDocument` will take * the form `Map` where each example region is mapped to a * regular expression representing that example. Newlines will be preserved * (as `\n` characters), but multiple space characters will be collapsed and * replaced with a single `\s+`. All other characters in the example text will * be escaped using `RegExp.escape`. * * Returning a regular expression representing the example text instead of the * text itself is useful when the real output contains a variable number of * spaces, such as when examining CLI output that expands to fill the * available terminal width. * * @default false */ asRegExp?: boolean; /** * Use the internal cached result from a previous run, if available. * * Unless `useCached` is `false`, the results returned by this function will * always strictly equal (`===`) each other with respect to call signature. * * @see {@link cache} */ useCached: boolean; }; /** * This function returns a mapping of identifiers to code blocks by searching * the document at `path` for _example regions_. Example regions are code blocks * in Markdown style (3+ backticks, e.g. ```` ```js\n...\n``` ````) or HTML * style (e.g. `
\n...\n
`) that are preceded by * a "special" HTML/Markdown comment denoting the block as an example region. * * For example: * * ````markdown * * * ```js * const myCodeExample = 'goes here'; * ``` * ```` * * Where `id` is a non-zero-length string that will become the identifier mapped * to its respective code block, both of which are returned by this function. * * The only characters that can separate the special example region comment from * its code block are whitespace characters (including newlines). If any other * characters appear between the code block and its identifier, it will not be * recognized as an example region and will be ignored. * * **NOTE: the result of this function is memoized! This does NOT _necessarily_ * mean results will strictly equal each other. See `useCached` in this specific * function's options for details.** To fetch fresh results, set the `useCached` * option to `false` or clear the internal cache with {@link cache.clear}. */ export declare function extractExamplesFromDocument(path: string, options: ExtractExamplesFromDocumentOptions & { asRegExp?: false; }): Promise>; export declare function extractExamplesFromDocument(path: string, options: ExtractExamplesFromDocumentOptions): Promise>; export declare namespace extractExamplesFromDocument { /** * This function returns a mapping of identifiers to code blocks by searching * the document at `path` for _example regions_. Example regions are code * blocks in Markdown style (3+ backticks, e.g. ```` ```js\n...\n``` ````) or * HTML style (e.g. `
\n...\n
`) that are * preceded by a "special" HTML/Markdown comment denoting the block as an * example region. * * For example: * * ````markdown * * * ```js * const myCodeExample = 'goes here'; * ``` * ```` * * Where `id` is a non-zero-length string that will become the identifier * mapped to its respective code block, both of which are returned by this * function. * * The only characters that can separate the special example region comment * from its code block are whitespace characters (including newlines). If any * other characters appear between the code block and its identifier, it will * not be recognized as an example region and will be ignored. * * **NOTE: the result of this function is memoized! This does NOT * _necessarily_ mean results will strictly equal each other. See `useCached` * in this specific function's options for details.** To fetch fresh results, * set the `useCached` option to `false` or clear the internal cache with * {@link cache.clear}. */ function extractExamplesFromDocumentSync(path: string, options: ExtractExamplesFromDocumentOptions & { asRegExp?: false; }): Map; function extractExamplesFromDocumentSync(path: string, options: ExtractExamplesFromDocumentOptions): Map; export const sync: typeof extractExamplesFromDocumentSync; export {}; }