Skip to content
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

Add a new highlighter that skips lines starting with $ #3306

Closed
iesahin opened this issue Feb 22, 2022 · 2 comments
Closed

Add a new highlighter that skips lines starting with $ #3306

iesahin opened this issue Feb 22, 2022 · 2 comments
Labels
type: discussion Requires active participation to reach a conclusion. website: eng-doc DEPRECATED JS engine for /doc

Comments

@iesahin
Copy link
Contributor

iesahin commented Feb 22, 2022

Our intention is to add some automation to document generation. Currently, for a set of commands below, we run the command and add the output by copy/paste. I think it's possible to add semi-automated command blocks.

An example workflow is like:

  • Run a script dvc-doc-runner.py that takes the source blocks in dvcoutput format, get commands from the lines starting with $, run them and update the block by commands and outputs. Note that, as we run the script manually, there is no need for site generator (Gatsby) to run these scripts everytime. We only run them when we need.
  • Commit files that are updated by the script to Git, and submit a PR as normal.
  • The highlighter will only show the lines without $. Hence not the commands, but the outputs will be shown.

For example, for two command blocks like:

```dvc
$ dvc exp show
```
```dvctableoutput
$ git clone https://github.com/iterative/example-dvc-experiments /tmp/ede
$ cd /tmp/ede
$ dvc exp show --no-pager --json | custom-script-to-draw-table.py
<<<colored table>>>
```

The lines with $ in dvc will be shown, but the lines with $ in dvctableoutput won't be shown in the HTML output. Only the remaining part with table <<<colored table>>> (or output) will be shown. This will enable to automate the outputs in the UG and GS on demand, quickly. Also it won't add DVC as a dependency to the site generation.

It can have two flavors, one derived from dvc that shows the command output as is, one from dvctable that shows the colored tables.

Originally posted by @iesahin in #2770 (comment)

@jorgeorpinel
Copy link
Contributor

Ideally we could extend the dvctable highlighter hopefully without need to run any commands or clone repos? Just copy-paste the output and it colors it automatically.

From #2770 (comment)

@iesahin
Copy link
Contributor Author

iesahin commented Feb 22, 2022

Copy-paste doesn't work as expected, there are terminal/shell dependent control characters for colorful output and I usually redirect it first to a file, then copy the contents from an editor. We can add another control character, like to run some lines in dvc blocks, but not show them to the reader.

```dvctable
€ git clone https://github.com/iterative/example-dvc-experiments /tmp/ede
€ cd /tmp/ede
€ dvc exp show --no-pager --json | custom-script-to-draw-table.py
$ dvc exp show
<<<dvc exp show output from first 3 lines>>>
```

This one will run the first 3 lines, but show the line starting with $ only, and its output.

@jorgeorpinel jorgeorpinel added type: discussion Requires active participation to reach a conclusion. website: eng-doc DEPRECATED JS engine for /doc labels Mar 8, 2022
@dberenbaum dberenbaum closed this as not planned Won't fix, can't repro, duplicate, stale Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: discussion Requires active participation to reach a conclusion. website: eng-doc DEPRECATED JS engine for /doc
Projects
None yet
Development

No branches or pull requests

3 participants