Skip to content

Commit

Permalink
Add doc info on DSL code-comment syntax (#1165)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl authored Dec 31, 2022
1 parent 7bf358e commit b89371d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/src/dsl-example.mlr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
$cost = $quantity * $rate;
$cost = $quantity * $rate; # Here is how to make a comment
$index *= 100
6 changes: 4 additions & 2 deletions docs/src/miller-programming-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ purple square false 10 9100 72.3735 8.2430 596.5747605000001

<pre class="pre-highlight-in-pair">
<b>mlr --c2p put '</b>
<b> $cost = $quantity * $rate;</b>
<b> $cost = $quantity * $rate; # Here is how to make a comment</b>
<b> $index *= 100</b>
<b>' example.csv</b>
</pre>
Expand All @@ -91,13 +91,15 @@ yellow circle true 9 8700 63.5058 8.3350 529.3208430000001
purple square false 10 9100 72.3735 8.2430 596.5747605000001
</pre>

Anything from a `#` character to end of line is a code comment.

One of Miller's key features is the ability to express data-transformation right there at the keyboard, interactively. But if you find yourself using expressions repeatedly, you can put everything between the single quotes into a file and refer to that using `put -f`:

<pre class="pre-highlight-in-pair">
<b>cat dsl-example.mlr</b>
</pre>
<pre class="pre-non-highlight-in-pair">
$cost = $quantity * $rate;
$cost = $quantity * $rate; # Here is how to make a comment
$index *= 100
</pre>

Expand Down
4 changes: 3 additions & 1 deletion docs/src/miller-programming-language.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ GENMD-EOF

GENMD-RUN-COMMAND
mlr --c2p put '
$cost = $quantity * $rate;
$cost = $quantity * $rate; # Here is how to make a comment
$index *= 100
' example.csv
GENMD-EOF

Anything from a `#` character to end of line is a code comment.

One of Miller's key features is the ability to express data-transformation right there at the keyboard, interactively. But if you find yourself using expressions repeatedly, you can put everything between the single quotes into a file and refer to that using `put -f`:

GENMD-RUN-COMMAND
Expand Down
3 changes: 3 additions & 0 deletions docs/src/reference-dsl-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Newlines within the expression are ignored, which can help increase legibility o

<pre class="pre-highlight-in-pair">
<b>mlr --opprint put '</b>
<b> # Here is how to make a comment</b>
<b> $nf = NF;</b>
<b> $nr = NR;</b>
<b> $fnr = FNR;</b>
Expand All @@ -62,6 +63,8 @@ hat wye 10002 0.321507044286237609 0.568893318795083758 5 9 4 2 data/s
pan zee 10003 0.272054845593895200 0.425789896597056627 5 10 5 2 data/small2
</pre>

Anything from a `#` character to end of line is a code comment.

<pre class="pre-highlight-in-pair">
<b>mlr --opprint filter '($x > 0.5 && $y < 0.5) || ($x < 0.5 && $y > 0.5)' \</b>
<b> then stats2 -a corr -f x,y \</b>
Expand Down
3 changes: 3 additions & 0 deletions docs/src/reference-dsl-syntax.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Newlines within the expression are ignored, which can help increase legibility o

GENMD-RUN-COMMAND
mlr --opprint put '
# Here is how to make a comment
$nf = NF;
$nr = NR;
$fnr = FNR;
Expand All @@ -20,6 +21,8 @@ mlr --opprint put '
' data/small data/small2
GENMD-EOF

Anything from a `#` character to end of line is a code comment.

GENMD-RUN-COMMAND
mlr --opprint filter '($x > 0.5 && $y < 0.5) || ($x < 0.5 && $y > 0.5)' \
then stats2 -a corr -f x,y \
Expand Down

0 comments on commit b89371d

Please sign in to comment.