import { Block, Query } from './types'; /** * The ReadmeBlock represents the header and the content of a Readme section. * It exists to provide a way for the user to use methods returning {@link ReadmeBlock} * with the {@link Readme} instance. * @public */ export declare class ReadmeBlock { /** * A parsed Markdown header. */ header: string; /** * A parsed Markdown section. */ content: string; /** * @param block - an object conforming to the {@link Block} interface */ constructor(block: Block); /** * @returns a string formatting the combination of the header and the content lines. */ toString(): string; } /** * @public */ export declare type IndexedBlocks = Map; /** * The Readme class represents a markdown README and provides an API for programmatic transformations of it. * @public */ export declare class Readme { STANDARD_DOCS_PATH: string; /** * @param line - string representing a single line from a readme content. * * @returns a boolean indicating whether the readme line is a header */ static isHeader: (line: string) => boolean; /** * @param line - string representing a single line from a readme content. * * @returns a boolean indicating whether the readme line is a code start tag. */ static isCodeStartTag: (line: string) => boolean; /** * @param line - string representing a single line from a readme content. * * @returns a boolean indicating whether the readme line is a code end tag. */ static isCodeEndTag: (line: string) => boolean; /** * @param block - a {@link Block} object representing a content block in a parsed readme file. * * @returns a boolean indicating whether the readme line is a code end tag. */ static isRootNode: (block: Block) => boolean; /** * @param line - string representing a single line from a readme content. * * @returns a github-sanitized string to be used as an anchor tag linking to another section of the same readme document. */ static sanitize: (line: string) => string; /** * @param s - a string to be repeated * @param count - the number of times a string should be repeated. * * @returns a string comprised of `s`, repeated `count` times. */ static repeat: (s: string, count: number) => string; /** * @param header - a string representing a readme content section header. * @param query - a {@link Query} object * @param strict - a boolean flag to enable strict string matching. * * @returns - a boolean indicating whether a specific header was found in the readme content. */ static headerFound(header: string, query: Query, strict?: boolean): boolean; /** * @param textParts - a list of strings that are used to build a table of contents entry that links to a content section * * @returns a string representing a markdown anchor tag to a link in the same document. */ static makeLink: (...textParts: string[]) => string; /** * Generates a content block with an unlicense license. * @param heading - type of heading to use for the license block. * @returns a {@link ReadmeBlock} */ static getLicenseBlock(header?: string): ReadmeBlock; /** * @param content - a string representing an unparsed section * @returns a parsed readme section as a {@link ReadmeBlock} */ static parseBlockFromContent(content: string): ReadmeBlock; /** * readme content */ content: string; /** * A list of {@link ReadmeBlock}. */ blocks: ReadmeBlock[]; /** * A map of {@link IndexedBlocks} blocks. */ indexedBlocks: IndexedBlocks; /** * @param content - readme content as a string. */ constructor(content?: string); /** * @param content - readme content as string, to be parsed into {@link ReadmeBlock}s. * Parses the readme content and returns a Readme instance for chaining. * @public * @returns a {@link Readme} instance. */ static parse(content?: string): ReadmeBlock[]; /** * Indexes {@link Block}s by header to support efficient querying. * @public */ index(): void; /** * Generates a table of contents for a specified subset of sections, to avoid * including the readme top level sections, and to provide greater user control. * @public * @param startAt - the index of blocks to start parsing for the table of contents * @param indent - a string used to pad indentations for the list indentations. * * @returns a table of contents in string form. */ getTocBlock(startAt?: number, indent?: string): ReadmeBlock | undefined; /** * Convert the internal readme representation back to a string. * * @returns a string representing the entire readme after any transformations. */ export(): string; /** Implements toString method so that the readme is coerced properly * when stringified. * * @returns a string representing the entire readme, post any transformations. */ toString(): string; /** * Get a content parsed block by index. * * @param index - index of block in list of parsed content blocks. * * @returns a {@link Block} at the supplied index. If the index is out of range, it throws an error. */ getSectionAt(index: number): ReadmeBlock; /** * Find a single content (non-code) block by header. * * @param content - a {@link Block} object to insert before a matched content header. * @param strict - whether to perform a strict string match or not against a content header. * * @returns a single {@link Block } object if a section is matched, or null. */ getSection(target: Query, strict?: boolean): ReadmeBlock | null; /** * Find content blocks by header. * * @param content - a {@link Block} object to insert before a matched content header. * @param strict - whether to perform a strict string match or not against a content header. * * @returns a list of matched content {@link Block}s. */ getSections(target: Query, strict?: boolean): ReadmeBlock[]; /** * Parses content and adds it as a block to the end of the readme. * @param content - a string representing an unparsed readme section */ appendContent(content: string): void; /** * Parses content and adds it as a block to the beginning of the readme. * @param content - a string representing an unparsed readme section */ prependContent(content: string): void; /** * Appends content at end of the readme content list. * * @param block - a {@link Block} object to insert before a matched content header. * @param target - optional target block to append the new block after. */ appendBlock(block: ReadmeBlock, target?: ReadmeBlock | null): void; /** * Prepends content to the beginning of the readme content list. * * @param block - a {@link Block} object to insert before a matched content header. * @param target - optional target block to prepend the new block before. */ prependBlock(block: ReadmeBlock, target?: ReadmeBlock | null): void; /** * Inserts the content after a matching content block. * * @param target - a {@link Query} object to match a content section. * @param content - a {@link Block} object to insert after a matched content header. * @param strict - boolean indicating whether to perform a strict match or not against a content header. */ insertAfter(target: Query, newBlock: ReadmeBlock, strict?: boolean): void; /** * Inserts the content after a matching content block. * * @param target - a {@link Query} object to match a content section. * @param content - a {@link Block} object to insert before a matched content header. * @param strict - whether to perform a strict string match or not against a content header. */ insertBefore(target: Query, newBlock: ReadmeBlock, strict?: boolean): void; /** * Set the first found section (targeted by string/regex) to the supplied content * * @param target - a {@link Query} object to match a content section for replacement. * @param content - a {@link Block} object to insert after a matched content header. */ setSection(target: Query, content: string): void; /** * Set the section content at the supplied index. If the index is out of range, throw an error. * * @param index - index at which to set a section's content. * @param content - a {@link Block} object to insert after a matched content header. */ setSectionAt(index: number, content: string): void; } //# sourceMappingURL=readme.d.ts.map