docutils-ts
Version:
Port of the Python Docutils library to TypeScript
87 lines (86 loc) • 2.88 kB
TypeScript
import { Publisher } from './publisher.js';
import { ConfigSettings, SettingsSpecType, LoggerType } from './types.js';
import Writer from './writer.js';
import Parser from './parser.js';
import Reader from './reader.js';
import { Settings } from './settings.js';
export { Publisher };
export interface FileSystem {
writeFile(path: string, data: string | Uint8Array, options?: any): Promise<void>;
readFile(path: string): Promise<string | Uint8Array>;
}
export declare const fileSystem: {
writeFile: (path: string, data: string | Uint8Array, options?: any) => Promise<void>;
readFile: (path: string, options?: any) => Promise<string | Uint8Array>;
setImplementation: (implementation: FileSystem) => void;
resetToDefault: () => void;
};
export interface PublishStringOptions {
source: string | Uint8Array;
sourcePath?: string;
destinationPath?: string;
reader?: Reader;
readerName?: string;
parser?: Parser;
parserName?: string;
writer?: Writer;
writerName?: string;
settings?: any;
settingsSpec?: any;
settingsOverrides?: any;
configSection?: string;
enableExitStatus?: boolean;
}
export interface publishProgramaticallyOptions {
sourceClass: any;
source: string | Uint8Array;
sourcePath?: string;
destinationClass: any;
destination?: any;
destinationPath?: string;
reader?: Reader;
readerName?: string;
parser?: Parser;
parserName?: string;
writer?: Writer;
writerName?: string;
settings?: any;
settingsSpec?: any;
settingsOverrides?: any;
configSection?: string;
enableExitStatus?: boolean;
}
export declare function publish(args: any): void;
export interface PublishCmdLineArgs {
reader?: Reader;
readerName?: string;
parser?: Parser;
parserName?: string;
writer?: Writer;
writerName?: string;
settings?: Settings;
settingsSpec?: SettingsSpecType[];
settingsOverrides?: ConfigSettings;
configSection?: string;
enableExitStatus?: boolean;
argv?: string[];
usage?: string;
description?: string;
logger?: LoggerType;
}
/**
* Set up & run a `Publisher` for command-line-based file I/O (input and
* output file paths taken automatically from the command line). Return the
* encoded string output also.
*
* Parameters: see `publish_programmatically` for the remainder.
*
* - `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
* - `usage`: Usage string, output if there's a problem parsing the command
* line.
* - `description`: Program description, output for the "--help" option
* (along with command-line option descriptions).
*
*/
export declare function publishCmdLine(args: PublishCmdLineArgs): Promise<string | Uint8Array>;
export declare function publish_string(options: PublishStringOptions): Promise<string | Uint8Array>;