Skip to content

Commit 1199c01

Browse files
committed
closes #228 improving our code syntax highlighting and formatting
1 parent c3d9b93 commit 1199c01

File tree

3 files changed

+70
-22
lines changed

3 files changed

+70
-22
lines changed

conf.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858

5959
master_doc = 'index'
6060

61-
pygments_style = 'borland'
62-
6361
# Set the default role so we can use `foo` instead of ``foo``
6462
default_role = 'literal'
6563

@@ -95,9 +93,18 @@
9593

9694
# -- Options for Pygments ----------------------------------------------------
9795

96+
pygments_style = 'default'
97+
9898
# TODO: maybe write our own lexer to customize tokens, keywords, etc?
9999
lexers['cwl'] = YamlLexer()
100100

101+
highlight_options = {
102+
'default': {
103+
'stripall': True
104+
},
105+
'bash': {'startinline': True},
106+
}
107+
101108
# -- Options for HTML output -------------------------------------------------
102109

103110
# The theme to use for HTML and HTML Help pages. See the documentation for

prerequisites.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ like `venv` or `conda`. The following commands will create and activate a Python
3939
virtual environment using the `venv` module, and install `cwltool` in that
4040
environment:
4141

42-
```bash
42+
```{code-block} console
43+
:name: installing-cwltool-with-pip-and-venv
44+
:caption: Installing `cwltool` with `pip` and `venv`.
45+
4346
$ python -m venv venv
4447
$ source venv/bin/activate
4548
$ (venv) pip install cwltool
@@ -54,15 +57,22 @@ Let's use a simple workflow `true.cwl` with `cwltool`.
5457

5558
```{literalinclude} /_includes/cwl/simplest_cwl.cwl
5659
:language: cwl
60+
:caption: "`true.cwl`"
61+
:name: truecwl-file
5762
```
58-
<p class="text-center text-muted mt-n2">true.cwl</p>
5963

60-
First you can validate the CWL document:
64+
The `cwltool` command has an option to validate CWL workflows. It will parse the
65+
CWL workflow, look for syntax errors, and verify that the workflow is compliant
66+
with the CWL specification, without running the workflow. To use it you just need
67+
to pass `--validate` to the `cwltool` command:
6168

6269
% TODO: maybe figure out a way to avoid /home/kinow/ etc. in the documentation
6370
% to avoid multiple user-names/directory-locations varying in the docs.
6471

65-
```bash
72+
```{code-block} console
73+
:name: validating-truecwl-with-cwltool
74+
:caption: Validating `true.cwl` with `cwltool`.
75+
6676
$ cwltool --validate true.cwl
6777
INFO /home/kinow/Development/python/workspace/user_guide/venv/bin/cwltool 3.1.20220406080846
6878
INFO Resolved 'true.cwl' to 'file:///tmp/true.cwl'
@@ -71,7 +81,10 @@ true.cwl is valid CWL.
7181

7282
You can run the CWL workflow now that you know it is valid:
7383

74-
```bash
84+
```{code-block} console
85+
:name: running-truecwl-with-cwltool
86+
:caption: Running `true.cwl` with `cwltool`.
87+
7588
$ cwltool true.cwl
7689
INFO /home/kinow/Development/python/workspace/user_guide/venv/bin/cwltool 3.1.20220406080846
7790
INFO Resolved 'true.cwl' to 'file:///tmp/true.cwl'
@@ -81,7 +94,7 @@ INFO [job true.cwl] completed success
8194
INFO Final process status is success
8295
```
8396

84-
### cwl-runner
97+
### cwl-runner Python module
8598

8699
`cwl-runner` is an implementation agnostic alias for CWL Runners.
87100
Users can invoke `cwl-runner` instead of invoking a CWL runner like `cwltool`
@@ -93,7 +106,10 @@ The CWL community publishes a Python module with the same name,
93106
the rest of this user guide. You can use `pip` to install the `cwl-runner`
94107
Python module:
95108

96-
```bash
109+
```{code-block} console
110+
:name: installing-cwlrunner-with-pip
111+
:caption: Installing `cwl-runner` with `pip`.
112+
97113
$ pip install cwl-runner
98114
```
99115

@@ -104,14 +120,20 @@ Now you can validate and run your workflow with `cwl-runner` executable,
104120
which will invoke `cwltool`. You should have the same results and output
105121
as in the previous section.
106122

107-
```bash
123+
```{code-block} console
124+
:name: validating-truecwl-with-cwl-runner
125+
:caption: Validating `true.cwl` with `cwl-runner`.
126+
108127
$ cwl-runner --validate true.cwl
109128
INFO /home/kinow/Development/python/workspace/user_guide/venv/bin/cwl-runner 3.1.20220406080846
110129
INFO Resolved 'true.cwl' to 'file:///tmp/true.cwl'
111130
true.cwl is valid CWL.
112131
```
113132

114-
```bash
133+
```{code-block} console
134+
:name: running-truecwl-with-cwl-runner
135+
:caption: Running `true.cwl` with `cwl-runner`.
136+
115137
$ cwl-runner true.cwl
116138
INFO /home/kinow/Development/python/workspace/user_guide/venv/bin/cwl-runner 3.1.20220406080846
117139
INFO Resolved 'true.cwl' to 'file:///tmp/true.cwl'
@@ -127,15 +149,19 @@ a special first line, a *shebang*:
127149

128150
```{literalinclude} /_includes/cwl/simplest_cwl_shebang.cwl
129151
:language: cwl
152+
:name: cwltool-with-a-shebang
153+
:caption: "`cwltool` with a shebang"
130154
```
131-
<p class="text-center text-muted mt-n2">true.cwl</p>
132155

133156
Now, after you make the file `true.cwl` executable with `chmod u+x`,
134157
you can execute it directly in the command-line and the program
135158
specified in the shebang (`cwl-runner`) will be used to execute the
136159
rest of the file.
137160

138-
```bash
161+
```{code-block} console
162+
:name: making-truecwl-executable-and-running-it
163+
:caption: Making `true.cwl` executable and running it.
164+
139165
$ chmod u+x true.cwl
140166
$ ./true.cwl
141167
INFO /home/kinow/Development/python/workspace/user_guide/venv/bin/cwl-runner 3.1.20220406080846

quick-start.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ with comments:
1919

2020
```{literalinclude} /_includes/cwl/hello_world.cwl
2121
:language: cwl
22+
:name: hello_worldcwl
23+
:caption: "`hello_world.cwl`"
2224
```
23-
<p class="text-center text-muted mt-n2">hello_world.cwl</p>
2425

2526
The example above is just a wrapper for the `echo` command-line tool.
2627
Running the workflow above with the default input values, produces the
@@ -39,8 +40,11 @@ CWL *Reference Runner* for the specification, and compliant with the
3940
latest version of the specification, {{ cwl_version }}. You can install
4041
`cwltool` using `pip`:
4142

42-
```bash
43-
pip install cwltool
43+
```{code-block} console
44+
:name: installing-cwltool-with-pip
45+
:caption: Installing `cwltool` with `pip`.
46+
47+
$ pip install cwltool
4448
```
4549

4650
```{note}
@@ -55,7 +59,10 @@ The usage of the `cwltool` command-line executable is basically
5559
`cwltool [OPTIONS] <CWL_DOCUMENT> [INPUTS_OBJECT]`. You can run the
5660
`hello_world.cwl` workflow without specifying any option:
5761

58-
```bash
62+
```{code-block} console
63+
:name: running-hello_worldcwl-with-cwltool
64+
:caption: Running `hello_world.cwl` with `cwltool`.
65+
5966
$ cwltool hello_world.cwl
6067
INFO /tmp/venv/bin/cwltool 3.1.20220628170238
6168
INFO Resolved 'hello_world.cwl' to 'file:///tmp/hello_world.cwl'
@@ -70,7 +77,10 @@ INFO Final process status is success
7077
Or you can override the default value of the input parameter `message`, similar
7178
to how you would change the argument of the `echo` base command:
7279

73-
```bash
80+
```{code-block} console
81+
:name: running-hello_worldcwl-with-cwltool-passing-an-input-parameter
82+
:caption: Running `hello_world.cwl` with `cwltool` passing an input parameter.
83+
7484
$ cwltool hello_world.cwl --message="Hola mundo"
7585
INFO /home/kinow/Development/python/workspace/user_guide/venv/bin/cwltool 3.1.20220406080846
7686
INFO Resolved '/tmp/hello_world.cwl' to 'file:///tmp/hello_world.cwl'
@@ -86,7 +96,9 @@ Another way of passing values to your workflow input parameters is via an
8696
*Inputs Object*. This is a file containing the input fields with the
8797
corresponding values. This file can be written in JSON or YAML. For example:
8898

89-
```json
99+
```{code-block} json
100+
:name: hello_world-jobjson
101+
:caption: hello_world-job.json
90102
{
91103
"message": "こんにちは世界"
92104
}
@@ -95,7 +107,9 @@ corresponding values. This file can be written in JSON or YAML. For example:
95107

96108
You can use this Inputs Object file now to execute the “Hello World” workflow:
97109

98-
```bash
110+
```{code-block} console
111+
:name: passing-an-inputs-object-file-to-cwltool
112+
:caption: Passing an Inputs Object file to `cwltool`.
99113
$ cwltool hello_world.cwl hello_world-job.json
100114
INFO /home/kinow/Development/python/workspace/user_guide/venv/bin/cwltool 3.1.20220406080846
101115
INFO Resolved '/tmp/hello_world.cwl' to 'file:///tmp/hello_world.cwl'
@@ -109,8 +123,9 @@ INFO Final process status is success
109123

110124
```{note}
111125
We used a similar file name for the workflow and for the inputs object files.
112-
It is not a requirement for CWL, but the *-job.json* suffix is very common.
113-
You can choose any name for your workflows and inputs object files.
126+
The *-job.json* suffix is very common in Inputs Object files, but it is not
127+
a requirement. You can choose any name for your workflows and inputs object
128+
files.
114129
```
115130

116131
## Learn more

0 commit comments

Comments
 (0)