Skip to content

Commit 66d798f

Browse files
authored
Merge pull request #434 from DannyBen/add/mandoc-custom-see-also
Add support for custom "See Also" in mandoc renderer (`x_mandoc_see_also`)
2 parents 4856197 + 067a2cc commit 66d798f

File tree

28 files changed

+77
-42
lines changed

28 files changed

+77
-42
lines changed

examples/render-mandoc/docs/download.1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
. ftr VB CB
1515
. ftr VBI CBI
1616
.\}
17-
.TH "download" "1" "August 2023" "Version 0.1.0" "Sample application"
17+
.TH "download" "1" "September 2023" "Version 0.1.0" "Sample application"
1818
.hy
1919
.SH NAME
2020
.PP
@@ -50,6 +50,9 @@ Show debug information
5050
.SS aws-cli
5151
.PP
5252
Download from <https://aws.amazon.com/cli/>
53+
.SH SEE ALSO
54+
.PP
55+
\f[B]docker\f[R](1), \f[B]docker-compose.yml\f[R](5)
5356
.SH ISSUE TRACKER
5457
.PP
5558
Report issues at <https://github.com/lanalang/smallville>

examples/render-mandoc/docs/download.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% download(1) Version 0.1.0 | Sample application
22
% Lana Lang
3-
% August 2023
3+
% September 2023
44

55
NAME
66
==================================================
@@ -60,5 +60,10 @@ aws-cli
6060
Download from \<https://aws.amazon.com/cli/\>
6161

6262

63+
SEE ALSO
64+
==================================================
65+
66+
**docker**(1), **docker-compose.yml**(5)
67+
6368
# ISSUE TRACKER
6469
Report issues at \<https://github.com/lanalang/smallville\>

examples/render-mandoc/src/bashly.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ x_mandoc_authors: Lana Lang
88
x_mandoc_footer: |-
99
# ISSUE TRACKER
1010
Report issues at <https://github.com/lanalang/smallville>
11+
x_mandoc_see_also:
12+
- docker
13+
- docker-compose.yml(5)
1114

1215
dependencies:
1316
aws-cli: Download from <https://aws.amazon.com/cli/>

lib/bashly/libraries/render/mandoc/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@ Add an authors string to your man pages.
4343
```yaml
4444
x_mandoc_authors: Lana Lang
4545
```
46+
47+
### See Also: `x_mandoc_see_also`
48+
49+
Adds additional pages to the `SEE ALSO` section, in addition to the
50+
pages that are added automatically (like the parent command, and
51+
sub commands).
52+
53+
This property should be an array of strings. You can optionally add
54+
a section number in parentheses. If not provided, `(1)` will be used
55+
as default.
56+
57+
#### Example
58+
59+
```yaml
60+
x_mandoc_see_also:
61+
- docker
62+
- docker-compose.yml(5)
63+
```

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,19 @@ if examples
181181
>
182182
end
183183

184-
if public_commands.any? || parents.any?
184+
see_also = []
185+
see_also << parents.first if parents.any?
186+
see_also += public_commands.map { |x| x.full_name.to_hyphen } if public_commands.any?
187+
see_also += x_mandoc_see_also if x_mandoc_see_also && x_mandoc_see_also.is_a?(Array)
188+
see_also.map! do |item|
189+
item.match(/(.+)(\(\d\))/) ? "**#{$1}**#{$2}" : "**#{item}**(1)"
190+
end
191+
192+
if see_also.any?
185193
> SEE ALSO
186194
> ==================================================
187195
>
188-
if parents.any?
189-
> **{{ parents.first }}**(1)
190-
end
191-
= public_commands.map { |x| "**#{x.full_name.to_hyphen}**(1)" }.join ', '
196+
= see_also.join ', '
192197
>
193198
end
194199

spec/approvals/examples/render-mandoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ DEPENDENCIES
3535
aws-cli
3636
Download from <https://aws.amazon.com/cli/>
3737

38+
SEE ALSO
39+
docker(1), docker-compose.yml(5)
40+
3841
ISSUE TRACKER
3942
Report issues at <https://github.com/lanalang/smallville>
4043

4144
AUTHORS
4245
Lana Lang.
4346

44-
Version 0.1.0 August 2023 download(1)
47+
Version 0.1.0 September 2023 download(1)

spec/approvals/libraries/render/mandoc/render-1-download.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ EXAMPLES
2929
download example.com ./output -f
3030

3131

32-
Version 0.1.0 August 2023 download(1)
32+
Version 0.1.0 MONTH YEAR download(1)

spec/approvals/libraries/render/mandoc/render-1-download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% download(1) Version 0.1.0 | Sample minimal application without commands
22
%
3-
% August 2023
3+
% MONTH YEAR
44

55
NAME
66
==================================================

spec/approvals/libraries/render/mandoc/render-2-download.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% cli-download(1) | Download a file
22
%
3-
% August 2023
3+
% MONTH YEAR
44

55
NAME
66
==================================================
@@ -69,4 +69,3 @@ SEE ALSO
6969
**cli**(1)
7070

7171

72-

spec/approvals/rendering/mandoc/catch-all-advanced/cli-download.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% cli-download(1) | Download a file
22
%
3-
% August 2023
3+
% MONTH YEAR
44

55
NAME
66
==================================================
@@ -66,4 +66,3 @@ SEE ALSO
6666
**cli**(1)
6767

6868

69-

0 commit comments

Comments
 (0)