Skip to content

Commit 6835eb7

Browse files
authored
Fix emphasize-lines with runcmd (#280)
* Fix emphasize-lines with runcmd * Update emphasize-lines in inputs.md * Fix emphasize lines for the troubleshooting file
1 parent 58943d7 commit 6835eb7

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

cwl/sphinx/runcmd.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,20 @@ def run(self):
169169
r = match.group("replacement").replace("\\", "")
170170
output = re.sub(p, r, output)
171171

172+
# Note: Sphinx's CodeBlock directive expects an array of command-line
173+
# output lines: https://github.com/sphinx-doc/sphinx/blob/c51a88da8b7b40e8d8cbdb1fce85ca2346b2b59a/sphinx/directives/code.py#L114
174+
# But the runcmd original code was simply wrapping a string
175+
# containing \n in the text as a one-element array, e.g.
176+
# ["cwltool --debug ...\ncwltool Version..."].
177+
# That caused the output to be correctly rendered, but the
178+
# emphasize-lines directive parameter to fail if the lines were
179+
# anything greater than 0 (as the self.content array had 1 elem).
180+
# See: https://github.com/common-workflow-language/user_guide/issues/269
181+
output = output.split("\n")
182+
172183
# Set up our arguments to run the CodeBlock parent run function
173184
self.arguments[0] = syntax
174-
self.content = [output]
185+
self.content = output
175186
node = super(RunCmdDirective, self).run()
176187

177188
return node

src/topics/inputs.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ In the first example, you can't provide `itemA` without also providing `itemB`.
222222

223223
```{runcmd} cwltool record.cwl record-job2.yml
224224
:working-directory: src/_includes/cwl/inputs
225-
:emphasize-lines: 3, 9-10, 24
225+
:emphasize-lines: 4, 10-11, 23
226226
````
227227
228228
```{code-block} console
@@ -241,7 +241,7 @@ matching item (`itemC`) is added to the command line and remaining item (`itemD`
241241

242242
```{runcmd} cwltool record.cwl record-job3.yml
243243
:working-directory: src/_includes/cwl/inputs
244-
:emphasize-lines: 9-10, 24
244+
:emphasize-lines: 9-10, 22
245245
````
246246
247247
```{code-block} console
@@ -266,7 +266,6 @@ that accepts `null` (i.e. no value provided), or any value from an enum.
266266
:language: cwl
267267
:caption: "`exclusive-parameter-expressions.cwl`"
268268
:name: exclusive-parameter-expressions.cwl
269-
:emphasize-lines: 7, 21-23
270269
```
271270

272271
Note how the JavaScript expression uses the value of the exclusive input parameter
@@ -284,7 +283,7 @@ output field (a `string`), resulting in failure when running your workflow.
284283
285284
```{runcmd} cwltool exclusive-parameter-expressions.cwl
286285
:working-directory: src/_includes/cwl/inputs
287-
:emphasize-lines: 6-10
286+
:emphasize-lines: 5-10
288287
```
289288

290289
To correct it, you must remember to use an or operator in your JavaScript expression

src/topics/troubleshooting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ create the directory for you if it does not exist already):
2929

3030
```{runcmd} cwltool --cachedir /tmp/cachedir/ troubleshooting-wf1.cwl
3131
:working-directory: src/_includes/cwl/troubleshooting
32-
:emphasize-lines: 12-14, 19-21
32+
:emphasize-lines: 13-15, 18-20
3333
```
3434

3535
The workflow is in the `permanentFail` status due to `step_b` failing to execute the
@@ -53,7 +53,7 @@ Also note that the status of `step_b` is now of success.
5353

5454
```{runcmd} cwltool --cachedir /tmp/cachedir/ troubleshooting-wf1-stepb-fixed.cwl
5555
:working-directory: src/_includes/cwl/troubleshooting
56-
:emphasize-lines: 12, 16-18
56+
:emphasize-lines: 12-16
5757
```
5858

5959
In this example the workflow step `step_a` was not re-evaluated as it had been cached, and

0 commit comments

Comments
 (0)