File tree Expand file tree Collapse file tree 8 files changed +59
-17
lines changed
lib/bashly/libraries/render/mandoc
approvals/rendering/mandoc Expand file tree Collapse file tree 8 files changed +59
-17
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ RSpec/FilePath:
2828 - ' spec/bashly/concerns/completions_command_spec.rb'
2929 - ' spec/bashly/concerns/completions_flag_spec.rb'
3030
31- # FIXME: This test is ugly and long
31+ # Allow longer integration examples as they are more complex by nature
3232RSpec/ExampleLength :
3333 Exclude :
34- - ' spec/bashly/integration/rendering_spec.rb '
34+ - ' spec/bashly/integration/**/* '
Original file line number Diff line number Diff line change @@ -21,3 +21,8 @@ $ PREVIEW="cli download" bashly render :mandoc docs
2121# .. and also watch for changes
2222$ PREVIEW=" cli download" bashly render :mandoc docs --watch
2323```
24+
25+ ## Appending a footer
26+
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.
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ if examples
166166 >
167167 end
168168 > ~~~
169+ >
169170end
170171
171172if public_commands.any?
@@ -175,3 +176,5 @@ if public_commands.any?
175176 = public_commands.map { |x| "**#{x.full_name.to_hyphen}**(1)" }.join ', '
176177 >
177178end
179+
180+ >
Original file line number Diff line number Diff line change 1111 manfile = "#{ target } /#{ command . full_name . tr ( ' ' , '-' ) } .1"
1212 save mdfile , gtx . parse ( command )
1313
14- cmd = %[pandoc -f markdown-smart -s --to man "#{ mdfile } " > "#{ manfile } "]
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
1519
20+ # The pandoc command that creates a manpage from markdown
21+ cmd = %[pandoc -f markdown-smart -s --to man "#{ mdfile } " > "#{ manfile } "]
1622 success = system cmd
1723 raise "Failed running pandoc\n Make sure the following command succeeds and try again:\n \n #{ cmd } " unless success
1824
Original file line number Diff line number Diff line change @@ -51,3 +51,4 @@ cli download example.com
5151cli download example.com ./output -f
5252
5353~~~
54+
Original file line number Diff line number Diff line change @@ -46,3 +46,4 @@ download example.com
4646download example.com ./output -f
4747
4848~~~
49+
Original file line number Diff line number Diff line change 11# This spec tests that the rendering using the libraries/render templates
22# is generating the expected output.
3- describe 'rendering templates ' do
3+ describe 'rendering mandoc ' do
44 subject { Commands ::Render . new }
55
66 target = 'spec/tmp'
2222 reset_tmp_dir
2323 end
2424
25- it 'renders markdown properly' do
26- expect { subject . execute %W[ render :markdown #{ target } ] }
27- . to output_approval ( "rendering/markdown/#{ example } /stdout" )
28-
29- Dir [ "#{ target } /*.md" ] . each do |file |
30- puts " => #{ file } "
31- basename = File . basename file
32- expect ( File . read file ) . to match_approval ( "rendering/markdown/#{ example } /#{ basename } " )
33- . diff ( leeway )
34- end
35- end
36-
37- it 'renders mandoc properly' do
25+ it 'renders properly' do
3826 expect { subject . execute %W[ render :mandoc #{ target } ] }
3927 . to output_approval ( "rendering/mandoc/#{ example } /stdout" )
4028
Original file line number Diff line number Diff line change 1+ # This spec tests that the rendering using the libraries/render templates
2+ # is generating the expected output.
3+ describe 'rendering markdown' do
4+ subject { Commands ::Render . new }
5+
6+ target = 'spec/tmp'
7+ examples = %w[
8+ catch-all-advanced
9+ dependencies-alt
10+ docker-like
11+ extensible-delegate
12+ minimal
13+ ]
14+
15+ # Allow up to a certain string distance from the approval text in CI
16+ leeway = ENV [ 'CI' ] ? 20 : 0
17+
18+ examples . each do |example |
19+ describe example do
20+ before do
21+ Settings . config_path = "examples/#{ example } /src/bashly.yml"
22+ reset_tmp_dir
23+ end
24+
25+ it 'renders properly' do
26+ expect { subject . execute %W[ render :markdown #{ target } ] }
27+ . to output_approval ( "rendering/markdown/#{ example } /stdout" )
28+
29+ Dir [ "#{ target } /*.md" ] . each do |file |
30+ puts " => #{ file } "
31+ basename = File . basename file
32+ expect ( File . read file ) . to match_approval ( "rendering/markdown/#{ example } /#{ basename } " )
33+ . diff ( leeway )
34+ end
35+ end
36+ end
37+ end
38+ end
You can’t perform that action at this time.
0 commit comments