myst-cli
Version:
Command line tools for MyST
76 lines • 3.83 kB
TypeScript
import type { Export } from 'myst-frontmatter';
import { ExportFormats } from 'myst-frontmatter';
import { VFile } from 'vfile';
import type { LocalProject } from '../../project/types.js';
import type { ISession } from '../../session/types.js';
import type { ExportWithOutput, ExportWithInputOutput, ExportWithFormat, RendererFn } from '../types.js';
export declare const SOURCE_EXTENSIONS: string[];
type ResolvedArticles = Pick<Export, 'articles' | 'sub_articles'>;
export declare function resolveArticlesFromProject(exp: ExportWithFormat, proj: Omit<LocalProject, 'bibliography'>, vfile: VFile): ResolvedArticles;
/**
* Resolve template to absolute path
*
* If `disableTemplate: true` template resolves to `null`
*
* Otherwise, if it exists on the path relative to the source file, it is
* resolved to absolute path. If not, it is unchanged.
*/
export declare function resolveTemplate(sourceFile: string, exp: Export, disableTemplate?: boolean): string | null | undefined;
/**
* Resolve format based on export format/template/output
*
* User-provided `format` is prioritized, then `template` type, then `output` file extension.
* (Validation ensures one of format/output/template is provided.)
*
* If `format` or `output` give PDF export, we look at the template kind and switch to `typst`
* in the case of a typst template.
*/
export declare function resolveFormat(vfile: VFile, exp: Export): ExportFormats | undefined;
/**
* Resolve articles and sub_articles based on explicit or implicit table of contents
*
* This also takes into account format, to determine if multiple articles or sub_articles
* are allowed.
*/
export declare function resolveArticles(session: ISession, sourceFile: string, vfile: VFile, exp: ExportWithFormat, projectPath?: string): ResolvedArticles;
export declare const ALLOWED_EXTENSIONS: Record<ExportFormats, string[]>;
/**
* Resolve output based on format and existing output value
*
* By default, this will generate a file with a valid extension in
* the _build directory.
*
* If output is provided with a valid extension, it is respected.
* If output is provided with an invalid extension, an error is logged.
* If output has no extension, it is assumed to be the output folder and
* will be used in place of the _build directory.
*/
export declare function resolveOutput(session: ISession, sourceFile: string, vfile: VFile, exp: ExportWithFormat, projectPath?: string): string | undefined;
export type CollectionOptions = {
projectPath?: string;
disableTemplate?: boolean;
renderer?: RendererFn;
};
/**
* Resolve formats on export list and filter based on desired formats
*
* @param sourceFile
* @param formats desired output formats
* @param exportList list of export objects from a file or defined explicitly
*/
export declare function resolveExportListFormats(session: ISession, sourceFile: string, formats: ExportFormats[], exportList: Export[]): ExportWithFormat[];
/**
* Resolve export list with formats to export list with articles and outputs
*/
export declare function resolveExportListArticles(session: ISession, sourceFile: string, exportList: ExportWithFormat[], projectPath: string | undefined, opts: CollectionOptions): ExportWithOutput[];
/**
* Given source files and desired export formats, collect all export objects
*
* @param files source files to inspect for exports
* @param formats list of requested ExportFormat types
* @param opts export options, mostly passed in from the command line
* @param opts.projectPath if provided, exports will also be loaded from the project config
*/
export declare function collectExportOptions(session: ISession, files: string[], formats: ExportFormats[], opts: CollectionOptions): Promise<ExportWithInputOutput[]>;
export {};
//# sourceMappingURL=collectExportOptions.d.ts.map