rdoc-generator-sixfish 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,256 @@
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
3
+
4
+ require_relative '../../helpers'
5
+
6
+ require 'tmpdir'
7
+ require 'rspec'
8
+ require 'rdoc/generator/sixfish'
9
+
10
+ describe RDoc::Generator::Sixfish do
11
+
12
+ # Lots of the setup and the examples in this file are ported from
13
+ # the test_rdoc_generator_darkfish.rb file from RDoc itself.
14
+ # Used under the second option in the LICENSE.rdoc file:
15
+ # https://github.com/rdoc/rdoc/blob/master/LICENSE.rdoc
16
+
17
+ before( :all ) do
18
+ @libdir = Pathname.pwd + 'lib'
19
+ @datadir = RDoc::Generator::Sixfish::DATADIR
20
+ @tmpdir = Pathname( Dir.tmpdir ) + "test_rdoc_generator_sixfish_#{$$}"
21
+ @opdir = @tmpdir + 'docs'
22
+ @storefile = @tmpdir + '.rdoc_store'
23
+
24
+ @options = RDoc::Options.new
25
+ @options.option_parser = OptionParser.new
26
+
27
+ @options.op_dir = @opdir.to_s
28
+ @options.generator = described_class
29
+ @options.template_dir = @datadir.to_s
30
+
31
+ @tmpdir.mkpath
32
+ @store = RDoc::Store.new( @storefile.to_s )
33
+ @store.load_cache
34
+
35
+ $stderr.puts "Tmpdir is: %s" % [@tmpdir] if ENV['SIXFISH_DEVELMODE']
36
+ end
37
+
38
+ before( :each ) do
39
+ @generator = described_class.new( @store, @options )
40
+
41
+ @rdoc = RDoc::RDoc.new
42
+ @rdoc.options = @options
43
+ @rdoc.store = @store
44
+ @rdoc.generator = @generator
45
+
46
+ @top_level, @readme = add_code_objects( @store )
47
+ end
48
+
49
+ around( :each ) do |example|
50
+ @opdir.mkpath
51
+ Dir.chdir( @opdir ) { example.run }
52
+ @opdir.rmtree unless ENV['SIXFISH_DEVELMODE']
53
+ end
54
+
55
+
56
+ #
57
+ # Examples
58
+ #
59
+
60
+ it "registers itself as a generator" do
61
+ expect( RDoc::RDoc::GENERATORS ).to include( 'sixfish' => described_class )
62
+ end
63
+
64
+
65
+ it "configures Inversion to load templates from its data directory" do
66
+ expect( Inversion::Template.template_paths ).to eq( [@datadir + 'templates'] )
67
+ end
68
+
69
+
70
+ describe "additional-stylesheet option" do
71
+
72
+ it "is added to the options by the setup_options callback" do
73
+ @options.setup_generator( 'sixfish' )
74
+ expect( @options.option_parser.to_a.join ).to include( '--additional-stylesheet=URL' )
75
+ end
76
+
77
+ end
78
+
79
+
80
+ describe "generation" do
81
+
82
+ before( :each ) do
83
+ @generator.populate_data_objects
84
+ end
85
+
86
+
87
+ it "uses the index template to make the index page" do
88
+ index_template = double( "index template" )
89
+ expect( Inversion::Template ).to receive( :load ).
90
+ with( 'index.tmpl', encoding: 'utf-8' ).
91
+ and_return( index_template )
92
+
93
+ expect( index_template ).to receive( :dup ).and_return( index_template )
94
+ expect( index_template ).to receive( :files= ).with( [@top_level] ).once
95
+ expect( index_template ).to receive( :classes= ).
96
+ with( @store.all_classes_and_modules.sort )
97
+ expect( index_template ).to receive( :methods= ).
98
+ with( @store.all_classes_and_modules.flat_map(&:method_list).sort )
99
+ expect( index_template ).to receive( :modsort= ) do |sorted_mods|
100
+ expect( sorted_mods ).to include( @store.find_class_named('Klass') )
101
+ end
102
+ expect( index_template ).to receive( :rdoc_options= ).with( @options )
103
+ expect( index_template ).to receive( :rdoc_version= ).with( RDoc::VERSION )
104
+ expect( index_template ).to receive( :sixfish_version= ).with( Sixfish.version_string )
105
+ expect( index_template ).to receive( :mainpage= ).with( @readme )
106
+ expect( index_template ).to receive( :synopsis= ).
107
+ with( %{<p>This is a readme for testing.</p>} )
108
+ expect( index_template ).to receive( :rel_prefix= ).with( Pathname('.') ).once
109
+ expect( index_template ).to receive( :pageclass= ).with( 'index-page' )
110
+
111
+ expect( index_template ).to receive( :render ).and_return( "Index page!" )
112
+
113
+ @generator.generate_index_page
114
+ end
115
+
116
+
117
+ it "combines a class template with the layout template to make class pages" do
118
+ classes = @store.all_classes_and_modules
119
+
120
+ layout_template = get_fixtured_layout_template_mock()
121
+
122
+ class_template = double( "class template" )
123
+ expect( Inversion::Template ).to receive( :load ).
124
+ with( 'class.tmpl', encoding: 'utf-8' ).
125
+ and_return( class_template )
126
+ expect( class_template ).to receive( :dup ).and_return( class_template )
127
+
128
+ classes.each do |klass|
129
+ expect( class_template ).to receive( :klass= ).with( klass )
130
+ end
131
+
132
+ expect( layout_template ).to receive( :contents= ).with( class_template ).
133
+ exactly( classes.length ).times
134
+ expect( layout_template ).to receive( :pageclass= ).with( 'class-page' ).
135
+ exactly( classes.length ).times
136
+ expect( layout_template ).to receive( :rel_prefix= ).with( Pathname('.') ).
137
+ exactly( classes.length ).times
138
+
139
+ expect( layout_template ).to receive( :render ).
140
+ and_return( *classes.map {|k| "#{k.name} class page!"} )
141
+
142
+ @generator.generate_class_files
143
+ end
144
+
145
+
146
+ it "combines a file template with the layout template to make file pages" do
147
+ files = @store.all_files
148
+
149
+ layout_template = get_fixtured_layout_template_mock()
150
+
151
+ file_template = double( "file template" )
152
+ expect( Inversion::Template ).to receive( :load ).
153
+ with( 'file.tmpl', encoding: 'utf-8' ).
154
+ and_return( file_template )
155
+ expect( file_template ).to receive( :dup ).and_return( file_template )
156
+ expect( file_template ).to receive( :header= ).
157
+ with( %{<h1 id="label-Testing+README">Testing <a href="README_md} +
158
+ %{.html">README</a></h1>} )
159
+ expect( file_template ).to receive( :description= ).
160
+ with( %{\n<p>This is a readme for testing.</p>\n\n<p>It has some more} +
161
+ %{ stuff</p>\n\n<p>And even more stuff.</p>\n} )
162
+
163
+ expect( file_template ).to receive( :file= ).with( @readme )
164
+
165
+ expect( layout_template ).to receive( :contents= ).with( file_template ).once
166
+ expect( layout_template ).to receive( :pageclass= ).with( 'file-page' )
167
+ expect( layout_template ).to receive( :rel_prefix= ).with( Pathname('.') )
168
+ expect( layout_template ).to receive( :render ).and_return( "README file page!" )
169
+
170
+ @generator.generate_file_files
171
+ end
172
+
173
+ end
174
+
175
+
176
+
177
+ #
178
+ # Helpers
179
+ #
180
+
181
+ def any_method( name, comment=nil )
182
+ return RDoc::AnyMethod.new( comment, name )
183
+ end
184
+
185
+
186
+ def add_code_objects( store )
187
+ top_level = store.add_file( 'file.rb' )
188
+ top_level.parser = RDoc::Parser::Ruby
189
+
190
+ # Klass
191
+ klass = top_level.add_class( RDoc::NormalClass, 'Klass' )
192
+
193
+ # Klass::A
194
+ alias_constant = RDoc::Constant.new( 'A', nil, '' )
195
+ alias_constant.record_location( top_level )
196
+ top_level.add_constant( alias_constant )
197
+
198
+ # ::A = ::Klass (?)
199
+ klass.add_module_alias( klass, 'Klass', alias_constant, top_level )
200
+
201
+ # Klass#method
202
+ meth = RDoc::AnyMethod.new( nil, 'method' )
203
+ klass.add_method( meth )
204
+
205
+ # Klass#method!
206
+ meth_bang = RDoc::AnyMethod.new( nil, 'method!' )
207
+ klass.add_method( meth_bang )
208
+
209
+ # attr_accessor :name
210
+ name_attr = RDoc::Attr.new( nil, 'name', 'RW', '' )
211
+ klass.add_attribute( name_attr )
212
+
213
+ # Ignored class ::Ignored
214
+ ignored = top_level.add_class( RDoc::NormalClass, 'Ignored' )
215
+ ignored.ignore
216
+
217
+ readme = store.add_file( 'README.md' )
218
+ readme.parser = RDoc::Parser::Markdown
219
+ readme.comment = "= Testing README\n\nThis is a readme for testing.\n\n" +
220
+ "It has some more stuff\n\nAnd even more stuff.\n\n"
221
+
222
+ store.complete :private
223
+
224
+ return top_level, readme
225
+ end
226
+
227
+
228
+ def get_fixtured_layout_template_mock
229
+ layout_template = double( "layout template" )
230
+ expect( Inversion::Template ).to receive( :load ).
231
+ with( 'layout.tmpl', encoding: 'utf-8' ).
232
+ and_return( layout_template )
233
+
234
+ allow( layout_template ).to receive( :synopsis= )
235
+
236
+ # Work around caching
237
+ expect( layout_template ).to receive( :dup ).and_return( layout_template )
238
+
239
+ expect( layout_template ).to receive( :files= ).with( [@top_level] )
240
+ expect( layout_template ).to receive( :classes= ).
241
+ with( @store.all_classes_and_modules.sort )
242
+ expect( layout_template ).to receive( :methods= ).
243
+ with( @store.all_classes_and_modules.flat_map(&:method_list).sort )
244
+ expect( layout_template ).to receive( :modsort= ) do |sorted_mods|
245
+ expect( sorted_mods ).to include( @store.find_class_named('Klass') )
246
+ end
247
+ expect( layout_template ).to receive( :mainpage= ).with( @readme )
248
+ expect( layout_template ).to receive( :rdoc_options= ).with( @options )
249
+ expect( layout_template ).to receive( :rdoc_version= ).with( RDoc::VERSION )
250
+ expect( layout_template ).to receive( :sixfish_version= ).with( Sixfish.version_string )
251
+
252
+ return layout_template
253
+ end
254
+
255
+ end
256
+
@@ -0,0 +1,19 @@
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
3
+
4
+ require 'helpers'
5
+ require 'rspec'
6
+ require 'sixfish'
7
+
8
+ describe Sixfish do
9
+
10
+ describe "version methods" do
11
+
12
+ it "returns a version string if asked" do
13
+ expect( described_class.version_string ).to match( /\w+ [\d.]+/ )
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,165 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rdoc-generator-sixfish
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Granger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIID+DCCAmCgAwIBAgIBBDANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdnZWQv
14
+ REM9RmFlcmllTVVEL0RDPW9yZzAeFw0yMjAxMDcyMzU4MTRaFw0yMzAxMDcyMzU4
15
+ MTRaMCIxIDAeBgNVBAMMF2dlZC9EQz1GYWVyaWVNVUQvREM9b3JnMIIBojANBgkq
16
+ hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAvyVhkRzvlEs0fe7145BYLfN6njX9ih5H
17
+ L60U0p0euIurpv84op9CNKF9tx+1WKwyQvQP7qFGuZ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vd3QHRiWTTuhgHrdDnGdXg93N2M5KHn1ug8BtPLQwlcFwEpKnlLn
34
+ btEP+7EplFuoiMfd
35
+ -----END CERTIFICATE-----
36
+ date: 2022-11-15 00:00:00.000000000 Z
37
+ dependencies:
38
+ - !ruby/object:Gem::Dependency
39
+ name: inversion
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '1.3'
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '1.3'
52
+ - !ruby/object:Gem::Dependency
53
+ name: loggability
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '0.18'
59
+ type: :runtime
60
+ prerelease: false
61
+ version_requirements: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - "~>"
64
+ - !ruby/object:Gem::Version
65
+ version: '0.18'
66
+ - !ruby/object:Gem::Dependency
67
+ name: rdoc
68
+ requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '6.4'
73
+ type: :runtime
74
+ prerelease: false
75
+ version_requirements: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '6.4'
80
+ - !ruby/object:Gem::Dependency
81
+ name: rake-deveiate
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '0.19'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '0.19'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rdoc-generator-fivefish
96
+ requirement: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '0.4'
101
+ type: :development
102
+ prerelease: false
103
+ version_requirements: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.4'
108
+ description: A readable HTML generator for RDoc. It uses the Bulma CSS framework.
109
+ email:
110
+ - ged@faeriemud.org
111
+ executables: []
112
+ extensions: []
113
+ extra_rdoc_files: []
114
+ files:
115
+ - History.md
116
+ - README.md
117
+ - data/rdoc-generator-sixfish/css/fa-solid-900.515704be.ttf
118
+ - data/rdoc-generator-sixfish/css/fa-solid-900.7ba04835.svg
119
+ - data/rdoc-generator-sixfish/css/fa-solid-900.8c589fd1.eot
120
+ - data/rdoc-generator-sixfish/css/fa-solid-900.c7b072c6.woff
121
+ - data/rdoc-generator-sixfish/css/fa-solid-900.f2049a98.woff2
122
+ - data/rdoc-generator-sixfish/css/sixfish.css
123
+ - data/rdoc-generator-sixfish/css/sixfish.css.map
124
+ - data/rdoc-generator-sixfish/js/sixfish.js
125
+ - data/rdoc-generator-sixfish/js/sixfish.js.map
126
+ - data/rdoc-generator-sixfish/templates/class.tmpl
127
+ - data/rdoc-generator-sixfish/templates/file.tmpl
128
+ - data/rdoc-generator-sixfish/templates/index.tmpl
129
+ - data/rdoc-generator-sixfish/templates/layout.tmpl
130
+ - lib/inversion/template/striptag.rb
131
+ - lib/rdoc/discover.rb
132
+ - lib/rdoc/generator/sixfish.rb
133
+ - lib/sixfish.rb
134
+ - lib/sixfish/patches.rb
135
+ - spec/helpers.rb
136
+ - spec/rdoc/generator/sixfish_spec.rb
137
+ - spec/sixfish_spec.rb
138
+ homepage: https://hg.sr.ht/~ged/Sixfish
139
+ licenses:
140
+ - BSD-3-Clause
141
+ metadata:
142
+ homepage_uri: https://hg.sr.ht/~ged/Sixfish
143
+ documentation_uri: https://deveiate.org/code/sixfish
144
+ source_uri: https://hg.sr.ht/~ged/Sixfish
145
+ bug_tracker_uri: https://todo.sr.ht/~ged/Sixfish
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubygems_version: 3.3.7
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: A readable HTML generator for RDoc.
165
+ test_files: []
metadata.gz.sig ADDED
Binary file