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

update examples #48

Merged
merged 1 commit into from
Jun 25, 2024
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
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Usage:

Flags:
-o, --result-md-path <Filepath> - path to a resulting `.md` file; if omitted, updates the original file
--print-block-results - print the block's execution results immediately.
--print-block-results - print blocks one by one as they are executed
--echo - output resulting markdown to the terminal
--save-ansi - save ANSI formatted version
--no-backup - overwrite the existing `.md` file without backup
Expand Down Expand Up @@ -87,10 +87,10 @@ By default, `numd` provides basic stats on changes made.
╭──────────────────┬───────────────────────────────────╮
│ filename │ simple_markdown_with_no_output.md │
│ nushell_blocks │ 3 │
│ levenshtein_dist │ 38
│ diff_lines │ +9 (37.5%)
│ levenshtein_dist │ 39
│ diff_lines │ +10 (41.7%)
│ diff_words │ +6 (10.7%) │
│ diff_chars │ +38 (11%)
│ diff_chars │ +39 (11.3%)
╰──────────────────┴───────────────────────────────────╯
```

Expand Down Expand Up @@ -123,6 +123,7 @@ Output:
// > 2 + 2
// + 4
// ```
// +
```

### Styling outputs
Expand Down Expand Up @@ -156,6 +157,7 @@ Output:
// | 1 | 2 | 3 |
// +---+---+---+
// ```
//
```

### `numd clear-outputs`
Expand Down Expand Up @@ -275,3 +277,4 @@ Testing of the `numd` module itself is done via the `testing` command in `tools.
│ README.md │ 10 │ 0 │ 0% │ 0% │ 0% │
╰───────────filename────────────┴─nushell_blocks─┴─levenshtein_dist─┴─diff_lines─┴─diff_words─┴─diff_chars─╯
```

1 change: 1 addition & 0 deletions examples/1_simple_markdown/simple_markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ user
> 2 + 2
4
```

80 changes: 39 additions & 41 deletions examples/2_numd_commands_explanations/numd_commands_explanations.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,50 +141,48 @@ The `run-intermid-script` command runs and captures outputs of the executed inte
# the flag `$no_fail_on_error` is set to false
let $no_fail_on_error = false

let $nu_res_stdout_lines = run-intermid-script $intermid_script_path $no_fail_on_error
let $nu_res_stdout_lines = run-intermid-script $intermid_script_path $no_fail_on_error false
rm $intermid_script_path
$nu_res_stdout_lines
```

Output:

```
// ╭───────────────────────────────────────────────────────────────────────╮
// │ # This is a simple markdown example │
// │ │
// │ ## Example 1 │
// │ │
// │ the block below will be executed as it is, but won't yield any output │
// │ │
// │ ```nu │
// │ let $var1 = 'foo' │
// │ ``` │
// │ ```output-numd │
// │ ``` │
// │ │
// │ ## Example 2 │
// │ │
// │ ```nu │
// │ # This block will produce some output in a separate block │
// │ $var1 | path join 'baz' 'bar' │
// │ ``` │
// │ ```output-numd │
// │ foo/baz/bar │
// │ │
// │ ``` │
// │ │
// │ ## Example 3 │
// │ │
// │ ```nu │
// │ # This block will output results inline │
// │ > whoami │
// │ user │
// │ │
// │ > 2 + 2 │
// │ 4 │
// │ │
// │ ``` │
// ╰───────────────────────────────────────────────────────────────────────╯
// # This is a simple markdown example
//
// ## Example 1
//
// the block below will be executed as it is, but won't yield any output
//
// ```nu
// let $var1 = 'foo'
// ```
// ```output-numd
// ```
//
// ## Example 2
//
// ```nu
// # This block will produce some output in a separate block
// $var1 | path join 'baz' 'bar'
// ```
// ```output-numd
// foo/baz/bar
//
// ```
//
// ## Example 3
//
// ```nu
// # This block will output results inline
// > whoami
// user
//
// > 2 + 2
// 4
//
// ```
```

```nu indent-output
Expand Down Expand Up @@ -227,7 +225,6 @@ Output:
//
// > 2 + 2
// 4
//
// ```
```

Expand All @@ -245,9 +242,10 @@ Output:
// ╭──────────────────┬────────────────────╮
// │ filename │ simple_markdown.md │
// │ nushell_blocks │ 3 │
// │ levenshtein_dist │ 2
// │ diff_lines │ +1 (3.3%)
// │ levenshtein_dist │ 1
// │ diff_lines │ -1 (-3.2%)
// │ diff_words │ 0% │
// │ diff_chars │ 0%
// │ diff_chars │ -1 (-0.3%)
// ╰──────────────────┴────────────────────╯
```

Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The `run-intermid-script` command runs and captures outputs of the executed inte
print ("# the flag `$no_fail_on_error` is set to false
let $no_fail_on_error = false

let $nu_res_stdout_lines = run-intermid-script $intermid_script_path $no_fail_on_error
let $nu_res_stdout_lines = run-intermid-script $intermid_script_path $no_fail_on_error false
rm $intermid_script_path
$nu_res_stdout_lines" | nu-highlight)

Expand All @@ -100,7 +100,7 @@ $nu_res_stdout_lines" | nu-highlight)
# the flag `$no_fail_on_error` is set to false
let $no_fail_on_error = false

let $nu_res_stdout_lines = run-intermid-script $intermid_script_path $no_fail_on_error
let $nu_res_stdout_lines = run-intermid-script $intermid_script_path $no_fail_on_error false
rm $intermid_script_path
$nu_res_stdout_lines | table | into string | lines | each {$'// ($in)' | str trim --right} | str join (char nl) | print; print ''

Expand Down
1 change: 1 addition & 0 deletions examples/3_book_types_of_data/types_of_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,3 +533,4 @@ If you would prefer this to return `null`, mark the cell path member as _optiona

The absence of a value is (as of Nushell 0.71) printed as the ❎ emoji in interactive output.
:::

1 change: 1 addition & 0 deletions examples/4_book_working_with_lists/working_with_lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,4 @@ be converted to a separate row with a single column:
│ Asia/Yekaterinburg │ 2024.06.17 11:06 │
╰────────Zone────────┴───────Time───────╯
```