Skip to content

Commit a1c8e09

Browse files
committed
improve manpage template
1 parent 4de8f4d commit a1c8e09

File tree

19 files changed

+216
-140
lines changed

19 files changed

+216
-140
lines changed

examples/render-mandoc/README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ args:
3535
- name: source
3636
required: true
3737
allowed: [server1, server2]
38-
repeatable: true
3938
help: Source to download from
4039
- name: target
4140
help: "Target filename (default: same as source)"
41+
repeatable: true
4242

4343
flags:
4444
- long: --force
@@ -62,32 +62,34 @@ NAME
6262
download - Sample application
6363
6464
SYNOPSIS
65-
download SOURCE... [TARGET] OPTIONS
65+
download SOURCE [TARGET...] OPTIONS
6666
6767
DESCRIPTION
6868
Sample application
6969
7070
ARGUMENTS
71-
SOURCE Source to download from
71+
SOURCE
72+
Source to download from
7273
73-
• Required
74+
• Required
7475
75-
• Repeatable
76+
• Allowed Values: server1, server2
7677
77-
• Allowed Values: server1, server2
78+
TARGET
79+
Target filename (default: same as source)
7880
79-
TARGET Target filename (default: same as source)
81+
• Repeatable
8082
8183
OPTIONS
82-
--force, -f
83-
Overwrite existing files
84+
--force, -f
85+
Overwrite existing files
8486
85-
--debug, -d
86-
Show debug information
87+
--debug, -d
88+
Show debug information
8789
8890
DEPENDENCIES
89-
aws-cli
90-
Download from <https://aws.amazon.com/cli/>
91+
aws-cli
92+
Download from <https://aws.amazon.com/cli/>
9193
9294
ISSUE TRACKER
9395
Report issues at <https://github.com/lanalang/smallville>

examples/render-mandoc/docs/download.1

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,34 @@
2121
\f[B]download\f[R] - Sample application
2222
.SH SYNOPSIS
2323
.PP
24-
\f[B]download\f[R] SOURCE...
25-
[TARGET] OPTIONS
24+
\f[B]download\f[R] SOURCE [TARGET...]
25+
OPTIONS
2626
.SH DESCRIPTION
2727
.PP
2828
Sample application
2929
.SH ARGUMENTS
30-
.TP
31-
\f[B]SOURCE\f[R]
30+
.SS SOURCE
31+
.PP
3232
Source to download from
33-
.RS
3433
.IP \[bu] 2
3534
\f[I]Required\f[R]
3635
.IP \[bu] 2
37-
\f[I]Repeatable\f[R]
38-
.IP \[bu] 2
3936
Allowed Values: \f[B]server1, server2\f[R]
40-
.RE
41-
.TP
42-
\f[B]TARGET\f[R]
37+
.SS TARGET
38+
.PP
4339
Target filename (default: same as source)
40+
.IP \[bu] 2
41+
\f[I]Repeatable\f[R]
4442
.SH OPTIONS
45-
.TP
46-
\f[B]--force, -f\f[R]
43+
.SS --force, -f
44+
.PP
4745
Overwrite existing files
48-
.TP
49-
\f[B]--debug, -d\f[R]
46+
.SS --debug, -d
47+
.PP
5048
Show debug information
5149
.SH DEPENDENCIES
52-
.TP
53-
\f[B]aws-cli\f[R]
50+
.SS aws-cli
51+
.PP
5452
Download from <https://aws.amazon.com/cli/>
5553
.SH ISSUE TRACKER
5654
.PP

examples/render-mandoc/docs/download.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ NAME
1010
SYNOPSIS
1111
==================================================
1212

13-
**download** SOURCE... [TARGET] [OPTIONS]
13+
**download** SOURCE [TARGET...] [OPTIONS]
1414

1515
DESCRIPTION
1616
==================================================
@@ -21,35 +21,47 @@ Sample application
2121
ARGUMENTS
2222
==================================================
2323

24-
**SOURCE**
25-
: Source to download from
24+
SOURCE
25+
--------------------------------------------------
2626

27-
- *Required*
28-
- *Repeatable*
29-
- Allowed Values: **server1, server2**
27+
Source to download from
3028

31-
**TARGET**
32-
: Target filename (default: same as source)
29+
- *Required*
30+
- Allowed Values: **server1, server2**
3331

32+
TARGET
33+
--------------------------------------------------
34+
35+
Target filename (default: same as source)
36+
37+
- *Repeatable*
3438

3539
OPTIONS
3640
==================================================
3741

38-
**--force, -f**
39-
: Overwrite existing files
42+
--force, -f
43+
--------------------------------------------------
44+
45+
Overwrite existing files
46+
4047

48+
--debug, -d
49+
--------------------------------------------------
4150

42-
**--debug, -d**
43-
: Show debug information
51+
Show debug information
4452

4553

4654
DEPENDENCIES
4755
==================================================
4856

49-
**aws-cli**
50-
: Download from \<https://aws.amazon.com/cli/\>
57+
aws-cli
58+
--------------------------------------------------
59+
60+
Download from \<https://aws.amazon.com/cli/\>
5161

5262

5363
# ISSUE TRACKER
5464

55-
Report issues at <https://github.com/lanalang/smallville>
65+
66+
67+
Report issues at \<https://github.com/lanalang/smallville\>

examples/render-mandoc/src/bashly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ args:
1717
- name: source
1818
required: true
1919
allowed: [server1, server2]
20-
repeatable: true
2120
help: Source to download from
2221
- name: target
2322
help: "Target filename (default: same as source)"
23+
repeatable: true
2424

2525
flags:
2626
- long: --force

lib/bashly/commands/render.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def watch
8787
end
8888

8989
def watchables
90-
@watchables ||= [Settings.config_path, args['SOURCE']]
90+
@watchables ||= [Settings.config_path, render_source.path]
9191
end
9292
end
9393
end

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

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Reference: https://linux.die.net/man/5/pandoc_markdown
22

33
if version
4-
> % {{ full_name.to_hyphen }}(1) Version {{ version }} | {{ summary }}
4+
> % {{ full_name.to_hyphen }}(1) Version {{ version }} | {{ summary }}
55
else
6-
> % {{ full_name.to_hyphen }}(1) | {{ summary }}
6+
> % {{ full_name.to_hyphen }}(1) | {{ summary }}
77
end
8-
> % {{ x_mandoc_authors }}
8+
9+
> % {{ x_mandoc_authors&.for_manpage }}
910
> % {{ Date.today.strftime "%B %Y" }}
1011
>
1112

@@ -48,8 +49,10 @@ if public_commands.any?
4849
> ==================================================
4950
>
5051
commands.each do |subcommand|
51-
> **{{ subcommand.full_name }}**(1)
52-
> : {{ subcommand.summary.for_manpage }}
52+
> {{ subcommand.full_name }}
53+
> --------------------------------------------------
54+
>
55+
> {{ subcommand.summary.for_manpage }}
5356
>
5457
end
5558
>
@@ -61,34 +64,38 @@ if args.any?
6164
> ==================================================
6265
>
6366
args.each do |arg|
64-
> **{{ arg.name.upcase }}**
65-
> :{{ arg.help.for_manpage.indent(4) }}
67+
> {{ arg.name.upcase }}
68+
> --------------------------------------------------
69+
>
70+
> {{ arg.help.for_manpage }}
6671
>
6772
if arg.required
68-
> - *Required*
73+
> - *Required*
6974
end
7075
if arg.repeatable
71-
> - *Repeatable*
76+
> - *Repeatable*
7277
end
7378
if arg.default
74-
> - Default Value: **{{ arg.default }}**
79+
> - Default Value: **{{ arg.default }}**
7580
end
7681
if arg.allowed
77-
> - Allowed Values: **{{ arg.allowed.join(', ') }}**
78-
end
82+
> - Allowed Values: **{{ arg.allowed.join(', ') }}**
83+
end
7984
>
8085
end
8186

8287
if catch_all.label && catch_all.help
83-
> **{{ catch_all.label }}**
88+
> {{ catch_all.label }}
89+
> --------------------------------------------------
90+
>
8491
if catch_all.help
85-
> :{{ catch_all.help.for_manpage.indent(4) }}
92+
> {{ catch_all.help.for_manpage }}
8693
>
8794
end
8895
>
8996

9097
if catch_all.required?
91-
> - *Required*
98+
> - *Required*
9299
>
93100
end
94101
end
@@ -99,24 +106,26 @@ if flags.any?
99106
> ==================================================
100107
>
101108
flags.each do |flag|
102-
> **{{ flag.usage_string }}**
103-
> :{{ flag.help.for_manpage.indent(4) }}
109+
> {{ flag.usage_string }}
110+
> --------------------------------------------------
111+
>
112+
> {{ flag.help.for_manpage }}
104113
>
105114

106115
if flag.required
107-
> - *Required*
116+
> - *Required*
108117
end
109118
if flag.repeatable
110-
> - *Repeatable*
119+
> - *Repeatable*
111120
end
112121
if flag.default
113-
> - Default Value: **{{ flag.default }}**
122+
> - Default Value: **{{ flag.default }}**
114123
end
115124
if flag.allowed
116-
> - Allowed Values: **{{ flag.allowed.join(', ') }}**
125+
> - Allowed Values: **{{ flag.allowed.join(', ') }}**
117126
end
118127
if flag.conflicts
119-
> - Conflicts With: **{{ flag.conflicts.join(', ') }}**
128+
> - Conflicts With: **{{ flag.conflicts.join(', ') }}**
120129
end
121130
>
122131
end
@@ -127,9 +136,11 @@ if dependencies.any?
127136
> ==================================================
128137
>
129138
dependencies.each do |dependency|
130-
> **{{ dependency.commands.join ', ' }}**
139+
> {{ dependency.commands.join ', ' }}
140+
> --------------------------------------------------
141+
>
131142
if dependency.help
132-
> :{{ dependency.help.for_manpage.indent(4) }}
143+
> {{ dependency.help.for_manpage }}
133144
>
134145
end
135146
>
@@ -141,16 +152,17 @@ if public_environment_variables.any?
141152
> ==================================================
142153
>
143154
public_environment_variables.each do |environment_variable|
144-
> **{{ environment_variable.name.upcase }}**
155+
> {{ environment_variable.name.upcase }}
156+
> --------------------------------------------------
145157
>
146-
> :{{ environment_variable.help.for_manpage.indent(4) }}
158+
> {{ environment_variable.help.for_manpage }}
147159
>
148160

149161
if environment_variable.required
150-
> - *Required*
162+
> - *Required*
151163
end
152164
if environment_variable.default
153-
> - Default Value: **{{ environment_variable.default }}**
165+
> - Default Value: **{{ environment_variable.default }}**
154166
end
155167
>
156168
end
@@ -177,5 +189,5 @@ if public_commands.any?
177189
>
178190
end
179191

180-
= x_mandoc_footer
192+
= x_mandoc_footer&.for_manpage
181193
>

0 commit comments

Comments
 (0)