Skip to content

Fix emphasize-lines with runcmd #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cwl/sphinx/runcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,20 @@ def run(self):
r = match.group("replacement").replace("\\", "")
output = re.sub(p, r, output)

# Note: Sphinx's CodeBlock directive expects an array of command-line
# output lines: https://github.com/sphinx-doc/sphinx/blob/c51a88da8b7b40e8d8cbdb1fce85ca2346b2b59a/sphinx/directives/code.py#L114
# But the runcmd original code was simply wrapping a string
# containing \n in the text as a one-element array, e.g.
# ["cwltool --debug ...\ncwltool Version..."].
# That caused the output to be correctly rendered, but the
# emphasize-lines directive parameter to fail if the lines were
# anything greater than 0 (as the self.content array had 1 elem).
# See: https://github.com/common-workflow-language/user_guide/issues/269
output = output.split("\n")

# Set up our arguments to run the CodeBlock parent run function
self.arguments[0] = syntax
self.content = [output]
self.content = output
node = super(RunCmdDirective, self).run()

return node
Expand Down
7 changes: 3 additions & 4 deletions src/topics/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ In the first example, you can't provide `itemA` without also providing `itemB`.

```{runcmd} cwltool record.cwl record-job2.yml
:working-directory: src/_includes/cwl/inputs
:emphasize-lines: 3, 9-10, 24
:emphasize-lines: 4, 10-11, 23
````

```{code-block} console
Expand All @@ -241,7 +241,7 @@ matching item (`itemC`) is added to the command line and remaining item (`itemD`

```{runcmd} cwltool record.cwl record-job3.yml
:working-directory: src/_includes/cwl/inputs
:emphasize-lines: 9-10, 24
:emphasize-lines: 9-10, 22
````

```{code-block} console
Expand All @@ -266,7 +266,6 @@ that accepts `null` (i.e. no value provided), or any value from an enum.
:language: cwl
:caption: "`exclusive-parameter-expressions.cwl`"
:name: exclusive-parameter-expressions.cwl
:emphasize-lines: 7, 21-23
```

Note how the JavaScript expression uses the value of the exclusive input parameter
Expand All @@ -284,7 +283,7 @@ output field (a `string`), resulting in failure when running your workflow.

```{runcmd} cwltool exclusive-parameter-expressions.cwl
:working-directory: src/_includes/cwl/inputs
:emphasize-lines: 6-10
:emphasize-lines: 5-10
```

To correct it, you must remember to use an or operator in your JavaScript expression
Expand Down
4 changes: 2 additions & 2 deletions src/topics/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ create the directory for you if it does not exist already):

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

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

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

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