rdoc-babel 1.2.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47d4465a4ef80ca08eac47af424ee6812ae579733e6e8c45e42687a056bbc2ba
4
- data.tar.gz: ef4ad57af3f4e00744ba74de09b9b2d72bf50a86f4c04e5d21ed95758e7b60b9
3
+ metadata.gz: b6ae764381b167bd89156dc785a2a039b9fe66197e26ab1887b565225279c0de
4
+ data.tar.gz: 07c955b085e7aa2c195363b40cd0904bcc3a871727f19089d6060546131d9647
5
5
  SHA512:
6
- metadata.gz: c7e4e1224ac4b5118117189e68a4ea2652131ca105dee68f8569a553d205d7e2ba3f4011abdfc5c13a1cf709fca3424282e6fb69c4db8424f1392a5eac4fd971
7
- data.tar.gz: b5e429343ff77e7156dff182b7990a33f262d03629acad381866d15888fefe553224e8658621a4c20b38153230da1ed9a66350a6fc95f311d39f740b7fce95f9
6
+ metadata.gz: 011f9c6d9f66bbf81ae89064b8de0b4973dd397409ba439a8d6b03a8bad2549db5542e4f1d4c607a9c53c672a3d30dcfe152ebd9a055522bad9f70f10aa54402
7
+ data.tar.gz: 5aa917b782b26a0e1adc5217168d1eaa16e19d9a447eb664bd5ced9e52f0a3eeff2b12fb83660b61f0af1f8fcf572d8423ba82e74e39ef99cf761bb8441ee8ba
data/HISTORY.rdoc CHANGED
@@ -1,3 +1,19 @@
1
+ === 1.4.1
2
+
3
+ * remove an extra </span> in class HTML
4
+ * use flex to display the header components
5
+
6
+ === 1.4.0
7
+
8
+ * add a TOC button on the top right
9
+ * fix initial sizing in the left pane
10
+ * fix too wide <pre> sections
11
+
12
+ === 1.3.0
13
+
14
+ * switch from frameset to iframe
15
+ * highlight the current file/class/method in the left frame
16
+
1
17
  === 1.2.1
2
18
 
3
19
  * filter: only search in link text (skip class/method type)
data/README.rdoc CHANGED
@@ -16,39 +16,40 @@ and to contribute alternate templates or style sheets.
16
16
  - Dual-frame output, with indexes on the left.
17
17
  - Search boxes for classes and methods.
18
18
  - Links to undocumented classes/methods are grayed.
19
- - Highlights target methods, attributes and constants.
19
+ - Highlights the current file/class/method in the left frame.
20
+ - Highlights the target method, attribute or constant in the main frame.
20
21
  - Adds links to ancestor methods/attributes.
21
22
  - Borrows some ideas (and one icon) from Darkfish.
22
- - Tested on Firefox 3.5 & 5, Chrome 9 & 12, Safari 4 & 5.
23
+ - Tested on Firefox 125.<br>
24
+ If using the <tt>file://</tt> protocol, the "same origin policy" for local files must be turned off:<br>
25
+ <tt>about:config</tt> > <tt>security.fileuri.strict_origin_policy = false</tt>
23
26
 
24
27
  == Synopsis
25
28
 
26
29
  To output documentation formatted by Babel, use the <tt>--format/-f</tt>
27
- RDoc switch. For instance, to generate the documentation for Ruby core:
30
+ RDoc switch. For instance, to generate the documentation for Ruby core and stdlib:
28
31
 
29
- $ gem install rdoc-babel
30
- $ cd ~/.rvm/src/ruby-1.8.7-p302
31
- $ rdoc -f babel -a -t "Ruby 1.8.7 Core" -o ~/docs/ruby_core_187 *.c
32
+ > gem install rdoc-babel
33
+ > cd /ruby/src
34
+ > rdoc -f babel -a -t "Ruby Core + Stdlib" -o /docs/ruby-core
32
35
 
33
36
  Using rake:
34
37
 
35
38
  require 'rdoc/task'
36
39
 
37
40
  RDoc::Task.new do |t|
38
- Dir.chdir '~/.rvm/src/ruby-1.9.2-p0'
41
+ Dir.chdir '/ruby/src'
39
42
  rdoc.options <<
40
43
  '--format' << 'babel' <<
41
44
  '--all'
42
- t.title = "Ruby 1.9.2 Core"
43
- t.rdoc_dir = '~/docs/ruby_core_192'
44
- t.rdoc_files.concat Dir['*.c']
45
+ t.title = "Ruby Core + Stdlib"
46
+ t.rdoc_dir = '/docs/ruby-core'
45
47
  end
46
48
 
47
49
  To make Babel the default format when generating RDoc documentation,
48
- define the RDOCOPT environment variable in the appropriate file
49
- (e.g., <tt>~/.bashrc</tt>):
50
+ define the RDOCOPT environment variable:
50
51
 
51
- export RDOCOPT="--format babel"
52
+ RDOCOPT="--format babel"
52
53
 
53
54
  == Specific options
54
55
 
@@ -70,8 +71,8 @@ Babel supports specific options in addition to the standard RDoc options:
70
71
 
71
72
  == Requirements
72
73
 
73
- - Ruby >= 2.3.0 (may work with >= 1.9.3, but untested)
74
- - RDoc >= 5.0 (may work with >= 4.0, but untested)
74
+ - Ruby >= 3.1.0 (may work with >= 2.5.0, but untested)
75
+ - RDoc >= 6.5.0 (may work with >= 5.0, but untested)
75
76
 
76
77
  == Installation
77
78
 
@@ -81,7 +82,7 @@ Babel supports specific options in addition to the standard RDoc options:
81
82
 
82
83
  (The MIT License)
83
84
 
84
- Copyright (c) 2010-2020 Thierry Lambert
85
+ Copyright (c) 2010-2024 Thierry Lambert
85
86
 
86
87
  Permission is hereby granted, free of charge, to any person obtaining
87
88
  a copy of this software and associated documentation files (the
@@ -33,7 +33,7 @@ class RDoc::Generator::Babel
33
33
 
34
34
  RDoc::RDoc.add_generator(self)
35
35
 
36
- VERSION = '1.2.1'
36
+ VERSION = '1.4.1'
37
37
  DESCRIPTION = 'Alternate HTML documentation'
38
38
 
39
39
  include ERB::Util
@@ -157,6 +157,25 @@ class RDoc::Generator::Babel
157
157
 
158
158
  def generate
159
159
 
160
+ # rdoc bug fix: public class/module methods appear as external_aliases (unresolved aliases)
161
+
162
+ @store.all_classes_and_modules.each do |cm|
163
+ next if cm.external_aliases.empty?
164
+ class_level_names = cm.method_list.select { |m| m.type == 'class' }.map(&:name)
165
+ cm.external_aliases.dup.each do |a|
166
+ cm.external_aliases.delete a if class_level_names.include?(a.name)
167
+ end
168
+ end
169
+
170
+ # other bug fix: method aliases with singleton mismatch
171
+
172
+ @store.all_classes_and_modules.each do |cm|
173
+ cm.class_method_list.each do |m|
174
+ m.is_alias_for.singleton = true if m.is_alias_for
175
+ m.aliases.each { |a| a.singleton = true }
176
+ end
177
+ end
178
+
160
179
  # set instance variables
161
180
 
162
181
  @output_dir = Pathname.new(@options.op_dir).expand_path(@source_dir)
@@ -178,11 +197,25 @@ class RDoc::Generator::Babel
178
197
  @simple_files
179
198
  end
180
199
 
181
- @main_file = @options.main_page && @all_files.find { |f| f.full_name == @options.main_page }
182
- if @main_file
183
- unless @files_to_display.find { |f| f.full_name == @options.main_page }
184
- @files_to_display.unshift @main_file
200
+ if @options.main_page
201
+ # look for a TopLevel matching the main page
202
+ @main_page = @all_files.find { |f| f.full_name == @options.main_page }
203
+ if @main_page
204
+ # TODO are there cases where main_page = 'README' for 'lib/README'?
205
+ unless @files_to_display.find { |f| f.full_name == @options.main_page }
206
+ @files_to_display.unshift @main_page
207
+ end
208
+ # look for a class/module with that name
209
+ else
210
+ match = @unique_classes_and_modules.find { |cm| cm.full_name == @options.main_page }
211
+ if match
212
+ @main_page = match
213
+ else
214
+ warn "no such page: --main #{@options.main_page}"
215
+ end
185
216
  end
217
+ else
218
+ @main_page = nil
186
219
  end
187
220
 
188
221
  # write the output
@@ -263,7 +296,7 @@ class RDoc::Generator::Babel
263
296
  # Returns the first +Context+ object to display in the main frame.
264
297
  # This is, in order:
265
298
  # - The file designated by the +main_page+ option,
266
- # if there is a +TopLevel+ with that name.
299
+ # if there is a +TopLevel+ or class/module with that name.
267
300
  # - The first simple file that contains a comment
268
301
  # (in the order given on the command line).
269
302
  # - The first class or module that contains a comment.
@@ -274,19 +307,30 @@ class RDoc::Generator::Babel
274
307
  # - The first file.
275
308
 
276
309
  def first_page
277
- # TODO are there cases where main_page = 'README' for 'lib/README'?
278
- if @options.main_page && (main_file = @all_files.find { |f| f.full_name == @options.main_page })
279
- main_file
310
+ if @main_page
311
+ debug_msg "main as --main: #{@main_page}"
312
+ @main_page
280
313
  elsif (file = @simple_files.first)
314
+ debug_msg "main as first simple file: #{file}"
281
315
  file
282
316
  elsif (cm = @unique_classes_and_modules.find { |k| !k.comment.empty? })
317
+ debug_msg "main as first module/class with comment: #{cm}"
283
318
  cm
284
- elsif (file = @files_with_comment.first)
285
- file
319
+ # this is not a simple file, so currently not displayed in files
320
+ # elsif (file = @files_with_comment.first)
321
+ # debug_msg "main as first file with comment: #{file}"
322
+ # file
286
323
  elsif !@unique_classes_and_modules.empty?
287
- @unique_classes_and_modules.find { |k| k.any_content } or
288
- @unique_classes_and_modules.first
324
+ cm = @unique_classes_and_modules.find { |k| k.any_content }
325
+ if cm
326
+ debug_msg "main as first module/class with any content: #{cm}"
327
+ else
328
+ debug_msg "main as first module/class (no content): #{cm}"
329
+ cm = @unique_classes_and_modules.first
330
+ end
331
+ cm
289
332
  else
333
+ debug_msg "main as first file: #{cm}"
290
334
  @all_files.first
291
335
  end
292
336
  end
@@ -450,9 +494,32 @@ protected
450
494
 
451
495
  return if @options.dry_run
452
496
 
497
+ # fix file cross-references
498
+ # rdoc:ref handling by RDoc requires that files and classes are stored in the
499
+ # root output directory, while we have files and classes in separate subdirectories
500
+ output.gsub!(/<a (.*?)\bhref="(.+?)"/) do |match|
501
+ atts = $1
502
+ href = $2
503
+ next match if href[0] == '#'
504
+ path, id = href.split('#')
505
+ # in classes/OptionParser.html:
506
+ # we find for instance <a href="optparse/tutorial_rdoc.html">Tutorial</a>
507
+ # which matches files/doc/optparse/tutorial_rdoc.html
508
+ matches = @all_files.select do |f|
509
+ f.path.end_with?(path) && f.path != path
510
+ end
511
+ next match if matches.empty?
512
+ # we replace optparse/tutorial_rdoc.html by ../files/doc/optparse/tutorial_rdoc.html
513
+ f = matches.first
514
+ actual = Pathname.new(f.path).expand_path(@output_dir).relative_path_from(outfile.dirname).to_s
515
+ next match if actual == path
516
+ actual << '#' << id if id
517
+ %(<a #{atts}href="#{actual}")
518
+ end
519
+
453
520
  outfile.dirname.mkpath
454
- outfile.open('w', 0644) do |ofh|
455
- ofh.print(output)
521
+ outfile.open('w', 0644) do |io|
522
+ io.print(output)
456
523
  end
457
524
 
458
525
  end
@@ -2,65 +2,52 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="<%= @options.charset %>">
5
- <title><%= @class.type.capitalize %> <%= @class.full_name %></title>
5
+ <title><%= @class.full_name %> &ndash; <%= h @options.title %></title>
6
6
  <link href="<%= @stylesheet_url %>" rel="stylesheet">
7
7
  <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
8
8
  <script src="<%= @rel_prefix %>/scripts/mainFrame.js" type="text/javascript"></script>
9
9
  </head>
10
10
  <body>
11
11
 
12
+ <div id="left-container">
13
+ <iframe id="left-frame" src="<%= @rel_prefix %>/indexes.html"></iframe>
14
+ <div id="resizer"></div>
15
+ </div>
16
+ <div id="main-container">
12
17
  <div id="header">
13
18
  <p class="header-title">
14
19
  <span class="prefix"><%= @class.type.capitalize %></span><span class="name"> <%= @class.full_name %></span>
15
20
  </p>
16
21
  <% if @class.type == 'class' && @class.superclass %>
17
22
  <p class="header-title">
18
- <% if String === @class.superclass %>
19
- <span class="parent"> &lt; <%= @class.superclass %></span>
23
+ <% if @class.superclass.is_a?(String) %>
24
+ <span class="parent"> &nbsp;&lt; <%= @class.superclass %></span>
20
25
  <% else %>
21
- </span><span class="parent"> &lt; <a href="<%= @class.aref_to @class.superclass.path %>"><%= @class.superclass.full_name %></a></span>
26
+ <span class="parent"> &nbsp;&lt; <a href="<%= @class.aref_to @class.superclass.path %>"><%= @class.superclass.full_name %></a></span>
22
27
  <% end %>
23
28
  </p>
24
29
  <% end %>
25
30
  <p id="file-info">
31
+ <span class="in-files">In:</span>
26
32
  <% if @class.in_files.length < 3 %>
27
- <span class="displayed">
28
- <span class="in-files">In:</span>
29
- <span class="first-files">
30
- <% @class.in_files.each do |f| %>
31
- <a href="<%= @rel_prefix %>/<%= h f.path %>"><%= h f.full_name %></a><br>
32
- <% end %>
33
- </span>
34
- </span>
35
- <span class="hidden">
36
- <span class="in-files">In:</span>
37
- <span class="first-files">
38
- <% @class.in_files.each do |f| %>
39
- <a href="#"><%= h f.full_name %></a><br>
40
- <% end %>
41
- </span>
33
+ <span class="file-list">
34
+ <% @class.in_files.each do |f| %>
35
+ <a href="<%= @rel_prefix %>/<%= h f.path %>"><%= h f.full_name %></a><br>
36
+ <% end %>
37
+ <% if @class.in_files.length == 1 %>
38
+ &nbsp;
39
+ <% end %>
42
40
  </span>
43
41
  <% else %>
44
- <span class="displayed">
45
- <span class="in-files">In:</span>
46
- <span class="first-files">
47
- <a href="<%= @rel_prefix %>/<%= h @class.in_files.first.path %>"><%= h @class.in_files.first.full_name %></a><br>
48
- <a href="#" id="show-all-files">(<%= @class.in_files.length - 1 %> more...)</a>
49
- </span>
50
- </span>
51
- <span class="hidden">
52
- <span class="in-files">In:</span>
53
- <span class="first-files">
54
- <a href="#"><%= h @class.in_files.first.full_name %></a><br>
55
- <a href="#" id="show-all-files">(<%= @class.in_files.length - 1 %> more...)</a>
42
+ <span class="file-list">
43
+ <a href="<%= @rel_prefix %>/<%= h @class.in_files.first.path %>"><%= h @class.in_files.first.full_name %></a><br>
44
+ <a href="#" id="show-all-files">(<%= @class.in_files.length - 1 %> more...)</a>
45
+ <span id="all-files">
46
+ <% @class.in_files[1..-1].each do |f| %>
47
+ <a href="<%= @rel_prefix %>/<%= h f.path %>"><%= h f.full_name %></a><br>
48
+ <% end %>
56
49
  </span>
57
50
  </span>
58
- <br>
59
- <span id="all-files">
60
- <% @class.in_files[1..-1].each do |f| %>
61
- <a href="<%= @rel_prefix %>/<%= h f.path %>"><%= h f.full_name %></a><br>
62
- <% end %>
63
- </span>
64
51
  <% end %>
65
52
  </p>
66
53
  </div>
@@ -69,8 +56,8 @@
69
56
 
70
57
  <%= @class.description %>
71
58
 
72
- <!-- class/module aliases -->
73
59
  <% unless @class.aliases.empty? %>
60
+ <!-- class/module aliases -->
74
61
  <div id="class-aliases" class="list">
75
62
  <h3><%= @class.type.capitalize %> Aliases</h3>
76
63
  <ul>
@@ -81,8 +68,8 @@
81
68
  </div>
82
69
  <% end %>
83
70
 
84
- <!-- list of methods -->
85
71
  <% unless @class.method_list.empty? %>
72
+ <!-- list of methods -->
86
73
  <div id="method-list" class="list">
87
74
  <h3>Methods</h3>
88
75
  <% unless @class.class_method_list.empty? %>
@@ -104,8 +91,8 @@
104
91
  </div>
105
92
  <% end %>
106
93
 
107
- <!-- namespace contents -->
108
94
  <% unless @class.non_aliases.empty? %>
95
+ <!-- namespace contents -->
109
96
  <div id="namespace-list" class="list">
110
97
  <h3>Modules and Classes</h3>
111
98
  <table class="classes-modules">
@@ -119,8 +106,8 @@
119
106
  </div>
120
107
  <% end %>
121
108
 
122
- <!-- included modules -->
123
109
  <% unless @class.includes.empty? %>
110
+ <!-- included modules -->
124
111
  <div id="include-list" class="list">
125
112
  <h3>Included Modules</h3>
126
113
  <ul>
@@ -135,8 +122,8 @@
135
122
  </div>
136
123
  <% end %>
137
124
 
138
- <!-- constants -->
139
125
  <% unless @class.constants.empty? %>
126
+ <!-- constants -->
140
127
  <div id="constant-list" class="list">
141
128
  <h3>Constants</h3>
142
129
  <table>
@@ -162,8 +149,8 @@
162
149
  </div>
163
150
  <% end %>
164
151
 
165
- <!-- external aliases -->
166
152
  <% unless @class.external_aliases.empty? %>
153
+ <!-- external aliases -->
167
154
  <div id="external-aliases" class="list">
168
155
  <h3>External Aliases</h3>
169
156
  <table>
@@ -177,8 +164,8 @@
177
164
  </div>
178
165
  <% end %>
179
166
 
180
- <!-- class/module attributes -->
181
167
  <% unless @class.class_attributes.empty? %>
168
+ <!-- class/module attributes -->
182
169
  <div id="class-attributes" class="list">
183
170
  <h3><%= @class.type.capitalize %> Attributes</h3>
184
171
  <table>
@@ -203,8 +190,8 @@
203
190
  </div>
204
191
  <% end %>
205
192
 
206
- <!-- instance attributes -->
207
193
  <% unless @class.instance_attributes.empty? %>
194
+ <!-- instance attributes -->
208
195
  <div id="instance-attributes" class="list">
209
196
  <h3>Instance Attributes</h3>
210
197
  <table>
@@ -267,6 +254,7 @@
267
254
  <% end # @class.methods_by_type.each %>
268
255
 
269
256
  </div> <!-- #documentation -->
257
+ </div> <!-- #main-container -->
270
258
 
271
259
  </body>
272
260
  </html>
@@ -2,19 +2,21 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="<%= @options.charset %>">
5
- <title>File <%= @file.base_name %></title>
5
+ <title><%= @file.base_name %> &ndash; <%= h @options.title %></title>
6
6
  <link href="<%= @stylesheet_url %>" rel="stylesheet">
7
7
  <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
8
8
  <script src="<%= @rel_prefix %>/scripts/mainFrame.js" type="text/javascript"></script>
9
9
  </head>
10
10
  <body>
11
+ <div id="left-container">
12
+ <iframe id="left-frame" src="<%= @rel_prefix %>/indexes.html"></iframe>
13
+ <div id="resizer"></div>
14
+ </div>
15
+ <div id="main-container">
11
16
  <div id="header">
12
17
  <p class="header-title"><span class="prefix">File</span><span class="name"> <%= @file.base_name %></span></p>
13
18
  <p id="file-info">
14
- <span class="displayed">
15
- Path: <%= @file.absolute_name %><br>
16
- Modified: <%= @file.last_modified ? @file.last_modified.strftime('%Y-%m-%d %H:%M:%S') : 'unknown' %>
17
- </span>
19
+ Path: <%= @file.absolute_name %>
18
20
  </p>
19
21
  </div>
20
22
  <div id="documentation">
@@ -54,5 +56,6 @@
54
56
  </div>
55
57
  <% end %>
56
58
  </div>
59
+ </div>
57
60
  </body>
58
61
  </html>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 0 24 24" width="18px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="18px" viewBox="0 0 24 24" width="18px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>
@@ -1,11 +1,6 @@
1
1
  <!DOCTYPE html>
2
- <html lang="en">
2
+ <html>
3
3
  <head>
4
- <meta charset="<%= @options.charset %>">
5
- <title><%= h @options.title %></title>
4
+ <meta http-equiv="refresh" content="0; url=<%= @first_page.path %>" />
6
5
  </head>
7
- <frameset cols="20%,*">
8
- <frame name="indexFrame" src="indexes.html">
9
- <frame name="mainFrame" src="<%= @first_page.path %>">
10
- </frameset>
11
6
  </html>
@@ -7,7 +7,7 @@
7
7
  <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
8
8
  <script src="scripts/quicksearch.js" type="text/javascript"></script>
9
9
  <script src="scripts/indexFrame.js" type="text/javascript"></script>
10
- <base target="mainFrame">
10
+ <base target="_parent">
11
11
  </head>
12
12
  <body class="index">
13
13
  <% $stderr.sync = true %>