Skip to content

Commit c56f516

Browse files
authored
Merge pull request #552 from DannyBen/add/doc-rendering-visibility
Update mandoc/markdown library to consider private visibility setting
2 parents 57ee4ac + c49d94d commit c56f516

File tree

8 files changed

+30
-13
lines changed

8 files changed

+30
-13
lines changed

lib/bashly/concerns/completions.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def completion_generator
6262
end
6363

6464
def completion_flag_names
65-
visible_flags.map(&:name) + public_flags.map(&:short)
65+
visible_flags.map(&:name) + visible_flags.map(&:short)
6666
end
6767

6868
def completion_allowed_args

lib/bashly/libraries/render/mandoc/mandoc.gtx

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if extensible
4343
end
4444
>
4545

46-
if public_commands.any?
46+
if visible_commands.any?
4747
grouped_commands.each do |group, commands|
4848
> {{ group.gsub(/:$/, '').upcase }}
4949
> ==================================================
@@ -150,11 +150,11 @@ if dependencies.any?
150150
end
151151
end
152152

153-
if public_environment_variables.any?
153+
if visible_environment_variables.any?
154154
> ENVIRONMENT VARIABLES
155155
> ==================================================
156156
>
157-
public_environment_variables.each do |environment_variable|
157+
visible_environment_variables.each do |environment_variable|
158158
> {{ environment_variable.name.upcase }}
159159
> --------------------------------------------------
160160
>
@@ -186,7 +186,7 @@ end
186186

187187
see_also = []
188188
see_also << parents.first if parents.any?
189-
see_also += public_commands.map { |x| x.full_name.to_hyphen } if public_commands.any?
189+
see_also += visible_commands.map { |x| x.full_name.to_hyphen } if visible_commands.any?
190190
see_also += x_mandoc_see_also if x_mandoc_see_also && x_mandoc_see_also.is_a?(Array)
191191
see_also.map! do |item|
192192
item.match(/(.+)(\(\d\))/) ? "**#{$1}**#{$2}" : "**#{item}**(1)"

lib/bashly/libraries/render/markdown/markdown.gtx

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ end
6262

6363
# === Environment Variables
6464

65-
if public_environment_variables.any?
65+
if visible_environment_variables.any?
6666
> ## Environment Variables
6767
>
68-
public_environment_variables.each do |environment_variable|
68+
visible_environment_variables.each do |environment_variable|
6969
attributes = environment_variable.required || environment_variable.default
7070

7171
> #### *{{ environment_variable.name.upcase }}*

lib/bashly/script/introspection/commands.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ def default_command
7272
def grouped_commands
7373
result = {}
7474

75-
public_commands.each do |command|
75+
visible_commands.each do |command|
7676
result[command.group_string] ||= []
7777
result[command.group_string] << command
7878
next unless command.expose
7979

80-
command.public_commands.each do |subcommand|
80+
command.visible_commands.each do |subcommand|
8181
result[command.group_string] << subcommand
8282
end
8383
end

lib/bashly/script/introspection/environment_variables.rb

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ def validated_environment_variables
3131
environment_variables.select(&:validate)
3232
end
3333

34+
# Returns only public environment variables, or both public and private
35+
# environment variables if Settings.private_reveal_key is set
36+
def visible_environment_variables
37+
Settings.private_reveal_key ? environment_variables : public_environment_variables
38+
end
39+
3440
# Returns an array of all the environment_variables with a whitelist arg
3541
def whitelisted_environment_variables
3642
environment_variables.select(&:allowed)

lib/bashly/views/argument/usage.gtx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
> printf "{{ help.wrap(76).indent(4).sanitize_for_print }}\n"
55

66
if allowed
7-
> printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}\n"
7+
> printf " %s\n" "{{ strings[:allowed] % { values: allowed.join(', ') } }}"
88
end
99

1010
if default

spec/README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ Some specs have tags for convenience:
1818
- `:stable` - specs of features that rarely change
1919
- `:noci` - specs that are disabled in CI
2020

21-
For example, to run only specs that are not :slow and not :stable, run:
21+
## Useful respec commands
22+
2223

2324
```bash
25+
# smoke test; run only specs that are not :slow and not :stable
2426
$ respec tagged ~stable ~slow
27+
28+
# test examples only
29+
$ respec only examples
30+
31+
# test a specific example only
32+
$ EXAMPLE=whitelist respec only examples
33+
34+
# test only specs that changed recently, and repeat on change
35+
$ respec refactor # or respec r
2536
```
2637

2738
## Notes about Example Tests

spec/approvals/examples/command-private

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Usage:
1414
cli --version | -v
1515

1616
Commands:
17-
connect Connect to the metaverse
17+
connect Connect to the metaverse
1818

1919
+ ./cli -h
2020
cli - Sample application with private commands
@@ -25,7 +25,7 @@ Usage:
2525
cli --version | -v
2626

2727
Commands:
28-
connect Connect to the metaverse
28+
connect Connect to the metaverse
2929

3030
Options:
3131
--help, -h

0 commit comments

Comments
 (0)