From ced430bd3f22fc1c89fb83b915ed8e83f12b394d Mon Sep 17 00:00:00 2001 From: Ben Shaw Date: Sat, 31 Aug 2019 20:42:28 +1200 Subject: [PATCH] docs: Added instructions for running py interpreter in dev --- py/README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/py/README.md b/py/README.md index 47d6f239..21884bde 100644 --- a/py/README.md +++ b/py/README.md @@ -32,3 +32,45 @@ serialized = """{"type": "Heading", "content": ["Heading Text"], "depth": 2}""" h2 = from_json(serialized) ``` + +## Interpreter + +This library can also be used to interpret executable documents. Once installed it can be used like this: + +```bash +$ python3 -m stencila.schema execute [parameters] +``` + +`inputfile` and/or `outputfile` can be set to `-` to read from stdin and/or write to stdout (respectively). + +`[parameters]` is a list of parameters to pass to the document –- these will differ based on what the document defines. +They can be passed either by `--parameter_name=parameter_value` or `--parameter_name parameter_value`. Each parameter +must be named. + +### Usage in Development + +There are three options to run the interpreter without installing this package (which can be useful when developing). + +#### setup.py develop + +Run `python3 setup.py develop` which will link this library into your site packages directory. You can then execute +documents with the above Interpreter command. + +#### Run interpreter.py directly + +You can run the `interpreter.py` script directly, the arguments are the same as running as a module in the example +above except the first `execute` argument is omitted: + +```bash +$ python3 schema/py/stencila/schema/interpreter.py [parameters] +``` + +### cd into stencila directory + +You can run the interpreter as a module by changing into the `stencila` directory first, and then ommitting the +`stencila` namespace: + +```bash +$ cd schema/py/stencila +$ python3 -m schema execute [parameters] +```