myst-cli
Version:
Command line tools for MyST
62 lines • 3.26 kB
TypeScript
import type { ISession } from '../session/types.js';
import type { PageLevels, LocalProjectFolder, LocalProjectPage, LocalProject, SlugOptions } from './types.js';
import type { TOC, Entry, ParentEntry, FileEntry, URLEntry, FileParentEntry, URLParentEntry } from 'myst-toc';
import { globSync } from 'glob';
export declare const DEFAULT_INDEX_FILENAMES: string[];
type EntryWithoutPattern = (FileEntry | URLEntry | FileParentEntry | URLParentEntry | ParentEntry) & {
implicit?: boolean;
};
export declare function comparePaths(a: string, b: string): number;
/**
* Traverse toc entries and return a list of files
*/
export declare function listExplicitFiles(entries: Entry[], path: string): string[];
/**
* Resolve pattern entries in a toc in the same way as implicit project sorting
*
* This is a normalization function that should be run on the toc prior to computing pages.
*
* - Resolution of pattern matches implicit structure (alpha sorting, respecting numbering)
* - However, implicitly ignored files (node_modules, _build, .*) are _not_ ignored
* - Project `exclude` files are still respected
* - Pages never show up twice even if they match multiple patterns
*/
export declare function patternsToFileEntries(session: ISession, entries: Entry[], path: string, ignore: string[], file: string, opts?: Omit<Parameters<typeof globSync>[1], 'withFileTypes'>): EntryWithoutPattern[];
/**
* Get a list of ignored files, including configs and project.exclude entries
*/
export declare function getIgnoreFiles(session: ISession, path: string): string[];
/**
* Build project structure from a MyST TOC
*
* Starting level may be provided; by default this is 1. Numbers up to
* 6 may be provided for pages to start at a lower level. Level may
* also be -1 or 0. In these cases, the first "part" level will be -1
* and the first "chapter" level will be 0; However, "sections"
* will never be level < 1.
*/
export declare function projectFromTOC(session: ISession, path: string, toc: TOC, level?: PageLevels, file?: string, opts?: SlugOptions): Omit<LocalProject, 'bibliography'>;
/**
* Build project structure from jupyterbook '_toc.yml' file on a path
*
* Starting level may be provided; by default this is 1. Numbers up to
* 6 may be provided for pages to start at a lower level. Level may
* also be -1 or 0. In these cases, the first "part" level will be -1
* and the first "chapter" level will be 0; However, "sections"
* will never be level < 1.
*/
export declare function projectFromSphinxTOC(session: ISession, path: string, level?: PageLevels, opts?: SlugOptions): Omit<LocalProject, 'bibliography'>;
/**
* Return only project pages/folders from a TOC
*
* The root file is converted into just another top-level page.
*/
export declare function pagesFromTOC(session: ISession, path: string, toc: TOC, level: PageLevels, opts?: SlugOptions): (LocalProjectFolder | LocalProjectPage)[];
/**
* Return only project pages/folders from a '_toc.yml' file
*
* The root file is converted into just another top-level page.
*/
export declare function pagesFromSphinxTOC(session: ISession, path: string, level: PageLevels, opts?: SlugOptions): (LocalProjectFolder | LocalProjectPage)[];
export {};
//# sourceMappingURL=fromTOC.d.ts.map