UNPKG

1.02 kBTypeScriptView Raw
1import Doer from './Doer';
2import { SoftwarePackage } from '@stencila/schema';
3/**
4 * A base class for language parsers
5 *
6 * A language `Parser` generates a JSON-LD `SoftwarePackage` instance based on the
7 * contents of a directory. It is responsible for determining which packages the application
8 * needs, resolving the dependencies of those packages (both system and language packages) and
9 * turning those into a JSON-LD `SoftwarePackage` instance.
10 *
11 * If the `Parser` finds a corresponding requirements file for the language (e.g. `requirements.txt` for Python),
12 * then it uses that to determine the language packages to install. If no requirements file is found,
13 * it scans for source code files for package import statements (e.g. `library(package)` in `.R` files),
14 * generates a package list from those statements and creates a requirements file.
15 */
16export default abstract class Parser extends Doer {
17 /**
18 * Parse the project folder
19 */
20 abstract parse(): Promise<SoftwarePackage | null>;
21}