import { normalizeSimpleName, type SimpleName } from '../SimpleName.ts' import { RstNode } from '../RstNode/RstNode.ts' import { convertUnicode } from '../utils/convertUnicode.ts' import { RstDirective } from '../RstNode/ExplicitMarkup/Directive.ts' import { RstInterpretedText } from '../RstNode/Inline/InterpretedText.ts' import type { RstGeneratorOptions } from './RstGeneratorOptions.ts' import { RstCompiler } from '../RstCompiler.ts' import { SubstitutionResolver } from '../Parser/Resolver/SubstitutionResolver.ts' import { HtmlAttrResolver } from '../Parser/Resolver/HtmlAttrResolver.ts' import { RstDocument } from '../RstNode/Block/Document.ts' import type { RstNodeGenerator } from './RstGenerator.ts' import { type FilePathWithoutRst, getFilePathWithoutRst } from './FilePathWithoutRst.ts' import { RstSection } from '../RstNode/Block/Section.ts' import { HtmlAttributeStore } from './HtmlAttributeStore.ts' import { RstGeneratorError } from './RstGeneratorError.ts' import { sha1 } from '../utils/sha1.ts' import { SimpleNameResolver } from '../Parser/Resolver/SimpleNameResolver.ts' import { RstFootnoteDef } from '../RstNode/ExplicitMarkup/FootnoteDef.ts' import { RstFootnoteRef } from '../RstNode/Inline/FootnoteRef.ts' import type { RstParserOutput } from '../Parser/RstParserState.ts' import { RstCitationRef } from '../RstNode/Inline/CitationRef.ts' import { RstCitationDef } from '../RstNode/ExplicitMarkup/CitationDef.ts' import { getAutoFootnoteSymbol } from '../utils/getAutoFootnoteSymbol.ts' import { getPathDirname, joinFilePath, normalizeFilePath, resolveFilePath } from '../utils/path.ts' import { RstHyperlinkTarget } from '../RstNode/ExplicitMarkup/HyperlinkTarget.ts' import { RstHyperlinkRef } from '../RstNode/Inline/HyperlinkRef.ts' export type RstGeneratorInput = { basePath: string // Base url all pages will be deployed to (default /) currentDocPath: string docs: Array<{ docPath: string // docPath is relative to basePath parserOutput: RstParserOutput }> } export type RstGeneratorOutput = { body: string header: string downloads: Array<{ srcPath: string destPath: string }> } type LinePrefix = { val: string replacementAfterOnce?: string } type OutputBuffer = { textOutput: string prefixes: Array } type VisitChildren = () => void export class RstGeneratorState { readonly opts: RstGeneratorOptions private readonly _generatorInput: Readonly private readonly _compiler: RstCompiler private readonly _basePath: FilePathWithoutRst private readonly _currentDocPath: FilePathWithoutRst private readonly _currentParserOutput: RstParserOutput private readonly _docsCache: ReadonlyMap private readonly _simpleNameCache: ReadonlyMap private _globalHeaderBuffer = new Map() // Content to write to top of output e.g.