Metadata-Version: 2.5
Name: plain-parser
Version: 0.1.2.dev3
Summary: Parser for ***plain specification files
License-Expression: MIT
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Compilers
Requires-Python: >=3.11
Requires-Dist: mistletoe<2,>=1.6.0
Requires-Dist: networkx<4,>=3.6.1
Requires-Dist: python-frontmatter<2,>=1.3.0
Requires-Dist: python-liquid2<0.5,>=0.4.0
Requires-Dist: pyyaml<7,>=6
Provides-Extra: dev
Requires-Dist: black==26.5.1; extra == 'dev'
Requires-Dist: flake8==7.3.0; extra == 'dev'
Requires-Dist: isort==8.0.1; extra == 'dev'
Requires-Dist: mypy==2.3.0; extra == 'dev'
Requires-Dist: pytest==9.1.1; extra == 'dev'
Description-Content-Type: text/markdown

# plain-parser

Python parser for [`***plain`](https://www.plainlang.org/docs/) specification files.

Reads a `.plain`  module and its `import` / `requires` chain, resolves Liquid templates,
validates concepts and linked resources, and returns the marshalled specification tree
plus the ordered list of functionalities (FRIDs).

## Install

```bash
pip install plain-parser
```

## Usage

Validate a module and its `requires` chain from the command line (`<file>: OK` and exit `0` when valid; `Error: …` on stderr and exit `1` otherwise):

```bash
plain-parser check my_spec.plain [--template-dir DIR] [--config-name NAME]
```

Modules and `{% include %}` templates are looked up in the `.plain` file's directory, then in `--template-dir`.
When `--template-dir` is not given, it is read from the `template-dir` key of `config.yaml` (or the file named by
`--config-name`), found next to the `.plain` file or in the working directory. Finding it in both is a usage error
(exit `2`). The config file is read even when `--template-dir` is given, so a malformed one fails the run either way.
Other config keys are ignored.

Or from Python:

```python
from plain_parser import plain_file_parser

module_name, plain_source_tree, required_modules = plain_file_parser("my_spec.plain", ["."])
```

`plain_source_tree` is a dict keyed by section (`definitions`, `implementation reqs`,
`test reqs`, `functional specs`), each a list of `{"markdown": ..., "linked_resources": [...]}`
entries. `plain_parser.plain_spec` has helpers for walking functionalities
(`get_frids`, `get_specifications_for_frid`, `collect_linked_resources`).

## Development

```bash
uv venv --python 3.11 && source .venv/bin/activate
uv pip install -e ".[dev]"
pytest
black . --check && isort . --check-only && flake8 . && mypy src
```

## License

MIT, see [LICENSE](LICENSE).
