Skip to content

Commit b44b91f

Browse files
committed
- Refactor mandoc template to use x_mandoc_footer and x_mandoc_authors
1 parent 7e568f5 commit b44b91f

File tree

19 files changed

+55
-16
lines changed

19 files changed

+55
-16
lines changed

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

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,52 @@ Render man pages for your script.
55
Note that this renderer will render specially formatted markdown documents and
66
will then use [pandoc](https://command-not-found.com/pandoc) to convert them.
77

8-
Setting the environment variable `PREVIEW` to the full command you wish to
9-
preview, will prompt the renderer to show the output using the `man` command
10-
after rendering.
11-
128
## Usage
139

1410
```bash
1511
# Generate all man pages to the ./docs directory
1612
$ bashly render :mandoc docs
13+
```
14+
15+
## Special template features
16+
17+
### Preview
1718

18-
# .. and also preview the page for the "cli download" command
19+
Setting the environment variable `PREVIEW` to the full command you wish
20+
to preview, will prompt the renderer to show the output using the `man`
21+
command after rendering.
22+
23+
```bash
24+
# Preview the page for the "cli download" command
1925
$ PREVIEW="cli download" bashly render :mandoc docs
2026

21-
# .. and also watch for changes
27+
# .. and also watch for changes (after existing the man preview)
2228
$ PREVIEW="cli download" bashly render :mandoc docs --watch
2329
```
2430

25-
## Appending a footer
31+
### Footer
32+
33+
You can add additional sections to any of the generated man pages, by
34+
adding a property named `x_mandoc_footer` to any of your commands in
35+
your `bashly.yml`.
36+
37+
This field should contain a markdown string, for example:
2638

27-
In case you wish to append additional sections to your generated man pages,
28-
you can place a file named `_footer.md` in your target directory.
39+
```yaml
40+
x_mandoc_footer: |-
41+
# ISSUE TRACKER
42+
43+
Report issues at <https://github.com/lanalang/smallville>
44+
```
45+
46+
### Authors
47+
48+
You can specify an authors string that will be added to the man page,
49+
by adding a property named `x_mandoc_authors` to any of your commands
50+
in your `bashly.yml`.
51+
52+
For example:
53+
54+
```yaml
55+
x_mandoc_authors: Lana Lang
56+
```

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if version
55
else
66
> % {{ full_name.to_hyphen }}(1) | {{ summary }}
77
end
8-
> % {{ ENV['AUTHORS'] }}
8+
> % {{ x_mandoc_authors }}
99
> % {{ Date.today.strftime "%B %Y" }}
1010
>
1111

@@ -177,4 +177,5 @@ if public_commands.any?
177177
>
178178
end
179179

180+
= x_mandoc_footer
180181
>

lib/bashly/libraries/render/mandoc/render.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
manfile = "#{target}/#{command.full_name.tr(' ', '-')}.1"
1212
save mdfile, gtx.parse(command)
1313

14-
# Append the footer file if it exists
15-
footer_file = "#{target}/_footer.md"
16-
if File.exist? footer_file
17-
File.append mdfile, File.read(footer_file)
18-
end
19-
2014
# The pandoc command that creates a manpage from markdown
2115
cmd = %[pandoc -f markdown-smart -s --to man "#{mdfile}" > "#{manfile}"]
2216
success = system cmd

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ cli download example.com ./output -f
5252
5353
~~~
5454

55+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ Upload a file
1919

2020
- Alias: **u**
2121

22+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ SEE ALSO
3333

3434
**cli-download**(1), **cli-upload**(1)
3535

36+

spec/approvals/rendering/mandoc/dependencies-alt/cli-download.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ DEPENDENCIES
3131
: install with $(green sudo apt install curl)
3232

3333

34+

spec/approvals/rendering/mandoc/dependencies-alt/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ SEE ALSO
3030

3131
**cli-download**(1)
3232

33+

spec/approvals/rendering/mandoc/docker-like/docker-container-run.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ ARGUMENTS
2626

2727
- *Required*
2828

29+

spec/approvals/rendering/mandoc/docker-like/docker-container-stop.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ ARGUMENTS
2626

2727
- *Required*
2828

29+

0 commit comments

Comments
 (0)