Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Markdown Shell Recorder: Add Partial Support for Indented Code Blocks #2002

Merged
merged 9 commits into from
May 17, 2018
94 changes: 50 additions & 44 deletions doc/help/kdb-ls.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,55 +37,61 @@ This command will list the name of all keys below a given path.
## EXAMPLES

```sh
# Backup-and-Restore: /sw/elektra/examples
# Backup-and-Restore: /tests/examples

# We use `dump` as storage format here, since storage plugins such as INI
# automatically add keys between levels (e.g. `/tests/examples/kdb-ls/test/foo`).
kdb mount ls.ecf /tests/examples dump

# Create the keys we use for the examples
kdb set /sw/elektra/examples/kdb-ls/test val1
kdb set /sw/elektra/examples/kdb-ls/test/foo/bar val2
kdb set /sw/elektra/examples/kdb-ls/test/fizz/buzz fizzbuzz
kdb set /sw/elektra/examples/kdb-ls/tost val3
kdb set /sw/elektra/examples/kdb-ls/tost/level lvl

# list all keys below /sw/elektra/examples/kdb-ls
kdb ls /sw/elektra/examples/kdb-ls
#>user/sw/elektra/examples/kdb-ls/test
#>user/sw/elektra/examples/kdb-ls/test/fizz/buzz
#>user/sw/elektra/examples/kdb-ls/test/foo/bar
#>user/sw/elektra/examples/kdb-ls/tost
#>user/sw/elektra/examples/kdb-ls/tost/level

# list the next level of keys below /sw/elektra/examples/kdb-ls
kdb set /tests/examples/kdb-ls/test val1
kdb set /tests/examples/kdb-ls/test/foo/bar val2
kdb set /tests/examples/kdb-ls/test/fizz/buzz fizzbuzz
kdb set /tests/examples/kdb-ls/tost val3
kdb set /tests/examples/kdb-ls/tost/level lvl

# list all keys below /tests/examples/kdb-ls
kdb ls /tests/examples/kdb-ls
#> user/tests/examples/kdb-ls/test
#> user/tests/examples/kdb-ls/test/fizz/buzz
#> user/tests/examples/kdb-ls/test/foo/bar
#> user/tests/examples/kdb-ls/tost
#> user/tests/examples/kdb-ls/tost/level

# list the next level of keys below /tests/examples/kdb-ls
# note that if the search key ends with a /, it lists the next level
kdb ls /sw/elektra/examples/kdb-ls/ --max-depth=1
#>user/sw/elektra/examples/kdb-ls/test
#>user/sw/elektra/examples/kdb-ls/tost
kdb ls /tests/examples/kdb-ls/ --max-depth=1
#> user/tests/examples/kdb-ls/test
#> user/tests/examples/kdb-ls/tost

# list the current level of keys below /sw/elektra/examples/kdb-ls
# list the current level of keys below /tests/examples/kdb-ls
# note the difference to the previous example
kdb ls /sw/elektra/examples/kdb-ls --max-depth=1
# this yields no output as /sw/elektra/examples/kdb-ls is not a key

# list all keys below /sw/elektra/examples/kdb-ls with are minimum 1 level away from that key
# and maximum 2 levels away
kdb ls /sw/elektra/examples/kdb-ls --min-depth=1 --max-depth=2
#>user/sw/elektra/examples/kdb-ls/tost/level

# list all keys below /sw/elektra/examples/kdb-ls/test
kdb ls /sw/elektra/examples/kdb-ls/test
#>user/sw/elektra/examples/kdb-ls/test
#>user/sw/elektra/examples/kdb-ls/test/fizz/buzz
#>user/sw/elektra/examples/kdb-ls/test/foo/bar

# list all keys under /sw/elektra/examples/kdb-ls in verbose mode
kdb ls /sw/elektra/examples/kdb-ls/ -v
#>size of all keys in mountpoint: 31
#>size of requested keys: 5
#>user/sw/elektra/examples/kdb-ls/test
#>user/sw/elektra/examples/kdb-ls/test/fizz/buzz
#>user/sw/elektra/examples/kdb-ls/test/foo/bar
#>user/sw/elektra/examples/kdb-ls/tost
#>user/sw/elektra/examples/kdb-ls/tost/level

kdb ls /tests/examples/kdb-ls --max-depth=1
# this yields no output as /tests/examples/kdb-ls is not a key

# list all keys below /tests/examples/kdb-ls with are minimum 1 level (inclusive) away from that key
# and maximum 2 levels away (exclusive)
kdb ls /tests/examples/kdb-ls --min-depth=1 --max-depth=2
#> user/tests/examples/kdb-ls/test
#> user/tests/examples/kdb-ls/tost

# list all keys below /tests/examples/kdb-ls/test
kdb ls /tests/examples/kdb-ls/test
#> user/tests/examples/kdb-ls/test
#> user/tests/examples/kdb-ls/test/fizz/buzz
#> user/tests/examples/kdb-ls/test/foo/bar

# list all keys under /tests/examples/kdb-ls in verbose mode
kdb ls /tests/examples/kdb-ls/ -v
#> size of all keys in mountpoint: 5
#> size of requested keys: 5
#> user/tests/examples/kdb-ls/test
#> user/tests/examples/kdb-ls/test/fizz/buzz
#> user/tests/examples/kdb-ls/test/foo/bar
#> user/tests/examples/kdb-ls/tost
#> user/tests/examples/kdb-ls/tost/level

kdb umount /tests/examples
```

## SEE ALSO
Expand Down
85 changes: 46 additions & 39 deletions doc/man/man1/kdb-ls.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "KDB\-LS" "1" "April 2018" "" ""
.TH "KDB\-LS" "1" "May 2018" "" ""
.
.SH "NAME"
\fBkdb\-ls\fR \- List keys in the key database
Expand Down Expand Up @@ -57,54 +57,61 @@ Give debug information\.
.
.nf

# Backup\-and\-Restore: /sw/elektra/examples
# Backup\-and\-Restore: /tests/examples

# We use `dump` as storage format here, since storage plugins such as INI
# automatically add keys between levels (e\.g\. `/tests/examples/kdb\-ls/test/foo`)\.
kdb mount ls\.ecf /tests/examples dump

# Create the keys we use for the examples
kdb set /sw/elektra/examples/kdb\-ls/test val1
kdb set /sw/elektra/examples/kdb\-ls/test/foo/bar val2
kdb set /sw/elektra/examples/kdb\-ls/test/fizz/buzz fizzbuzz
kdb set /sw/elektra/examples/kdb\-ls/tost val3
kdb set /sw/elektra/examples/kdb\-ls/tost/level lvl
kdb set /tests/examples/kdb\-ls/test val1
kdb set /tests/examples/kdb\-ls/test/foo/bar val2
kdb set /tests/examples/kdb\-ls/test/fizz/buzz fizzbuzz
kdb set /tests/examples/kdb\-ls/tost val3
kdb set /tests/examples/kdb\-ls/tost/level lvl

# list all keys below /sw/elektra/examples/kdb\-ls
kdb ls /sw/elektra/examples/kdb\-ls
#>user/sw/elektra/examples/kdb\-ls/test
#>user/sw/elektra/examples/kdb\-ls/test/fizz/buzz
#>user/sw/elektra/examples/kdb\-ls/test/foo/bar
#>user/sw/elektra/examples/kdb\-ls/tost
#>user/sw/elektra/examples/kdb\-ls/tost/level
# list all keys below /tests/examples/kdb\-ls
kdb ls /tests/examples/kdb\-ls
#> user/tests/examples/kdb\-ls/test
#> user/tests/examples/kdb\-ls/test/fizz/buzz
#> user/tests/examples/kdb\-ls/test/foo/bar
#> user/tests/examples/kdb\-ls/tost
#> user/tests/examples/kdb\-ls/tost/level

# list the next level of keys below /sw/elektra/examples/kdb\-ls
# list the next level of keys below /tests/examples/kdb\-ls
# note that if the search key ends with a /, it lists the next level
kdb ls /sw/elektra/examples/kdb\-ls/ \-\-max\-depth=1
#>user/sw/elektra/examples/kdb\-ls/test
#>user/sw/elektra/examples/kdb\-ls/tost
kdb ls /tests/examples/kdb\-ls/ \-\-max\-depth=1
#> user/tests/examples/kdb\-ls/test
#> user/tests/examples/kdb\-ls/tost

# list the current level of keys below /sw/elektra/examples/kdb\-ls
# list the current level of keys below /tests/examples/kdb\-ls
# note the difference to the previous example
kdb ls /sw/elektra/examples/kdb\-ls \-\-max\-depth=1
# this yields no output as /sw/elektra/examples/kdb\-ls is not a key
kdb ls /tests/examples/kdb\-ls \-\-max\-depth=1
# this yields no output as /tests/examples/kdb\-ls is not a key

# list all keys below /tests/examples/kdb\-ls with are minimum 1 level (inclusive) away from that key
# and maximum 2 levels away (exclusive)
kdb ls /tests/examples/kdb\-ls \-\-min\-depth=1 \-\-max\-depth=2
#> user/tests/examples/kdb\-ls/test
#> user/tests/examples/kdb\-ls/tost

# list all keys below /sw/elektra/examples/kdb\-ls with are minimum 1 level away from that key
# and maximum 2 levels away
kdb ls /sw/elektra/examples/kdb\-ls \-\-min\-depth=1 \-\-max\-depth=2
#>user/sw/elektra/examples/kdb\-ls/tost/level
# list all keys below /tests/examples/kdb\-ls/test
kdb ls /tests/examples/kdb\-ls/test
#> user/tests/examples/kdb\-ls/test
#> user/tests/examples/kdb\-ls/test/fizz/buzz
#> user/tests/examples/kdb\-ls/test/foo/bar

# list all keys below /sw/elektra/examples/kdb\-ls/test
kdb ls /sw/elektra/examples/kdb\-ls/test
#>user/sw/elektra/examples/kdb\-ls/test
#>user/sw/elektra/examples/kdb\-ls/test/fizz/buzz
#>user/sw/elektra/examples/kdb\-ls/test/foo/bar
# list all keys under /tests/examples/kdb\-ls in verbose mode
kdb ls /tests/examples/kdb\-ls/ \-v
#> size of all keys in mountpoint: 5
#> size of requested keys: 5
#> user/tests/examples/kdb\-ls/test
#> user/tests/examples/kdb\-ls/test/fizz/buzz
#> user/tests/examples/kdb\-ls/test/foo/bar
#> user/tests/examples/kdb\-ls/tost
#> user/tests/examples/kdb\-ls/tost/level

# list all keys under /sw/elektra/examples/kdb\-ls in verbose mode
kdb ls /sw/elektra/examples/kdb\-ls/ \-v
#>size of all keys in mountpoint: 31
#>size of requested keys: 5
#>user/sw/elektra/examples/kdb\-ls/test
#>user/sw/elektra/examples/kdb\-ls/test/fizz/buzz
#>user/sw/elektra/examples/kdb\-ls/test/foo/bar
#>user/sw/elektra/examples/kdb\-ls/tost
#>user/sw/elektra/examples/kdb\-ls/tost/level
kdb umount /tests/examples
.
.fi
.
Expand Down
3 changes: 3 additions & 0 deletions doc/news/_preparation_next_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ Many problems were resolved with the following fixes:
[`ccode`](https://libelektra.org/plugins/ccode) instead of the “provider” `code`.
- The script [`check_bashisms.sh`](https://master.libelektra.org/tests/shell/check_bashisms.sh) should now work correctly again, if the
system uses the GNU version `find`.
- The Markdown Shell Recorder now partially supports indented code blocks.
- We fixed some problems in the [Markdown Shell Recorder](https://master.libelektra.org/tests/shell/shell_recorder/tutorial_wrapper) test
of [`kdb ls`](https://master.libelektra.org/doc/help/kdb-ls.md).


## Outlook
Expand Down
2 changes: 1 addition & 1 deletion tests/shell/shell_recorder/tutorial_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ add_msr_test (readme_msr "${CMAKE_SOURCE_DIR}/tests/shell/shell_recorder/tutoria
add_msr_test (issue_template "${CMAKE_SOURCE_DIR}/.github/ISSUE_TEMPLATE.md")
add_msr_test (tutorial_cascading "${CMAKE_SOURCE_DIR}/doc/tutorials/cascading.md")
add_msr_test (kdb-complete "${CMAKE_SOURCE_DIR}/doc/help/kdb-complete.md")
add_msr_test (kdb-ls "${CMAKE_SOURCE_DIR}/doc/help/kdb-ls.md")
add_msr_test (kdb-ls "${CMAKE_SOURCE_DIR}/doc/help/kdb-ls.md" REQUIRED_PLUGINS sync)

add_msr_test (tutorial_validation "${CMAKE_SOURCE_DIR}/doc/tutorials/validation.md" REQUIRED_PLUGINS validation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ translate()
while read -r line;
do
if grep -Eq '^\s*#>' <<< "$line"; then
output=$(sed -n 's/\s*#> \(.*\)/\1/p' <<< "$line")
output=$(sed -E -e 's/([ ]*#>$)/\1 /' -e 's/[ ]*#> (.*)/\1/' <<< "$line")
[ -z "$OUTBUF" ] && OUTBUF="$output" || OUTBUF="${OUTBUF}⏎$output"
fi

Expand Down