rdoc 6.17.0 → 8.1.0
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 +4 -4
- data/CONTRIBUTING.md +193 -0
- data/LEGAL.rdoc +6 -0
- data/LICENSE.rdoc +4 -0
- data/README.md +132 -8
- data/RI.md +75 -75
- data/doc/markup_reference/markdown.md +659 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/exe/rdoc +2 -2
- data/lib/rdoc/code_object/alias.rb +70 -74
- data/lib/rdoc/code_object/any_method.rb +308 -293
- data/lib/rdoc/code_object/attr.rb +150 -142
- data/lib/rdoc/code_object/class_module.rb +802 -715
- data/lib/rdoc/code_object/constant.rb +181 -144
- data/lib/rdoc/code_object/context/section.rb +140 -130
- data/lib/rdoc/code_object/context.rb +925 -941
- data/lib/rdoc/code_object/extend.rb +7 -5
- data/lib/rdoc/code_object/include.rb +7 -5
- data/lib/rdoc/code_object/method_attr.rb +328 -315
- data/lib/rdoc/code_object/mixin.rb +97 -92
- data/lib/rdoc/code_object/normal_class.rb +77 -78
- data/lib/rdoc/code_object/normal_module.rb +61 -59
- data/lib/rdoc/code_object/require.rb +23 -39
- data/lib/rdoc/code_object/single_class.rb +21 -19
- data/lib/rdoc/code_object/top_level.rb +215 -202
- data/lib/rdoc/code_object.rb +305 -305
- data/lib/rdoc/comment.rb +274 -337
- data/lib/rdoc/cross_reference.rb +195 -206
- data/lib/rdoc/encoding.rb +105 -103
- data/lib/rdoc/erb_partial.rb +13 -11
- data/lib/rdoc/erbio.rb +29 -27
- data/lib/rdoc/generator/aliki.rb +196 -30
- data/lib/rdoc/generator/darkfish.rb +647 -629
- data/lib/rdoc/generator/json_index.rb +233 -229
- data/lib/rdoc/generator/markup.rb +165 -122
- data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
- data/lib/rdoc/generator/pot/po.rb +52 -51
- data/lib/rdoc/generator/pot/po_entry.rb +138 -132
- data/lib/rdoc/generator/pot.rb +85 -81
- data/lib/rdoc/generator/ri.rb +23 -19
- data/lib/rdoc/generator/template/aliki/DESIGN.md +538 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/aliki/_head.rhtml +15 -10
- data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +3 -3
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +3 -3
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/class.rhtml +71 -61
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +796 -323
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +119 -113
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +1 -1
- data/lib/rdoc/generator/template/aliki/js/{search.js → search_controller.js} +16 -7
- data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/class.rhtml +29 -32
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +19 -1
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/generator.rb +48 -46
- data/lib/rdoc/i18n/locale.rb +99 -95
- data/lib/rdoc/i18n/text.rb +109 -105
- data/lib/rdoc/i18n.rb +7 -5
- data/lib/rdoc/markdown/byte_runtime.rb +80 -0
- data/lib/rdoc/markdown.kpeg +52 -33
- data/lib/rdoc/markdown.rb +365 -177
- data/lib/rdoc/markup/blank_line.rb +25 -23
- data/lib/rdoc/markup/block_quote.rb +12 -8
- data/lib/rdoc/markup/document.rb +127 -123
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/formatter.rb +220 -203
- data/lib/rdoc/markup/hard_break.rb +30 -27
- data/lib/rdoc/markup/heading.rb +163 -77
- data/lib/rdoc/markup/include.rb +33 -29
- data/lib/rdoc/markup/indented_paragraph.rb +37 -33
- data/lib/rdoc/markup/inline_parser.rb +316 -0
- data/lib/rdoc/markup/list.rb +80 -88
- data/lib/rdoc/markup/list_item.rb +73 -85
- data/lib/rdoc/markup/paragraph.rb +23 -19
- data/lib/rdoc/markup/parser.rb +501 -497
- data/lib/rdoc/markup/pre_process.rb +284 -305
- data/lib/rdoc/markup/raw.rb +52 -55
- data/lib/rdoc/markup/rule.rb +16 -12
- data/lib/rdoc/markup/table.rb +48 -40
- data/lib/rdoc/markup/to_ansi.rb +143 -92
- data/lib/rdoc/markup/to_bs.rb +86 -102
- data/lib/rdoc/markup/to_html.rb +608 -506
- data/lib/rdoc/markup/to_html_crossref.rb +219 -210
- data/lib/rdoc/markup/to_html_snippet.rb +210 -205
- data/lib/rdoc/markup/to_joined_paragraph.rb +40 -41
- data/lib/rdoc/markup/to_label.rb +64 -51
- data/lib/rdoc/markup/to_markdown.rb +212 -184
- data/lib/rdoc/markup/to_rdoc.rb +341 -277
- data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
- data/lib/rdoc/markup/to_test.rb +62 -50
- data/lib/rdoc/markup/to_tt_only.rb +83 -92
- data/lib/rdoc/markup/verbatim.rb +62 -58
- data/lib/rdoc/markup.rb +196 -215
- data/lib/rdoc/options.rb +1063 -1076
- data/lib/rdoc/parser/c.rb +1039 -1036
- data/lib/rdoc/parser/changelog.rb +320 -287
- data/lib/rdoc/parser/markdown.rb +17 -13
- data/lib/rdoc/parser/rbs.rb +279 -0
- data/lib/rdoc/parser/rd.rb +17 -13
- data/lib/rdoc/parser/ruby.rb +1231 -2222
- data/lib/rdoc/parser/ruby_colorizer.rb +303 -0
- data/lib/rdoc/parser/simple.rb +31 -27
- data/lib/rdoc/parser/text.rb +12 -8
- data/lib/rdoc/parser.rb +230 -221
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/inline.rb +57 -53
- data/lib/rdoc/rd.rb +90 -88
- data/lib/rdoc/rdoc.rb +547 -366
- data/lib/rdoc/ri/driver.rb +1141 -1130
- data/lib/rdoc/ri/formatter.rb +7 -3
- data/lib/rdoc/ri/paths.rb +140 -136
- data/lib/rdoc/ri/servlet.rb +456 -0
- data/lib/rdoc/ri/store.rb +4 -2
- data/lib/rdoc/ri/task.rb +55 -51
- data/lib/rdoc/ri.rb +14 -11
- data/lib/rdoc/rubygems_hook.rb +194 -192
- data/lib/rdoc/server.rb +462 -0
- data/lib/rdoc/stats/normal.rb +46 -42
- data/lib/rdoc/stats/quiet.rb +39 -35
- data/lib/rdoc/stats/verbose.rb +35 -31
- data/lib/rdoc/stats.rb +363 -338
- data/lib/rdoc/store.rb +919 -725
- data/lib/rdoc/task.rb +260 -255
- data/lib/rdoc/text.rb +164 -240
- data/lib/rdoc/token_stream.rb +88 -106
- data/lib/rdoc/tom_doc.rb +203 -201
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +35 -7
- data/lib/rubygems_plugin.rb +2 -11
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +9 -7
- metadata +46 -32
- data/CONTRIBUTING.rdoc +0 -219
- data/ExampleMarkdown.md +0 -39
- data/ExampleRDoc.rdoc +0 -210
- data/lib/rdoc/code_object/anon_class.rb +0 -10
- data/lib/rdoc/code_object/ghost_method.rb +0 -6
- data/lib/rdoc/code_object/meta_method.rb +0 -6
- data/lib/rdoc/markdown/literals.kpeg +0 -21
- data/lib/rdoc/markdown/literals.rb +0 -454
- data/lib/rdoc/markup/attr_changer.rb +0 -22
- data/lib/rdoc/markup/attr_span.rb +0 -35
- data/lib/rdoc/markup/attribute_manager.rb +0 -405
- data/lib/rdoc/markup/attributes.rb +0 -70
- data/lib/rdoc/markup/regexp_handling.rb +0 -40
- data/lib/rdoc/parser/prism_ruby.rb +0 -1100
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -302
- data/lib/rdoc/parser/ruby_tools.rb +0 -163
- data/lib/rdoc/servlet.rb +0 -452
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
<% if namespace[:self] %>
|
|
27
27
|
<span><%= namespace[:name] %></span>
|
|
28
28
|
<% else %>
|
|
29
|
-
<a href="<%= namespace[:path] %>"><%= namespace[:name] %></a><span>::</span>
|
|
29
|
+
<a href="<%= namespace[:path] %>"><%= namespace[:name] %></a><span class="separator">::</span>
|
|
30
30
|
<% end %>
|
|
31
31
|
</li>
|
|
32
32
|
<% end %>
|
|
33
33
|
</ol>
|
|
34
34
|
<% end %>
|
|
35
35
|
|
|
36
|
+
<span id="<%= h klass.legacy_aref %>" class="legacy-anchor"></span>
|
|
36
37
|
<h1 id="<%= h klass.aref %>" class="anchor-link <%= klass.type %>">
|
|
37
38
|
<%= klass.type %> <%= klass.full_name %>
|
|
38
39
|
</h1>
|
|
@@ -42,8 +43,9 @@
|
|
|
42
43
|
</section>
|
|
43
44
|
|
|
44
45
|
<%- klass.each_section do |section, constants, attributes| %>
|
|
46
|
+
<span id="<%= section.legacy_aref %>" class="legacy-anchor"></span>
|
|
45
47
|
<section id="<%= section.aref %>" class="documentation-section anchor-link">
|
|
46
|
-
<%- if section.title
|
|
48
|
+
<%- if section.title %>
|
|
47
49
|
<header class="documentation-section-title">
|
|
48
50
|
<h2>
|
|
49
51
|
<%= section.title %>
|
|
@@ -54,13 +56,13 @@
|
|
|
54
56
|
</header>
|
|
55
57
|
<%- end %>
|
|
56
58
|
|
|
57
|
-
<%- if section.comment
|
|
59
|
+
<%- if section.comment %>
|
|
58
60
|
<div>
|
|
59
61
|
<%= section.description %>
|
|
60
62
|
</div>
|
|
61
63
|
<%- end %>
|
|
62
64
|
|
|
63
|
-
<%- unless constants.empty?
|
|
65
|
+
<%- unless constants.empty? %>
|
|
64
66
|
<section class="constants-list">
|
|
65
67
|
<header>
|
|
66
68
|
<h3>Constants</h3>
|
|
@@ -68,9 +70,9 @@
|
|
|
68
70
|
<dl>
|
|
69
71
|
<%- constants.each do |const| %>
|
|
70
72
|
<dt id="<%= const.name %>"><%= const.name %></dt>
|
|
71
|
-
<%- if const.comment
|
|
73
|
+
<%- if const.comment %>
|
|
72
74
|
<dd>
|
|
73
|
-
<%- if const.mixin_from
|
|
75
|
+
<%- if const.mixin_from %>
|
|
74
76
|
<div class="mixin-from">
|
|
75
77
|
Included from <a href="<%= klass.aref_to(const.mixin_from.path) %>"><%= const.mixin_from.full_name %></a>
|
|
76
78
|
</div>
|
|
@@ -85,7 +87,7 @@
|
|
|
85
87
|
</section>
|
|
86
88
|
<%- end %>
|
|
87
89
|
|
|
88
|
-
<%- unless attributes.empty?
|
|
90
|
+
<%- unless attributes.empty? %>
|
|
89
91
|
<section class="attribute-method-details method-section">
|
|
90
92
|
<header>
|
|
91
93
|
<h3>Attributes</h3>
|
|
@@ -101,12 +103,12 @@
|
|
|
101
103
|
</div>
|
|
102
104
|
|
|
103
105
|
<div class="method-description">
|
|
104
|
-
<%- if attrib.mixin_from
|
|
106
|
+
<%- if attrib.mixin_from %>
|
|
105
107
|
<div class="mixin-from">
|
|
106
108
|
<%= attrib.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(attrib.mixin_from.path) %>"><%= attrib.mixin_from.full_name %></a>
|
|
107
109
|
</div>
|
|
108
110
|
<%- end %>
|
|
109
|
-
<%- if attrib.comment
|
|
111
|
+
<%- if attrib.comment %>
|
|
110
112
|
<%= attrib.description.strip %>
|
|
111
113
|
<%- else %>
|
|
112
114
|
<p class="missing-docs">(Not documented)</p>
|
|
@@ -117,10 +119,10 @@
|
|
|
117
119
|
</section>
|
|
118
120
|
<%- end %>
|
|
119
121
|
|
|
120
|
-
<%- klass.methods_by_type(section).each do |type, visibilities|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
<%- klass.methods_by_type(section).each do |type, visibilities| %>
|
|
123
|
+
<%- next if visibilities.empty? %>
|
|
124
|
+
<%- visibilities.each do |visibility, methods| %>
|
|
125
|
+
<%- next if methods.empty? %>
|
|
124
126
|
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
|
|
125
127
|
<header>
|
|
126
128
|
<h3><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
|
|
@@ -129,7 +131,7 @@
|
|
|
129
131
|
<%- methods.each do |method| %>
|
|
130
132
|
<div id="<%= method.aref %>" class="method-detail anchor-link <%= method.is_alias_for ? "method-alias" : '' %>">
|
|
131
133
|
<div class="method-header">
|
|
132
|
-
<%- if (call_seq = method.call_seq)
|
|
134
|
+
<%- if (call_seq = method.call_seq) %>
|
|
133
135
|
<%- call_seq.strip.split("\n").each_with_index do |call_seq, i| %>
|
|
134
136
|
<div class="method-heading">
|
|
135
137
|
<a href="#<%= method.aref %>" title="Link to this method">
|
|
@@ -141,7 +143,7 @@
|
|
|
141
143
|
</a>
|
|
142
144
|
</div>
|
|
143
145
|
<%- end %>
|
|
144
|
-
<%- elsif method.has_call_seq?
|
|
146
|
+
<%- elsif method.has_call_seq? %>
|
|
145
147
|
<div class="method-heading">
|
|
146
148
|
<a href="#<%= method.aref %>" title="Link to this method">
|
|
147
149
|
<span class="method-name"><%= h method.name %></span>
|
|
@@ -163,38 +165,33 @@
|
|
|
163
165
|
<summary>Source</summary>
|
|
164
166
|
</details>
|
|
165
167
|
</div>
|
|
166
|
-
<%- end %>
|
|
167
|
-
|
|
168
|
-
<%- unless method.skip_description? then %>
|
|
169
|
-
<div class="method-description">
|
|
170
|
-
<%- if method.token_stream then %>
|
|
171
168
|
<div class="method-source-code" id="<%= method.html_name %>-source">
|
|
172
169
|
<pre><%= method.markup_code %></pre>
|
|
173
170
|
</div>
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
<%- end %>
|
|
172
|
+
|
|
173
|
+
<%- unless method.skip_description? %>
|
|
174
|
+
<div class="method-description">
|
|
175
|
+
<%- if method.mixin_from %>
|
|
176
176
|
<div class="mixin-from">
|
|
177
177
|
<%= method.singleton ? "Extended" : "Included" %> from <a href="<%= klass.aref_to(method.mixin_from.path) %>"><%= method.mixin_from.full_name %></a>
|
|
178
178
|
</div>
|
|
179
179
|
<%- end %>
|
|
180
|
-
<%- if method.comment
|
|
180
|
+
<%- if method.comment %>
|
|
181
181
|
<%= method.description.strip %>
|
|
182
182
|
<%- else %>
|
|
183
183
|
<p class="missing-docs">(Not documented)</p>
|
|
184
184
|
<%- end %>
|
|
185
|
-
<%- if method.calls_super
|
|
185
|
+
<%- if method.calls_super %>
|
|
186
186
|
<div class="method-calls-super">
|
|
187
187
|
Calls superclass method
|
|
188
|
-
<%=
|
|
189
|
-
method.superclass_method ?
|
|
190
|
-
method.formatter.link(method.superclass_method.full_name, method.superclass_method.full_name) : nil
|
|
191
|
-
%>
|
|
188
|
+
<%= method.superclass_method_link %>
|
|
192
189
|
</div>
|
|
193
190
|
<%- end %>
|
|
194
191
|
</div>
|
|
195
192
|
<%- end %>
|
|
196
193
|
|
|
197
|
-
<%- unless method.aliases.empty?
|
|
194
|
+
<%- unless method.aliases.empty? %>
|
|
198
195
|
<div class="aliases">
|
|
199
196
|
Also aliased as: <%= method.aliases.map do |aka|
|
|
200
197
|
if aka.parent then # HACK lib/rexml/encodings
|
|
@@ -206,7 +203,7 @@
|
|
|
206
203
|
</div>
|
|
207
204
|
<%- end %>
|
|
208
205
|
|
|
209
|
-
<%- if method.is_alias_for
|
|
206
|
+
<%- if method.is_alias_for %>
|
|
210
207
|
<div class="aliases">
|
|
211
208
|
Alias for: <a href="<%= klass.aref_to method.is_alias_for.path %>"><%= h method.is_alias_for.name %></a>
|
|
212
209
|
</div>
|
|
@@ -215,8 +212,8 @@
|
|
|
215
212
|
|
|
216
213
|
<%- end %>
|
|
217
214
|
</section>
|
|
218
|
-
<%- end
|
|
219
|
-
|
|
215
|
+
<%- end %>
|
|
216
|
+
<%- end %>
|
|
220
217
|
</section>
|
|
221
218
|
<%- end %>
|
|
222
219
|
</main>
|
|
@@ -92,6 +92,25 @@ main .anchor-link:target {
|
|
|
92
92
|
scroll-margin-top: 1rem;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/* Legacy anchor for backward compatibility with old label- prefix links */
|
|
96
|
+
.legacy-anchor {
|
|
97
|
+
display: block;
|
|
98
|
+
position: relative;
|
|
99
|
+
visibility: hidden;
|
|
100
|
+
scroll-margin-top: 1rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* When a legacy anchor is targeted, highlight the next heading sibling */
|
|
104
|
+
.legacy-anchor:target + h1,
|
|
105
|
+
.legacy-anchor:target + h2,
|
|
106
|
+
.legacy-anchor:target + h3,
|
|
107
|
+
.legacy-anchor:target + h4,
|
|
108
|
+
.legacy-anchor:target + h5,
|
|
109
|
+
.legacy-anchor:target + h6 {
|
|
110
|
+
margin-left: -10px;
|
|
111
|
+
border-left: 10px solid var(--border-color);
|
|
112
|
+
}
|
|
113
|
+
|
|
95
114
|
/* 4. Links */
|
|
96
115
|
a {
|
|
97
116
|
color: var(--link-color);
|
|
@@ -430,7 +449,6 @@ main h6 {
|
|
|
430
449
|
.ruby-ivar { color: #B57614; } /* Brown */
|
|
431
450
|
.ruby-operator { color: #427B58; } /* Dark Teal */
|
|
432
451
|
.ruby-identifier { color: #076678; } /* Deep Teal */
|
|
433
|
-
.ruby-node { color: #8F3F71; } /* Plum */
|
|
434
452
|
.ruby-comment { color: #928374; font-style: italic; } /* Gray */
|
|
435
453
|
.ruby-regexp { color: #8F3F71; } /* Plum */
|
|
436
454
|
.ruby-value { color: #AF3A03; } /* Dark Orange */
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<h1 class="class"><%= h @title %></h1>
|
|
15
15
|
|
|
16
16
|
<%- simple_files = @files.select { |f| f.text? } %>
|
|
17
|
-
<%- unless simple_files.empty?
|
|
17
|
+
<%- unless simple_files.empty? %>
|
|
18
18
|
<h2 id="pages">Pages</h2>
|
|
19
19
|
<ul>
|
|
20
20
|
<%- simple_files.sort.each do |file| %>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<%
|
|
24
24
|
# HACK table_of_contents should not exist on Document
|
|
25
25
|
table = file.parse(file.comment).table_of_contents
|
|
26
|
-
unless table.empty?
|
|
26
|
+
unless table.empty? %>
|
|
27
27
|
<ul>
|
|
28
28
|
<%- table.each do |heading| %>
|
|
29
29
|
<li><a href="<%= h file.path %>#<%= heading.aref %>"><%= heading.plain_html %></a></li>
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
table.concat klass.parse(klass.comment_location).table_of_contents
|
|
45
45
|
table.concat klass.section_contents
|
|
46
46
|
|
|
47
|
-
unless table.empty?
|
|
47
|
+
unless table.empty? %>
|
|
48
48
|
<ul>
|
|
49
49
|
<%- table.each do |item| %>
|
|
50
50
|
<%- label = item.respond_to?(:label) ? item.label(klass) : item.aref %>
|
data/lib/rdoc/generator.rb
CHANGED
|
@@ -1,52 +1,54 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# RDoc
|
|
5
|
-
#
|
|
6
|
-
# RDoc::Generator::
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
# for
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
# RDoc
|
|
35
|
-
#
|
|
36
|
-
# RDoc
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
2
|
+
module RDoc
|
|
3
|
+
##
|
|
4
|
+
# RDoc uses generators to turn parsed source code in the form of an
|
|
5
|
+
# RDoc::CodeObject tree into some form of output. RDoc comes with the HTML
|
|
6
|
+
# generator RDoc::Generator::Darkfish and an ri data generator
|
|
7
|
+
# RDoc::Generator::RI.
|
|
8
|
+
#
|
|
9
|
+
# == Registering a Generator
|
|
10
|
+
#
|
|
11
|
+
# Generators are registered by calling RDoc::RDoc.add_generator with the class
|
|
12
|
+
# of the generator:
|
|
13
|
+
#
|
|
14
|
+
# class My::Awesome::Generator
|
|
15
|
+
# RDoc::RDoc.add_generator self
|
|
16
|
+
# end
|
|
17
|
+
#
|
|
18
|
+
# == Adding Options to +rdoc+
|
|
19
|
+
#
|
|
20
|
+
# Before option processing in +rdoc+, RDoc::Options will call ::setup_options
|
|
21
|
+
# on the generator class with an RDoc::Options instance. The generator can
|
|
22
|
+
# use RDoc::Options#option_parser to add command-line options to the +rdoc+
|
|
23
|
+
# tool. See RDoc::Options@Custom+Options for an example and see OptionParser
|
|
24
|
+
# for details on how to add options.
|
|
25
|
+
#
|
|
26
|
+
# You can extend the RDoc::Options instance with additional accessors for your
|
|
27
|
+
# generator.
|
|
28
|
+
#
|
|
29
|
+
# == Generator Instantiation
|
|
30
|
+
#
|
|
31
|
+
# After parsing, RDoc::RDoc will instantiate a generator by calling
|
|
32
|
+
# #initialize with an RDoc::Store instance and an RDoc::Options instance.
|
|
33
|
+
#
|
|
34
|
+
# The RDoc::Store instance holds documentation for parsed source code. In
|
|
35
|
+
# RDoc 3 and earlier the RDoc::TopLevel class held this data. When upgrading
|
|
36
|
+
# a generator from RDoc 3 and earlier you should only need to replace
|
|
37
|
+
# RDoc::TopLevel with the store instance.
|
|
38
|
+
#
|
|
39
|
+
# RDoc will then call #generate on the generator instance. You can use the
|
|
40
|
+
# various methods on RDoc::Store and in the RDoc::CodeObject tree to create
|
|
41
|
+
# your desired output format.
|
|
41
42
|
|
|
42
|
-
module
|
|
43
|
+
module Generator
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
autoload :Markup, "#{__dir__}/generator/markup"
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
autoload :Aliki, "#{__dir__}/generator/aliki"
|
|
48
|
+
autoload :Darkfish, "#{__dir__}/generator/darkfish"
|
|
49
|
+
autoload :JsonIndex, "#{__dir__}/generator/json_index"
|
|
50
|
+
autoload :RI, "#{__dir__}/generator/ri"
|
|
51
|
+
autoload :POT, "#{__dir__}/generator/pot"
|
|
51
52
|
|
|
53
|
+
end
|
|
52
54
|
end
|
data/lib/rdoc/i18n/locale.rb
CHANGED
|
@@ -1,102 +1,106 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# This object provides the following two features:
|
|
6
|
-
#
|
|
7
|
-
# * Loads translated messages from .po file.
|
|
8
|
-
# * Translates a message into the locale.
|
|
9
|
-
|
|
10
|
-
class RDoc::I18n::Locale
|
|
11
|
-
|
|
12
|
-
@@locales = {} # :nodoc:
|
|
13
|
-
|
|
14
|
-
class << self
|
|
15
|
-
|
|
2
|
+
module RDoc
|
|
3
|
+
module I18n
|
|
16
4
|
##
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
def [](locale_name)
|
|
20
|
-
@@locales[locale_name] ||= new(locale_name)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
##
|
|
24
|
-
# Sets the locale object for +locale_name+.
|
|
5
|
+
# A message container for a locale.
|
|
25
6
|
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
7
|
+
# This object provides the following two features:
|
|
8
|
+
#
|
|
9
|
+
# * Loads translated messages from .po file.
|
|
10
|
+
# * Translates a message into the locale.
|
|
11
|
+
|
|
12
|
+
class Locale
|
|
13
|
+
|
|
14
|
+
@@locales = {} # :nodoc:
|
|
15
|
+
|
|
16
|
+
class << self
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# Returns the locale object for +locale_name+.
|
|
20
|
+
|
|
21
|
+
def [](locale_name)
|
|
22
|
+
@@locales[locale_name] ||= new(locale_name)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
##
|
|
26
|
+
# Sets the locale object for +locale_name+.
|
|
27
|
+
#
|
|
28
|
+
# Normally, this method is not used. This method is useful for
|
|
29
|
+
# testing.
|
|
30
|
+
|
|
31
|
+
def []=(locale_name, locale)
|
|
32
|
+
@@locales[locale_name] = locale
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# The name of the locale. It uses IETF language tag format
|
|
39
|
+
# +[language[_territory][.codeset][@modifier]]+.
|
|
40
|
+
#
|
|
41
|
+
# See also {BCP 47 - Tags for Identifying
|
|
42
|
+
# Languages}[http://tools.ietf.org/rfc/bcp/bcp47.txt].
|
|
43
|
+
|
|
44
|
+
attr_reader :name
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# Creates a new locale object for +name+ locale. +name+ must
|
|
48
|
+
# follow IETF language tag format.
|
|
49
|
+
|
|
50
|
+
def initialize(name)
|
|
51
|
+
@name = name
|
|
52
|
+
@messages = {}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
##
|
|
56
|
+
# Loads translation messages from +locale_directory+/+@name+/rdoc.po
|
|
57
|
+
# or +locale_directory+/+@name+.po. The former has high priority.
|
|
58
|
+
#
|
|
59
|
+
# This method requires gettext gem for parsing .po file. If you
|
|
60
|
+
# don't have gettext gem, this method doesn't load .po file. This
|
|
61
|
+
# method warns and returns +false+.
|
|
62
|
+
#
|
|
63
|
+
# Returns +true+ if succeeded, +false+ otherwise.
|
|
64
|
+
|
|
65
|
+
def load(locale_directory)
|
|
66
|
+
return false if @name.nil?
|
|
67
|
+
|
|
68
|
+
po_file_candidates = [
|
|
69
|
+
File.join(locale_directory, @name, 'rdoc.po'),
|
|
70
|
+
File.join(locale_directory, "#{@name}.po"),
|
|
71
|
+
]
|
|
72
|
+
po_file = po_file_candidates.find do |po_file_candidate|
|
|
73
|
+
File.exist?(po_file_candidate)
|
|
74
|
+
end
|
|
75
|
+
return false unless po_file
|
|
76
|
+
|
|
77
|
+
begin
|
|
78
|
+
require 'gettext/po_parser'
|
|
79
|
+
require 'gettext/mo'
|
|
80
|
+
rescue LoadError
|
|
81
|
+
warn('Need gettext gem for i18n feature:')
|
|
82
|
+
warn(' gem install gettext')
|
|
83
|
+
return false
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
po_parser = GetText::POParser.new
|
|
87
|
+
messages = GetText::MO.new
|
|
88
|
+
po_parser.report_warning = false
|
|
89
|
+
po_parser.parse_file(po_file, messages)
|
|
90
|
+
|
|
91
|
+
@messages.merge!(messages)
|
|
92
|
+
|
|
93
|
+
true
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
##
|
|
97
|
+
# Translates the +message+ into locale. If there is no translation
|
|
98
|
+
# messages for +message+ in locale, +message+ itself is returned.
|
|
99
|
+
|
|
100
|
+
def translate(message)
|
|
101
|
+
@messages[message] || message
|
|
102
|
+
end
|
|
52
103
|
|
|
53
|
-
##
|
|
54
|
-
# Loads translation messages from +locale_directory+/+@name+/rdoc.po
|
|
55
|
-
# or +locale_directory+/+@name+.po. The former has high priority.
|
|
56
|
-
#
|
|
57
|
-
# This method requires gettext gem for parsing .po file. If you
|
|
58
|
-
# don't have gettext gem, this method doesn't load .po file. This
|
|
59
|
-
# method warns and returns +false+.
|
|
60
|
-
#
|
|
61
|
-
# Returns +true+ if succeeded, +false+ otherwise.
|
|
62
|
-
|
|
63
|
-
def load(locale_directory)
|
|
64
|
-
return false if @name.nil?
|
|
65
|
-
|
|
66
|
-
po_file_candidates = [
|
|
67
|
-
File.join(locale_directory, @name, 'rdoc.po'),
|
|
68
|
-
File.join(locale_directory, "#{@name}.po"),
|
|
69
|
-
]
|
|
70
|
-
po_file = po_file_candidates.find do |po_file_candidate|
|
|
71
|
-
File.exist?(po_file_candidate)
|
|
72
|
-
end
|
|
73
|
-
return false unless po_file
|
|
74
|
-
|
|
75
|
-
begin
|
|
76
|
-
require 'gettext/po_parser'
|
|
77
|
-
require 'gettext/mo'
|
|
78
|
-
rescue LoadError
|
|
79
|
-
warn('Need gettext gem for i18n feature:')
|
|
80
|
-
warn(' gem install gettext')
|
|
81
|
-
return false
|
|
82
104
|
end
|
|
83
|
-
|
|
84
|
-
po_parser = GetText::POParser.new
|
|
85
|
-
messages = GetText::MO.new
|
|
86
|
-
po_parser.report_warning = false
|
|
87
|
-
po_parser.parse_file(po_file, messages)
|
|
88
|
-
|
|
89
|
-
@messages.merge!(messages)
|
|
90
|
-
|
|
91
|
-
true
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
##
|
|
95
|
-
# Translates the +message+ into locale. If there is no translation
|
|
96
|
-
# messages for +message+ in locale, +message+ itself is returned.
|
|
97
|
-
|
|
98
|
-
def translate(message)
|
|
99
|
-
@messages[message] || message
|
|
100
105
|
end
|
|
101
|
-
|
|
102
106
|
end
|