markdown_exec 3.5.2 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/bats/block-type-shell-context-eval.bats +48 -0
- data/bats/block-type-ux-echo.bats +1 -1
- data/bats/block-type-ux-force.bats +1 -1
- data/bats/block-type-ux-invalid.bats +1 -1
- data/bats/block-type-ux-require.bats +1 -1
- data/bats/document-shell.bats +2 -2
- data/bats/import.bats +1 -1
- data/bats/load-vars-state-demo.bats +4 -4
- data/bin/tab_completion.sh +3 -3
- data/docs/dev/bats-document-configuration.md +1 -1
- data/docs/dev/block-type-shell-context-eval.md +52 -0
- data/docs/dev/block-type-shell-require-ux.md +6 -2
- data/docs/dev/block-type-ux-echo.md +3 -3
- data/docs/dev/block-type-ux-force.md +1 -1
- data/docs/dev/block-type-ux-require-chained.md +1 -1
- data/docs/dev/block-type-ux-require.md +2 -2
- data/docs/dev/import-parameter-symbols.md +1 -1
- data/docs/dev/linked-file.md +1 -1
- data/docs/dev/load-vars-state-demo.md +1 -1
- data/docs/dev/requiring-blocks.md +1 -1
- data/docs/dev/specs.md +2 -2
- data/docs/shell-script-evaluation.md +78 -0
- data/examples/link-blocks-vars.md +2 -2
- data/examples/linked.md +1 -1
- data/examples/linked1.md +2 -9
- data/examples/opts-blocks.md +2 -2
- data/examples/port-blocks.md +1 -1
- data/examples/variable-expansion.md +1 -1
- data/lib/cached_nested_file_reader.rb +10 -7
- data/lib/hash_delegator.rb +325 -284
- data/lib/input_sequencer.rb +4 -3
- data/lib/link_history.rb +76 -28
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/mdoc.rb +93 -65
- data/lib/menu.src.yml +5 -5
- data/lib/menu.yml +5 -5
- data/lib/ww.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 51d3a7c5749462279a14861d0f17ddb2074e9154a5daa2ba688418a524eb83ed
|
|
4
|
+
data.tar.gz: 387d31d100c9e38a955c78974a7c2679024559a36b1c540289f50a42fa6b8405
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f7521c909160d4f063875248e7d69264cb59916c659f47d1526acdc6ba8e142cffe46b5e0fd5f66c37f738d625f4e58ae3f6dd3443d1470452402e0508307bb
|
|
7
|
+
data.tar.gz: c0441396ed9b97bf4ac212451de554ec611e54d6ed15d2375812145d93f3fe7baddc42de936397eaf758f934c9a46f1fd5f90c21dd042ad625bb623a50261256
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [3.
|
|
3
|
+
## [3.6.0] - 2025-12-08
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Directive to append shell block to the context code.
|
|
8
|
+
- Directive to evaluate shell block prior to appending to context or transient code.
|
|
9
|
+
|
|
10
|
+
## [3.5.2] - 2025-12-02
|
|
4
11
|
|
|
5
12
|
### Added
|
|
6
13
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env bats
|
|
2
|
+
|
|
3
|
+
load 'test_helper'
|
|
4
|
+
|
|
5
|
+
@test 'context block appends shell code to context without executing it' {
|
|
6
|
+
BATS_OUTPUT_FILTER=A
|
|
7
|
+
BATS_SAFE=_
|
|
8
|
+
spec_mde_args_expect docs/dev/block-type-shell-context-eval.md \
|
|
9
|
+
'[context]' '[opts]' \
|
|
10
|
+
__Exit \
|
|
11
|
+
'VARS1 = 0.0__~ SHELL_V1=0.0, 1.1_~ SHELL_V2=0.0, 1.2__ context_code_ - : VARS1="0.0"_ - : SHELL_V1="${VARS1}, 1.1"_ - : SHELL_V2="${VARS1}, 1.2"'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@test 'eval block executes shell code and output becomes transient code' {
|
|
15
|
+
BATS_OUTPUT_FILTER=A
|
|
16
|
+
BATS_SAFE=_
|
|
17
|
+
spec_mde_args_expect docs/dev/block-type-shell-context-eval.md \
|
|
18
|
+
'[eval]' '[opts]' \
|
|
19
|
+
__Exit \
|
|
20
|
+
'VARS1 = 0.0__~ SHELL_V1=0.0, 2.1_~ SHELL_V2=0.0, 2.2__ context_code_ - : VARS1="0.0"'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@test 'eval-context block executes shell code and appends output to context' {
|
|
24
|
+
BATS_OUTPUT_FILTER=A
|
|
25
|
+
BATS_SAFE=_
|
|
26
|
+
spec_mde_args_expect docs/dev/block-type-shell-context-eval.md \
|
|
27
|
+
'[eval-context]' '[opts]' \
|
|
28
|
+
__Exit \
|
|
29
|
+
'VARS1 = 0.0__~ SHELL_V1=0.0, 3.1_~ SHELL_V2=0.0, 3.2__ context_code_ - : VARS1="0.0"_ - : SHELL_V1="0.0, 3.1"_ - : SHELL_V2="0.0, 3.2"'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@test 'require-context block requires context block and can access its variables' {
|
|
33
|
+
BATS_OUTPUT_FILTER=A
|
|
34
|
+
BATS_SAFE=_
|
|
35
|
+
spec_mde_args_expect docs/dev/block-type-shell-context-eval.md \
|
|
36
|
+
'[require-context]' '[opts]' \
|
|
37
|
+
__Exit \
|
|
38
|
+
'VARS1 = 0.0__~ SHELL_V1=0.0, 1.1, 4.1_~ SHELL_V2=0.0, 1.2, 4.2__ context_code_ - : VARS1="0.0"_ - : SHELL_V1="${VARS1}, 1.1"_ - : SHELL_V2="${VARS1}, 1.2"'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@test 'require-eval-context block requires eval-context block and can access its variables' {
|
|
42
|
+
BATS_OUTPUT_FILTER=A
|
|
43
|
+
BATS_SAFE=_
|
|
44
|
+
spec_mde_args_expect docs/dev/block-type-shell-context-eval.md \
|
|
45
|
+
'[require-eval-context]' '[opts]' \
|
|
46
|
+
__Exit \
|
|
47
|
+
'VARS1 = 0.0__~ SHELL_V1=0.0, 3.1, 5.1_~ SHELL_V2=0.0, 3.2, 5.2__ context_code_ - : VARS1="0.0"_ - : SHELL_V1="0.0, 3.1"_ - : SHELL_V2="0.0, 3.2"'
|
|
48
|
+
}
|
|
@@ -9,7 +9,7 @@ load 'test_helper'
|
|
|
9
9
|
|
|
10
10
|
@test 'displays inherited lines in menu' {
|
|
11
11
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-echo.md \
|
|
12
|
-
'(
|
|
12
|
+
'(menu_with_context_code)' \
|
|
13
13
|
'[[ -z $VAR ]] && VAR=markdown_exec_VAR=markdown_exec_IAB='
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -5,5 +5,5 @@ load 'test_helper'
|
|
|
5
5
|
# UX before VARS although VARS appears first
|
|
6
6
|
@test 'forces UX block before VARS block' {
|
|
7
7
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-force.md \
|
|
8
|
-
'Common_Name = Tapanuli Orangutan_
|
|
8
|
+
'Common_Name = Tapanuli Orangutan_ context_code_ - : Common_Name="Tapanuli Orangutan"_ - : Common_Name=Ruby\ Seadragon_Common_Name=Ruby Seadragon_| Common_Name | Ruby Seadragon |'
|
|
9
9
|
}
|
|
@@ -4,5 +4,5 @@ load 'test_helper'
|
|
|
4
4
|
|
|
5
5
|
@test 'reports error when automatic block has invalid YAML' {
|
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-invalid.md \
|
|
7
|
-
'_Error: HashDelegator.
|
|
7
|
+
'_Error: HashDelegator.IBNF:1¤./docs/dev/block-type-ux-invalid.md:1 - --- !ruby/object:NullResult_message: Invalid YAML_data: invalid_ -- -- '
|
|
8
8
|
}
|
|
@@ -9,6 +9,6 @@ load 'test_helper'
|
|
|
9
9
|
|
|
10
10
|
@test 'displays inherited lines in menu' {
|
|
11
11
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/block-type-ux-require.md \
|
|
12
|
-
'(
|
|
12
|
+
'(menu_with_context_code)' \
|
|
13
13
|
'SPECIES=Pongo\ tapanuliensis_GENUS=Pongo_NAME=Pongo\ tapanuliensis\ -\ Pongo_NAME2=Pongo\ tapanuliensis\ -\ Pongo_SPECIES=Pongo tapanuliensis_GENUS=Pongo_NAME=Pongo tapanuliensis - Pongo_NAME2=Pongo tapanuliensis - Pongo'
|
|
14
14
|
}
|
data/bats/document-shell.bats
CHANGED
|
@@ -4,6 +4,6 @@ load 'test_helper'
|
|
|
4
4
|
|
|
5
5
|
@test 'requires document_shell for inherited lines' {
|
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/document-shell.md \
|
|
7
|
-
--dump-
|
|
8
|
-
'
|
|
7
|
+
--dump-context-code t '* Exit' \
|
|
8
|
+
' context_code_ - : : from required_ - : : from document_shell'
|
|
9
9
|
}
|
data/bats/import.bats
CHANGED
|
@@ -20,5 +20,5 @@ load 'test_helper'
|
|
|
20
20
|
BATS_SAFE=_
|
|
21
21
|
spec_mde_args_expect docs/dev/import.md \
|
|
22
22
|
--list-block-message id --list-blocks \
|
|
23
|
-
'
|
|
23
|
+
'IBNF:1¤./docs/dev/specs-import.md:0_IBNF:4¤./docs/dev/specs-import.md:3_IBNF:7¤./docs/dev/specs-import.md:6'
|
|
24
24
|
}
|
|
@@ -4,23 +4,23 @@ load 'test_helper'
|
|
|
4
4
|
|
|
5
5
|
@test 'displays document initial state' {
|
|
6
6
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
|
|
7
|
-
'var1 = line1_var3 = line6_
|
|
7
|
+
'var1 = line1_var3 = line6_ context_code_ - : var1="line1"_ - : var3="line6"_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
@test 'applies load-mode-default to inherited state' {
|
|
11
11
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
|
|
12
12
|
load-mode-default \
|
|
13
|
-
'var1 = line1_var3 = line6_
|
|
13
|
+
'var1 = line1_var3 = line6_ context_code_ - : var1="line1"_ - : var3="line6"_ context_code_ - : var1="line1"_ - : var3="line6"_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
@test 'appends to inherited state with load-mode-append' {
|
|
17
17
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
|
|
18
18
|
load-mode-append \
|
|
19
|
-
'var1 = line1_var3 = line6_
|
|
19
|
+
'var1 = line1_var3 = line6_ context_code_ - : var1="line1"_ - : var3="line6"_ context_code_ - : var1="line1"_ - : var3="line6"_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
@test 'replaces inherited state with load-mode-replace' {
|
|
23
23
|
spec_mde_xansi_dname_doc_blocks_expect docs/dev/load-vars-state-demo.md \
|
|
24
24
|
load-mode-replace \
|
|
25
|
-
'var1 = line1_var3 = line6_
|
|
25
|
+
'var1 = line1_var3 = line6_ context_code_ - : var1="line1"_ - : var3="line6"_ context_code_ - : # line 1_ - : var1=line2_ - : # line 3_ - : var2=line4_ - : # line 5_ LOAD BLOCK STATE MODIFICATION DEMO__This document demonstrates how a LOAD block can modify_the inherited state that was initially set by VARS_blocks.__First, establish baseline variables using a VARS block:__Use a LOAD block to modify the initial state:__load-mode-default_load-mode-append_load-mode-replace'
|
|
26
26
|
}
|
data/bin/tab_completion.sh
CHANGED
|
@@ -44,7 +44,7 @@ _mde() {
|
|
|
44
44
|
|
|
45
45
|
--dump-inherited-dependencies) COMPREPLY="f"; return 0 ;;
|
|
46
46
|
|
|
47
|
-
--dump-
|
|
47
|
+
--dump-context-code) COMPREPLY="f"; return 0 ;;
|
|
48
48
|
|
|
49
49
|
--dump-menu-blocks) COMPREPLY="f"; return 0 ;;
|
|
50
50
|
|
|
@@ -110,7 +110,7 @@ _mde() {
|
|
|
110
110
|
# present matching option names
|
|
111
111
|
#
|
|
112
112
|
if [[ ${cur} == -* ]] ; then
|
|
113
|
-
opts=("--block-name" "--blocks" "--config" "--debug" "--dig" "--dump-blocks-in-file" "--dump-delegate-object" "--dump-dependencies" "--dump-inherited-block-names" "--dump-inherited-dependencies" "--dump-
|
|
113
|
+
opts=("--block-name" "--blocks" "--config" "--debug" "--dig" "--dump-blocks-in-file" "--dump-delegate-object" "--dump-dependencies" "--dump-inherited-block-names" "--dump-inherited-dependencies" "--dump-context-code" "--dump-menu-blocks" "--dump-selected-block" "--execute-in-own-window" "--exit" "--filename" "--find" "--find-path" "--help" "--history" "--how" "--list-blocks" "--list-blocks-eval" "--list-blocks-message" "--list-blocks-type" "--list-count" "--list-default-env" "--list-default-yaml" "--list-docs" "--format" "--list-recent-output" "--list-recent-scripts" "--load-code" "--mine" "--open" "--output-script" "--output-stdout" "--path" "--pause-after-script-execution" "--probe" "--publish-document-file-mode" "--publish-document-file-name" "--pwd" "--run-last-script" "--sift" "--tab-completions" "--user-must-approve" "--version" "--display-level")
|
|
114
114
|
COMPREPLY=( $(compgen -W "$(printf "'%s' " "${opts[@]}")" -- "${cur}") )
|
|
115
115
|
|
|
116
116
|
return 0
|
|
@@ -145,7 +145,7 @@ _mde() {
|
|
|
145
145
|
|
|
146
146
|
--dump-inherited-dependencies) COMPREPLY=".BOOL."; return 0 ;;
|
|
147
147
|
|
|
148
|
-
--dump-
|
|
148
|
+
--dump-context-code) COMPREPLY=".BOOL."; return 0 ;;
|
|
149
149
|
|
|
150
150
|
--dump-menu-blocks) COMPREPLY=".BOOL."; return 0 ;;
|
|
151
151
|
|
|
@@ -3,7 +3,7 @@ divider4_center: false
|
|
|
3
3
|
|
|
4
4
|
dump_blocks_in_file: false # Dump BlocksInFile (stage 1)
|
|
5
5
|
dump_delegate_object: false # Dump @delegate_object
|
|
6
|
-
|
|
6
|
+
dump_context_code: false # Dump inherited lines
|
|
7
7
|
dump_menu_blocks: false # Dump MenuBlocks (stage 2)
|
|
8
8
|
dump_selected_block: false # Dump selected block
|
|
9
9
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
```vars :(document_vars)
|
|
2
|
+
VARS1: '0.0'
|
|
3
|
+
```
|
|
4
|
+
/ these lines are appended to the context; print values
|
|
5
|
+
```bash :[context] +print-values @context
|
|
6
|
+
SHELL_V1="${VARS1}, 1.1"
|
|
7
|
+
SHELL_V2="${VARS1}, 1.2"
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
/ these lines are executed and the output is the transient code; print values
|
|
11
|
+
```bash :[eval] +print-values @eval
|
|
12
|
+
echo "SHELL_V1=\"${VARS1}, 2.1\""
|
|
13
|
+
echo "SHELL_V2=\"${VARS1}, 2.2\""
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
/ these lines are executed and the output is appended to the context; print values
|
|
17
|
+
```bash :[eval-context] +print-values @eval @context
|
|
18
|
+
echo "SHELL_V1=\"${VARS1}, 3.1\""
|
|
19
|
+
echo "SHELL_V2=\"${VARS1}, 3.2\""
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
/ require block setting context; set transient code; print values
|
|
23
|
+
```bash :[require-context] +[context]
|
|
24
|
+
SHELL_V1="${SHELL_V1}, 4.1"
|
|
25
|
+
SHELL_V2="${SHELL_V2}, 4.2"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
/ require block setting context from eval output; set transient code; print values
|
|
29
|
+
```bash :[require-eval-context] +[eval-context]
|
|
30
|
+
SHELL_V1="${SHELL_V1}, 5.1"
|
|
31
|
+
SHELL_V2="${SHELL_V2}, 5.2"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
/ these values are present while the block is being evaluated
|
|
35
|
+
```bash :print-values
|
|
36
|
+
echo "~ SHELL_V1=$SHELL_V1"
|
|
37
|
+
echo "~ SHELL_V2=$SHELL_V2"
|
|
38
|
+
```
|
|
39
|
+
```opts :[opts]
|
|
40
|
+
dump_context_code: true
|
|
41
|
+
```
|
|
42
|
+
/| Variable| Value
|
|
43
|
+
/| -| -
|
|
44
|
+
/| VARS1| ${VARS1}
|
|
45
|
+
/| SHELL_V1| ${SHELL_V1}
|
|
46
|
+
/| SHELL_V2| ${SHELL_V2}
|
|
47
|
+
@import bats-document-configuration.md
|
|
48
|
+
```opts :(document_opts)
|
|
49
|
+
/dump_context_code: true
|
|
50
|
+
/menu_for_saved_lines: true
|
|
51
|
+
menu_with_exit: true
|
|
52
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/ No blocks are evaluated at initialization.
|
|
2
2
|
/ When the shell block is activated, the UX block is required.
|
|
3
|
-
```bash :require-a-UX-block +[ux1]
|
|
3
|
+
```bash :require-a-UX-block +[ux1] @context
|
|
4
4
|
ENTITY='Mythical Monkey'
|
|
5
5
|
```
|
|
6
6
|
/ Display variables set in the UX block.
|
|
@@ -15,4 +15,8 @@ echo:
|
|
|
15
15
|
init: false
|
|
16
16
|
readonly: true
|
|
17
17
|
```
|
|
18
|
-
@import bats-document-configuration.md
|
|
18
|
+
@import bats-document-configuration.md
|
|
19
|
+
/```opts :(document_opts)
|
|
20
|
+
/dump_context_code: true
|
|
21
|
+
/menu_for_saved_lines: true
|
|
22
|
+
/```
|
|
@@ -4,8 +4,8 @@ echo: $(basename `pwd`)
|
|
|
4
4
|
name: VAR
|
|
5
5
|
```
|
|
6
6
|
/ This block is not visible. Execute to display the inherited lines for testing.
|
|
7
|
-
```opts :(
|
|
8
|
-
|
|
7
|
+
```opts :(menu_with_context_code)
|
|
8
|
+
menu_with_context_code: true
|
|
9
9
|
```
|
|
10
10
|
/ This block is not visible. Execute to set a new value, displayed by the block above.
|
|
11
11
|
```ux :(VAR_has_count)
|
|
@@ -22,6 +22,6 @@ echo: $VAR$VAR
|
|
|
22
22
|
name: IAB
|
|
23
23
|
```
|
|
24
24
|
```opts :(document_opts)
|
|
25
|
-
|
|
25
|
+
menu_with_context_code: false
|
|
26
26
|
```
|
|
27
27
|
@import bats-document-configuration.md
|
|
@@ -29,7 +29,7 @@ ENTITY='Pongo tapanuliensis,Pongo'
|
|
|
29
29
|
```
|
|
30
30
|
/
|
|
31
31
|
/ This block is not visible. Execute to display the inherited lines for testing.
|
|
32
|
-
```opts :(
|
|
33
|
-
|
|
32
|
+
```opts :(menu_with_context_code)
|
|
33
|
+
menu_with_context_code: true
|
|
34
34
|
```
|
|
35
35
|
@import bats-document-configuration.md
|
data/docs/dev/linked-file.md
CHANGED
data/docs/dev/specs.md
CHANGED
|
@@ -72,7 +72,7 @@ dump_blocks_in_file: false
|
|
|
72
72
|
dump_dependencies: false
|
|
73
73
|
dump_inherited_block_names: false
|
|
74
74
|
dump_inherited_dependencies: false
|
|
75
|
-
|
|
75
|
+
dump_context_code: false
|
|
76
76
|
dump_menu_blocks: false
|
|
77
77
|
```
|
|
78
78
|
|
|
@@ -80,5 +80,5 @@ dump_menu_blocks: false
|
|
|
80
80
|
```opts :(document_opts) +(disable_dump_*)
|
|
81
81
|
menu_note_color: 'plain'
|
|
82
82
|
menu_with_exit: true
|
|
83
|
-
|
|
83
|
+
menu_with_context_code: false
|
|
84
84
|
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/ v2025-12-07
|
|
2
|
+
/---
|
|
3
|
+
|
|
4
|
+
# App configuration
|
|
5
|
+
|
|
6
|
+
## CLI loading of app configuration
|
|
7
|
+
|
|
8
|
+
A file is read into the app configuration using the `--config` command line option.
|
|
9
|
+
|
|
10
|
+
## Per-document app configuration
|
|
11
|
+
|
|
12
|
+
An OPTS block that is automatically loaded when the document is loaded, modifies the app configuration.
|
|
13
|
+
|
|
14
|
+
## Activated block effect on app configuration
|
|
15
|
+
|
|
16
|
+
An OPTS block that is activated by the user modifies the app configuration.
|
|
17
|
+
|
|
18
|
+
/---
|
|
19
|
+
|
|
20
|
+
# Context code
|
|
21
|
+
|
|
22
|
+
The context code is empty when the app starts.
|
|
23
|
+
|
|
24
|
+
## CLI loading of context code
|
|
25
|
+
|
|
26
|
+
A file is loaded as the context code using the `--load-code` command line option.
|
|
27
|
+
|
|
28
|
+
## Automatic blocks
|
|
29
|
+
|
|
30
|
+
Some blocks are automatically processed when the document is loaded.
|
|
31
|
+
|
|
32
|
+
A VARS block that is automatically loaded when the document is loaded, is appended to the context code. Display variables set per the app configuration.
|
|
33
|
+
|
|
34
|
+
A UX block that is automatically loaded, is appended to the context code. Display variables set per the app configuration.
|
|
35
|
+
|
|
36
|
+
A shell block that is automatically loaded is appended to the context code.
|
|
37
|
+
|
|
38
|
+
## Activated VARS block
|
|
39
|
+
|
|
40
|
+
The variables named, converted to shell code to set to the corresponding values, are appended to the context code.
|
|
41
|
+
The app's environment is also updated with the specified variables and values.
|
|
42
|
+
|
|
43
|
+
## Activated UX block
|
|
44
|
+
|
|
45
|
+
Variables named, converted to shell code to set to the corresponding values, are appended to the context code.
|
|
46
|
+
The app's environment is also updated with the specified variables and values.
|
|
47
|
+
|
|
48
|
+
## Activated shell block
|
|
49
|
+
|
|
50
|
+
The activated and required shell blocks marked as context are appended to the context code.
|
|
51
|
+
|
|
52
|
+
/---
|
|
53
|
+
|
|
54
|
+
# Transient code
|
|
55
|
+
|
|
56
|
+
The transient code is empty between block activations.
|
|
57
|
+
|
|
58
|
+
## Activated shell block
|
|
59
|
+
|
|
60
|
+
The required blocks, the transient code for this block, are executed in a shell script and its output is displayed and logged.
|
|
61
|
+
|
|
62
|
+
/---
|
|
63
|
+
|
|
64
|
+
# Shell script composition
|
|
65
|
+
|
|
66
|
+
The shell script is composed of the context code followed by the transient code. The context code will include variables or context code in the required blocks.
|
|
67
|
+
|
|
68
|
+
## Script output
|
|
69
|
+
|
|
70
|
+
The output of the executed script (STDOUT and STDERR) is displayed in the console and logged to a file.
|
|
71
|
+
|
|
72
|
+
/---
|
|
73
|
+
|
|
74
|
+
## Shell block activation
|
|
75
|
+
|
|
76
|
+
The activated and required shell blocks, not marked as context by default, are are the transient code.
|
|
77
|
+
The script is composed and executed.
|
|
78
|
+
Display shell output per the app configuration.
|
|
@@ -22,7 +22,7 @@ View the current inherited lines.
|
|
|
22
22
|
The inherited lines can also be displayed automatically within the menu by enabling this option:
|
|
23
23
|
|
|
24
24
|
```opts
|
|
25
|
-
|
|
25
|
+
menu_with_context_code: true
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Setting Variables in the Inherited Lines
|
|
@@ -80,7 +80,7 @@ This Link block (YAML) appends the output of the Bash code to the inherited line
|
|
|
80
80
|
@import example-document-opts.md
|
|
81
81
|
```opts :(document_opts)
|
|
82
82
|
execute_in_own_window: false
|
|
83
|
-
|
|
83
|
+
menu_with_context_code: false
|
|
84
84
|
output_execution_report: false
|
|
85
85
|
output_execution_summary: false
|
|
86
86
|
pause_after_script_execution: true
|
data/examples/linked.md
CHANGED
|
@@ -2,7 +2,7 @@ Demonstrate setting variable values interactively for use in generated scripts.
|
|
|
2
2
|
|
|
3
3
|
@import example-document-opts.md
|
|
4
4
|
```opts :(document_opts)
|
|
5
|
-
|
|
5
|
+
menu_with_context_code: true
|
|
6
6
|
pause_after_script_execution: false
|
|
7
7
|
user_must_approve: false
|
|
8
8
|
```
|
data/examples/linked1.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
@import example-document-opts.md
|
|
4
4
|
```opts :(document_opts)
|
|
5
|
-
|
|
5
|
+
dump_context_code: true
|
|
6
6
|
pause_after_script_execution: false
|
|
7
7
|
user_must_approve: false
|
|
8
8
|
```
|
|
@@ -40,12 +40,5 @@ file: examples/linked2.md
|
|
|
40
40
|
```link :linked2_import_vars +(vars2)
|
|
41
41
|
file: examples/linked2.md
|
|
42
42
|
vars:
|
|
43
|
-
page2_var_via_environment:
|
|
44
|
-
page2_var_via_environment1: ${d1_v1}
|
|
45
|
-
page2_var_via_environment2: for_page2_from_page1_via_current_environment
|
|
43
|
+
page2_var_via_environment: for_page2_from_page1_via_current_environment
|
|
46
44
|
```
|
|
47
|
-
```vars :(document_vars)
|
|
48
|
-
d1_v1: 1
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
```
|
data/examples/opts-blocks.md
CHANGED
|
@@ -38,7 +38,7 @@ note 4
|
|
|
38
38
|
```opts
|
|
39
39
|
dump_blocks_in_file: true # Dump BlocksInFile (stage 1)
|
|
40
40
|
dump_delegate_object: true # Dump @delegate_object
|
|
41
|
-
|
|
41
|
+
dump_context_code: true # Dump inherited lines
|
|
42
42
|
dump_menu_blocks: true # Dump MenuBlocks (stage 2)
|
|
43
43
|
dump_selected_block: true # Dump selected block
|
|
44
44
|
```
|
|
@@ -46,7 +46,7 @@ dump_selected_block: true # Dump selected block
|
|
|
46
46
|
```opts
|
|
47
47
|
dump_blocks_in_file: false # Dump BlocksInFile (stage 1)
|
|
48
48
|
dump_delegate_object: false # Dump @delegate_object
|
|
49
|
-
|
|
49
|
+
dump_context_code: false # Dump inherited lines
|
|
50
50
|
dump_menu_blocks: false # Dump MenuBlocks (stage 2)
|
|
51
51
|
dump_selected_block: false # Dump selected block
|
|
52
52
|
```
|
data/examples/port-blocks.md
CHANGED
|
@@ -75,7 +75,7 @@ divider4_center: false
|
|
|
75
75
|
|
|
76
76
|
dump_blocks_in_file: false # Dump BlocksInFile (stage 1)
|
|
77
77
|
dump_delegate_object: false # Dump @delegate_object
|
|
78
|
-
|
|
78
|
+
dump_context_code: false # Dump inherited lines
|
|
79
79
|
dump_menu_blocks: false # Dump MenuBlocks (stage 2)
|
|
80
80
|
dump_selected_block: false # Dump selected block
|
|
81
81
|
|
|
@@ -53,11 +53,12 @@ class CachedNestedFileReader
|
|
|
53
53
|
def error_handler(name = '', opts = {})
|
|
54
54
|
Exceptions.error_handler(
|
|
55
55
|
"CachedNestedFileReader.#{name} -- #{$!}",
|
|
56
|
+
caller.deref(6),
|
|
56
57
|
opts
|
|
57
58
|
)
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
def warn_format(name, message, opts = {})
|
|
61
|
+
def self.warn_format(name, message, opts = {})
|
|
61
62
|
Exceptions.warn_format(
|
|
62
63
|
"CachedNestedFileReader.#{name} -- #{message}",
|
|
63
64
|
opts
|
|
@@ -113,7 +114,7 @@ class CachedNestedFileReader
|
|
|
113
114
|
|
|
114
115
|
# apply substitutions to the @import line
|
|
115
116
|
line_sub1 = apply_line_substitutions(line, substitutions,
|
|
116
|
-
|
|
117
|
+
use_template_delimiters)
|
|
117
118
|
|
|
118
119
|
# parse the @import line
|
|
119
120
|
Regexp.new(@import_directive_line_pattern) =~ line_sub1
|
|
@@ -197,8 +198,10 @@ class CachedNestedFileReader
|
|
|
197
198
|
wwt :read_document_code, 'processed_lines:', processed_lines
|
|
198
199
|
@file_cache[cache_key] = processed_lines
|
|
199
200
|
rescue Errno::ENOENT => err
|
|
200
|
-
warn_format(
|
|
201
|
-
|
|
201
|
+
CachedNestedFileReader.warn_format(
|
|
202
|
+
'readlines', "#{err} @@ #{context}",
|
|
203
|
+
{ abort: true }
|
|
204
|
+
)
|
|
202
205
|
rescue StandardError
|
|
203
206
|
wwe $!
|
|
204
207
|
end
|
|
@@ -327,7 +330,7 @@ class CachedNestedFileReader
|
|
|
327
330
|
# Matches the beginning of the first line as '#!' - anything after that matches a shebang
|
|
328
331
|
def is_shebang_line?(line, is_first_line)
|
|
329
332
|
return false unless is_first_line
|
|
330
|
-
|
|
333
|
+
|
|
331
334
|
line.start_with?('#!')
|
|
332
335
|
end
|
|
333
336
|
end
|
|
@@ -542,7 +545,7 @@ class CachedNestedFileReaderTest < Minitest::Test
|
|
|
542
545
|
)
|
|
543
546
|
|
|
544
547
|
result = reader_with_hide.readlines(file_with_shebang.path).map(&:to_s)
|
|
545
|
-
assert_equal [
|
|
548
|
+
assert_equal %w[Line1 Line2], result, 'Shebang line should be filtered when hide_shebang is true'
|
|
546
549
|
|
|
547
550
|
file_with_shebang.close
|
|
548
551
|
file_with_shebang.unlink
|
|
@@ -633,7 +636,7 @@ class CachedNestedFileReaderTest < Minitest::Test
|
|
|
633
636
|
)
|
|
634
637
|
|
|
635
638
|
result = reader_with_hide.readlines(file_without_shebang.path).map(&:to_s)
|
|
636
|
-
assert_equal [
|
|
639
|
+
assert_equal %w[Line1 Line2 Line3], result, 'File without shebang should work normally'
|
|
637
640
|
|
|
638
641
|
file_without_shebang.close
|
|
639
642
|
file_without_shebang.unlink
|