eslint-doc-generator
Version:
Automatic documentation generator for ESLint plugins and rules.
33 lines (32 loc) • 1.82 kB
TypeScript
import type { Context } from './context.js';
export declare function extractFrontmatter(markdown: string): string | undefined;
/**
* Replace the frontmatter, if present. If not and we have newFrontmatter to add, then add it at the beginning.
* @param markdown - doc content
* @param newFrontmatter - new frontmatter
*/
export declare function replaceOrCreateFrontmatter(markdown: string, newFrontmatter: string | undefined): string;
/**
* Replace the header of a doc up to and including the specified marker.
* Insert at beginning if header doesn't exist.
* @param markdown - doc content
* @param newHeader - new header including marker
* @param isMdx - is the file we're working on mdx or just regular md
*/
export declare function replaceOrCreateHeader(markdown: string, newHeader: string, isMdx: boolean): string;
/**
* Find the section most likely to be the top-level section for a given string.
*/
export declare function findSectionHeader(markdown: string, str: string): string | undefined;
export declare function findFinalHeaderLevel(context: Context, str: string): number | undefined;
/**
* Ensure a doc contains (or doesn't contain) some particular content.
* Upon failure, output the failure and set a failure exit code.
* @param docName - name of doc for error message
* @param contentName - name of content for error message
* @param contents - the doc's contents
* @param content - the content we are checking for
* @param expected - whether the content should be present or not present
*/
export declare function expectContentOrFail(docName: string, contentName: string, contents: string, content: string, expected: boolean): void;
export declare function expectSectionHeaderOrFail(contentName: string, contents: string, possibleHeaders: readonly string[], expected: boolean): void;