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