rdoc 7.0.1 → 7.0.3
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 +9 -0
- data/lib/rdoc/code_object/class_module.rb +25 -8
- data/lib/rdoc/generator/darkfish.rb +3 -1
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/class.rhtml +7 -7
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +0 -1
- data/lib/rdoc/generator/template/aliki/index.rhtml +1 -1
- data/lib/rdoc/generator/template/aliki/js/aliki.js +24 -17
- data/lib/rdoc/generator/template/aliki/js/search_controller.js +9 -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 +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/class.rhtml +6 -6
- data/lib/rdoc/markup/blank_line.rb +25 -23
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/hard_break.rb +30 -27
- data/lib/rdoc/markup/heading.rb +96 -79
- data/lib/rdoc/markup/raw.rb +52 -55
- data/lib/rdoc/markup/table.rb +48 -40
- data/lib/rdoc/markup.rb +1 -0
- data/lib/rdoc/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e115c57c1541a612613ea80a869ce964b13aee43badba6c75bae66aa70495e29
|
|
4
|
+
data.tar.gz: 5a0dfd61dc9a5116612d939f3d94197fe687667cd8185d00983afb3fea38aade
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc7d789798d547865d5205eafbb6b8db9b5b16bc422c5fba3658952a8568248eda44aba606c1c1cac335af38babdf18bf4a2aa56f1c7189fe894858e154c9353
|
|
7
|
+
data.tar.gz: da731f564307246734edefbc271577d434b3d4527d865cd2c6575db5dce5d36caab97925204bacbb1a2063aff4109a55db5c269829df32e5ac29163b366b8c7d
|
data/CONTRIBUTING.md
CHANGED
|
@@ -86,6 +86,15 @@ npm run lint:css
|
|
|
86
86
|
npm run lint:css -- --fix
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
## Type annotations
|
|
90
|
+
|
|
91
|
+
RDoc is currently not a typed codebase. Despite not running a type checker, contributors have been
|
|
92
|
+
adding some comment annotations to make the codebase easier to navigate and understand.
|
|
93
|
+
|
|
94
|
+
These annotations use [Sorbet flavored RBS](https://sorbet.org/docs/rbs-support) annotations,
|
|
95
|
+
so that we can tag definitions as abstract and override. For more information on RBS syntax,
|
|
96
|
+
see the [documentation](https://github.com/ruby/rbs/blob/master/docs/syntax.md).
|
|
97
|
+
|
|
89
98
|
## Parser Generation
|
|
90
99
|
|
|
91
100
|
RDoc uses generated parsers for Markdown and RD formats.
|
|
@@ -30,7 +30,22 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
30
30
|
attr_accessor :constant_aliases
|
|
31
31
|
|
|
32
32
|
##
|
|
33
|
-
#
|
|
33
|
+
# An array of `[comment, location]` pairs documenting this class/module.
|
|
34
|
+
# Use #add_comment to add comments.
|
|
35
|
+
#
|
|
36
|
+
# Before marshalling:
|
|
37
|
+
# - +comment+ is a String
|
|
38
|
+
# - +location+ is an RDoc::TopLevel
|
|
39
|
+
#
|
|
40
|
+
# After unmarshalling:
|
|
41
|
+
# - +comment+ is an RDoc::Markup::Document
|
|
42
|
+
# - +location+ is a filename String
|
|
43
|
+
#
|
|
44
|
+
# These type changes are acceptable (for now) because:
|
|
45
|
+
# - +comment+: Both String and Document respond to #empty?, and #parse
|
|
46
|
+
# returns Document as-is (see RDoc::Text#parse)
|
|
47
|
+
# - +location+: Only used by #parse to set Document#file, which accepts
|
|
48
|
+
# both TopLevel (extracts relative_name) and String
|
|
34
49
|
|
|
35
50
|
attr_accessor :comment_location
|
|
36
51
|
|
|
@@ -110,7 +125,7 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
110
125
|
@is_alias_for = nil
|
|
111
126
|
@name = name
|
|
112
127
|
@superclass = superclass
|
|
113
|
-
@comment_location = [] # [
|
|
128
|
+
@comment_location = [] # Array of [comment, location] pairs
|
|
114
129
|
|
|
115
130
|
super()
|
|
116
131
|
end
|
|
@@ -379,10 +394,10 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
379
394
|
|
|
380
395
|
@comment = RDoc::Comment.from_document document
|
|
381
396
|
|
|
382
|
-
@comment_location = if RDoc::Markup::Document
|
|
383
|
-
document
|
|
397
|
+
@comment_location = if document.parts.first.is_a?(RDoc::Markup::Document)
|
|
398
|
+
document.parts.map { |doc| [doc, doc.file] }
|
|
384
399
|
else
|
|
385
|
-
|
|
400
|
+
[[document, document.file]]
|
|
386
401
|
end
|
|
387
402
|
|
|
388
403
|
array[5].each do |name, rw, visibility, singleton, file|
|
|
@@ -807,11 +822,13 @@ class RDoc::ClassModule < RDoc::Context
|
|
|
807
822
|
cm_alias = cm.dup
|
|
808
823
|
cm_alias.name = const.name
|
|
809
824
|
|
|
810
|
-
|
|
811
|
-
|
|
825
|
+
if full_name == 'Object'
|
|
826
|
+
# Don't move top-level aliases under Object, they look ugly there
|
|
827
|
+
cm_alias.parent = top_level
|
|
828
|
+
else
|
|
812
829
|
cm_alias.parent = self
|
|
813
|
-
cm_alias.full_name = nil # force update for new parent
|
|
814
830
|
end
|
|
831
|
+
cm_alias.full_name = nil # force update for new parent
|
|
815
832
|
|
|
816
833
|
cm_alias.aliases.clear
|
|
817
834
|
cm_alias.is_alias_for = cm
|
|
@@ -356,7 +356,9 @@ class RDoc::Generator::Darkfish
|
|
|
356
356
|
|
|
357
357
|
current = nil
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
# Document files are generated only for non-alias classes/modules
|
|
360
|
+
@classes.reject(&:is_alias_for).each do |klass|
|
|
361
|
+
|
|
360
362
|
current = klass
|
|
361
363
|
|
|
362
364
|
generate_class klass, template_file
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<%= render '_header.rhtml' %>
|
|
4
4
|
<%= render '_sidebar_toggle.rhtml' %>
|
|
5
5
|
|
|
6
|
-
<nav id="navigation" role="navigation">
|
|
6
|
+
<nav id="navigation" role="navigation" hidden>
|
|
7
7
|
<%= render '_sidebar_pages.rhtml' %>
|
|
8
8
|
<%= render '_sidebar_sections.rhtml' %>
|
|
9
9
|
<%= render '_sidebar_ancestors.rhtml' %>
|
|
@@ -110,10 +110,10 @@
|
|
|
110
110
|
</section>
|
|
111
111
|
<%- end %>
|
|
112
112
|
|
|
113
|
-
<%- klass.methods_by_type(section).each do |type, visibilities|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
<%- klass.methods_by_type(section).each do |type, visibilities| %>
|
|
114
|
+
<%- next if visibilities.empty? %>
|
|
115
|
+
<%- visibilities.each do |visibility, methods| %>
|
|
116
|
+
<%- next if methods.empty? %>
|
|
117
117
|
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
|
|
118
118
|
<header>
|
|
119
119
|
<h3 id="<%= visibility %>-<%= type %>-methods"><a href="#<%= visibility %>-<%= type %>-methods"><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</a></h3>
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
|
|
207
207
|
<%- end %>
|
|
208
208
|
</section>
|
|
209
|
-
<%- end
|
|
210
|
-
|
|
209
|
+
<%- end %>
|
|
210
|
+
<%- end %>
|
|
211
211
|
</section>
|
|
212
212
|
<%- end %>
|
|
213
213
|
</main>
|
|
@@ -67,15 +67,7 @@ function createSearchInstance(input, result) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
search.select = function(result) {
|
|
70
|
-
|
|
71
|
-
const query = this.input.value;
|
|
72
|
-
if (query) {
|
|
73
|
-
const url = new URL(href, window.location.origin);
|
|
74
|
-
url.searchParams.set('q', query);
|
|
75
|
-
url.searchParams.set('nav', '0');
|
|
76
|
-
href = url.toString();
|
|
77
|
-
}
|
|
78
|
-
window.location.href = href;
|
|
70
|
+
window.location.href = result.firstChild.firstChild.href;
|
|
79
71
|
}
|
|
80
72
|
|
|
81
73
|
search.scrollIntoView = search.scrollInWindow;
|
|
@@ -97,15 +89,27 @@ function hookSearch() {
|
|
|
97
89
|
const search = createSearchInstance(input, result);
|
|
98
90
|
if (!search) return;
|
|
99
91
|
|
|
92
|
+
// Hide search results when clicking outside the search area
|
|
93
|
+
document.addEventListener('click', (e) => {
|
|
94
|
+
if (!e.target.closest('.navbar-search-desktop')) {
|
|
95
|
+
search.hide();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Show search results when focusing on input (if there's a query)
|
|
100
|
+
input.addEventListener('focus', () => {
|
|
101
|
+
if (input.value.trim()) {
|
|
102
|
+
search.show();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
100
106
|
// Check for ?q= URL parameter and trigger search automatically
|
|
101
107
|
if (typeof URLSearchParams !== 'undefined') {
|
|
102
108
|
const urlParams = new URLSearchParams(window.location.search);
|
|
103
109
|
const queryParam = urlParams.get('q');
|
|
104
110
|
if (queryParam) {
|
|
105
|
-
const navParam = urlParams.get('nav');
|
|
106
|
-
const autoSelect = navParam !== '0';
|
|
107
111
|
input.value = queryParam;
|
|
108
|
-
search.search(queryParam,
|
|
112
|
+
search.search(queryParam, false);
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
}
|
|
@@ -158,9 +162,12 @@ function hookSidebar() {
|
|
|
158
162
|
});
|
|
159
163
|
|
|
160
164
|
const isSmallViewport = window.matchMedia("(max-width: 1023px)").matches;
|
|
161
|
-
if (isSmallViewport) {
|
|
162
|
-
closeNav();
|
|
163
165
|
|
|
166
|
+
// The sidebar is hidden by default with the `hidden` attribute
|
|
167
|
+
// On large viewports, we display the sidebar with JavaScript
|
|
168
|
+
// This is better than the opposite approach of hiding it with JavaScript
|
|
169
|
+
// because it avoids flickering the sidebar when the page is loaded, especially on mobile devices
|
|
170
|
+
if (isSmallViewport) {
|
|
164
171
|
// Close nav when clicking links inside it
|
|
165
172
|
document.addEventListener('click', (e) => {
|
|
166
173
|
if (e.target.closest('#navigation a')) {
|
|
@@ -176,6 +183,8 @@ function hookSidebar() {
|
|
|
176
183
|
closeNav();
|
|
177
184
|
}
|
|
178
185
|
});
|
|
186
|
+
} else {
|
|
187
|
+
openNav();
|
|
179
188
|
}
|
|
180
189
|
}
|
|
181
190
|
|
|
@@ -378,9 +387,7 @@ function hookSearchModal() {
|
|
|
378
387
|
if (queryParam && isSmallViewport) {
|
|
379
388
|
openSearchModal();
|
|
380
389
|
searchInput.value = queryParam;
|
|
381
|
-
|
|
382
|
-
const autoSelect = navParam !== '0';
|
|
383
|
-
mobileSearch.search(queryParam, autoSelect);
|
|
390
|
+
mobileSearch.search(queryParam, false);
|
|
384
391
|
}
|
|
385
392
|
}
|
|
386
393
|
}
|
|
@@ -116,5 +116,14 @@ SearchController.prototype = Object.assign({}, SearchNavigation, new function()
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
this.hide = function() {
|
|
120
|
+
this.result.setAttribute('aria-expanded', 'false');
|
|
121
|
+
this.setNavigationActive(false);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
this.show = function() {
|
|
125
|
+
this.result.setAttribute('aria-expanded', 'true');
|
|
126
|
+
this.setNavigationActive(true);
|
|
127
|
+
}
|
|
119
128
|
});
|
|
120
129
|
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
</section>
|
|
118
118
|
<%- end %>
|
|
119
119
|
|
|
120
|
-
<%- klass.methods_by_type(section).each do |type, visibilities|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
<%- klass.methods_by_type(section).each do |type, visibilities| %>
|
|
121
|
+
<%- next if visibilities.empty? %>
|
|
122
|
+
<%- visibilities.each do |visibility, methods| %>
|
|
123
|
+
<%- next if methods.empty? %>
|
|
124
124
|
<section id="<%= visibility %>-<%= type %>-<%= section.aref %>-method-details" class="method-section anchor-link">
|
|
125
125
|
<header>
|
|
126
126
|
<h3><%= visibility.to_s.capitalize %> <%= type.capitalize %> Methods</h3>
|
|
@@ -213,8 +213,8 @@
|
|
|
213
213
|
|
|
214
214
|
<%- end %>
|
|
215
215
|
</section>
|
|
216
|
-
<%- end
|
|
217
|
-
|
|
216
|
+
<%- end %>
|
|
217
|
+
<%- end %>
|
|
218
218
|
</section>
|
|
219
219
|
<%- end %>
|
|
220
220
|
</main>
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
##
|
|
3
|
-
# An empty line. This class is a singleton.
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# An empty line
|
|
6
|
+
class BlankLine < Element
|
|
7
|
+
@instance = new
|
|
8
|
+
|
|
9
|
+
# RDoc::Markup::BlankLine is a singleton
|
|
10
|
+
#: () -> BlankLine
|
|
11
|
+
def self.new
|
|
12
|
+
@instance
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Calls #accept_blank_line on +visitor+
|
|
16
|
+
# @override
|
|
17
|
+
#: (untyped) -> void
|
|
18
|
+
def accept(visitor)
|
|
19
|
+
visitor.accept_blank_line(self)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# @override
|
|
23
|
+
#: (PP) -> void
|
|
24
|
+
def pretty_print(q) # :nodoc:
|
|
25
|
+
q.text("blankline")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
14
28
|
end
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
# Calls #accept_blank_line on +visitor+
|
|
18
|
-
|
|
19
|
-
def accept(visitor)
|
|
20
|
-
visitor.accept_blank_line self
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def pretty_print(q) # :nodoc:
|
|
24
|
-
q.text 'blankline'
|
|
25
|
-
end
|
|
26
|
-
|
|
27
29
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# Base class defining the interface for all markup elements found in documentation
|
|
6
|
+
# @abstract
|
|
7
|
+
class Element
|
|
8
|
+
# @abstract
|
|
9
|
+
#: (untyped) -> void
|
|
10
|
+
def accept(visitor)
|
|
11
|
+
raise NotImplementedError, "#{self.class} must implement the accept method"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @abstract
|
|
15
|
+
#: (PP) -> void
|
|
16
|
+
def pretty_print(q)
|
|
17
|
+
raise NotImplementedError, "#{self.class} must implement the pretty_print method"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
##
|
|
3
|
-
# A hard-break in the middle of a paragraph.
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# A hard-break in the middle of a paragraph.
|
|
6
|
+
class HardBreak < Element
|
|
7
|
+
@instance = new
|
|
8
|
+
|
|
9
|
+
# RDoc::Markup::HardBreak is a singleton
|
|
10
|
+
#: () -> HardBreak
|
|
11
|
+
def self.new
|
|
12
|
+
@instance
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Calls #accept_hard_break on +visitor+
|
|
16
|
+
# @override
|
|
17
|
+
#: (untyped) -> void
|
|
18
|
+
def accept(visitor)
|
|
19
|
+
visitor.accept_hard_break(self)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
#: (top) -> bool
|
|
23
|
+
def ==(other) # :nodoc:
|
|
24
|
+
self.class === other
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @override
|
|
28
|
+
#: (PP) -> void
|
|
29
|
+
def pretty_print(q) # :nodoc:
|
|
30
|
+
q.text("[break]")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
21
33
|
end
|
|
22
|
-
|
|
23
|
-
def ==(other) # :nodoc:
|
|
24
|
-
self.class === other
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def pretty_print(q) # :nodoc:
|
|
28
|
-
q.text "[break]"
|
|
29
|
-
end
|
|
30
|
-
|
|
31
34
|
end
|
data/lib/rdoc/markup/heading.rb
CHANGED
|
@@ -1,84 +1,101 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
##
|
|
3
|
-
# A heading with a level (1-6) and text
|
|
4
2
|
|
|
5
|
-
RDoc
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# A heading with a level (1-6) and text
|
|
6
|
+
#
|
|
7
|
+
# RDoc syntax:
|
|
8
|
+
# = Heading 1
|
|
9
|
+
# == Heading 2
|
|
10
|
+
# === Heading 3
|
|
11
|
+
#
|
|
12
|
+
# Markdown syntax:
|
|
13
|
+
# # Heading 1
|
|
14
|
+
# ## Heading 2
|
|
15
|
+
# ### Heading 3
|
|
16
|
+
class Heading < Element
|
|
17
|
+
#: String
|
|
18
|
+
attr_reader :text
|
|
19
|
+
|
|
20
|
+
#: Integer
|
|
21
|
+
attr_accessor :level
|
|
22
|
+
|
|
23
|
+
# A singleton RDoc::Markup::ToLabel formatter for headings.
|
|
24
|
+
#: () -> RDoc::Markup::ToLabel
|
|
25
|
+
def self.to_label
|
|
26
|
+
@to_label ||= Markup::ToLabel.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# A singleton plain HTML formatter for headings. Used for creating labels for the Table of Contents
|
|
30
|
+
#: () -> RDoc::Markup::ToHtml
|
|
31
|
+
def self.to_html
|
|
32
|
+
@to_html ||= begin
|
|
33
|
+
markup = Markup.new
|
|
34
|
+
markup.add_regexp_handling CrossReference::CROSSREF_REGEXP, :CROSSREF
|
|
35
|
+
|
|
36
|
+
to_html = Markup::ToHtml.new nil
|
|
37
|
+
|
|
38
|
+
def to_html.handle_regexp_CROSSREF(target)
|
|
39
|
+
target.text.sub(/^\\/, '')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
to_html
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
#: (Integer, String) -> void
|
|
47
|
+
def initialize(level, text)
|
|
48
|
+
super()
|
|
49
|
+
|
|
50
|
+
@level = level
|
|
51
|
+
@text = text
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
#: (Object) -> bool
|
|
55
|
+
def ==(other)
|
|
56
|
+
other.is_a?(Heading) && other.level == @level && other.text == @text
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @override
|
|
60
|
+
#: (untyped) -> void
|
|
61
|
+
def accept(visitor)
|
|
62
|
+
visitor.accept_heading(self)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# An HTML-safe anchor reference for this header.
|
|
66
|
+
#: () -> String
|
|
67
|
+
def aref
|
|
68
|
+
"label-#{self.class.to_label.convert text.dup}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Creates a fully-qualified label which will include the label from +context+. This helps keep ids unique in HTML.
|
|
72
|
+
#: (RDoc::Context?) -> String
|
|
73
|
+
def label(context = nil)
|
|
74
|
+
label = +""
|
|
75
|
+
label << "#{context.aref}-" if context&.respond_to?(:aref)
|
|
76
|
+
label << aref
|
|
77
|
+
label
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# HTML markup of the text of this label without the surrounding header element.
|
|
81
|
+
#: () -> String
|
|
82
|
+
def plain_html
|
|
83
|
+
no_image_text = text
|
|
84
|
+
|
|
85
|
+
if matched = no_image_text.match(/rdoc-image:[^:]+:(.*)/)
|
|
86
|
+
no_image_text = matched[1]
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
self.class.to_html.to_html(no_image_text)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# @override
|
|
93
|
+
#: (PP) -> void
|
|
94
|
+
def pretty_print(q)
|
|
95
|
+
q.group 2, "[head: #{level} ", ']' do
|
|
96
|
+
q.pp text
|
|
97
|
+
end
|
|
98
|
+
end
|
|
32
99
|
end
|
|
33
|
-
|
|
34
|
-
@to_html
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
##
|
|
38
|
-
# Calls #accept_heading on +visitor+
|
|
39
|
-
|
|
40
|
-
def accept(visitor)
|
|
41
|
-
visitor.accept_heading self
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
##
|
|
45
|
-
# An HTML-safe anchor reference for this header.
|
|
46
|
-
|
|
47
|
-
def aref
|
|
48
|
-
"label-#{self.class.to_label.convert text.dup}"
|
|
49
100
|
end
|
|
50
|
-
|
|
51
|
-
##
|
|
52
|
-
# Creates a fully-qualified label which will include the label from
|
|
53
|
-
# +context+. This helps keep ids unique in HTML.
|
|
54
|
-
|
|
55
|
-
def label(context = nil)
|
|
56
|
-
label = aref
|
|
57
|
-
|
|
58
|
-
label = [context.aref, label].compact.join '-' if
|
|
59
|
-
context and context.respond_to? :aref
|
|
60
|
-
|
|
61
|
-
label
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
##
|
|
65
|
-
# HTML markup of the text of this label without the surrounding header
|
|
66
|
-
# element.
|
|
67
|
-
|
|
68
|
-
def plain_html
|
|
69
|
-
text = self.text.dup
|
|
70
|
-
|
|
71
|
-
if matched = text.match(/rdoc-image:[^:]+:(.*)/)
|
|
72
|
-
text = matched[1]
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
self.class.to_html.to_html(text)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def pretty_print(q) # :nodoc:
|
|
79
|
-
q.group 2, "[head: #{level} ", ']' do
|
|
80
|
-
q.pp text
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
101
|
end
|
data/lib/rdoc/markup/raw.rb
CHANGED
|
@@ -1,69 +1,66 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
##
|
|
3
|
-
# A section of text that is added to the output document as-is
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
##
|
|
21
|
-
# Appends +text+
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# A section of text that is added to the output document as-is
|
|
6
|
+
class Raw
|
|
7
|
+
# The component parts of the list
|
|
8
|
+
#: Array[String]
|
|
9
|
+
attr_reader :parts
|
|
10
|
+
|
|
11
|
+
# Creates a new Raw containing +parts+
|
|
12
|
+
#: (*String) -> void
|
|
13
|
+
def initialize(*parts)
|
|
14
|
+
@parts = parts
|
|
15
|
+
end
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
# Appends +text+
|
|
18
|
+
#: (String) -> void
|
|
19
|
+
def <<(text)
|
|
20
|
+
@parts << text
|
|
21
|
+
end
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
#: (top) -> bool
|
|
24
|
+
def ==(other) # :nodoc:
|
|
25
|
+
self.class == other.class && @parts == other.parts
|
|
26
|
+
end
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
# Calls #accept_raw+ on +visitor+
|
|
29
|
+
# @override
|
|
30
|
+
#: (untyped) -> void
|
|
31
|
+
def accept(visitor)
|
|
32
|
+
visitor.accept_raw(self)
|
|
33
|
+
end
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
# Appends +other+'s parts
|
|
36
|
+
#: (Raw) -> void
|
|
37
|
+
def merge(other)
|
|
38
|
+
@parts.concat(other.parts)
|
|
39
|
+
end
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
# @override
|
|
42
|
+
#: (PP) -> void
|
|
43
|
+
def pretty_print(q) # :nodoc:
|
|
44
|
+
self.class.name =~ /.*::(\w{1,4})/i
|
|
40
45
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
q.group(2, "[#{$1.downcase}: ", ']') do
|
|
47
|
+
q.seplist(@parts) do |part|
|
|
48
|
+
q.pp(part)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
# Appends +texts+ onto this Paragraph
|
|
54
|
+
#: (*String) -> void
|
|
55
|
+
def push(*texts)
|
|
56
|
+
self.parts.concat(texts)
|
|
57
|
+
end
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
# The raw text
|
|
60
|
+
#: () -> String
|
|
61
|
+
def text
|
|
62
|
+
@parts.join(" ")
|
|
51
63
|
end
|
|
52
64
|
end
|
|
53
65
|
end
|
|
54
|
-
|
|
55
|
-
##
|
|
56
|
-
# Appends +texts+ onto this Paragraph
|
|
57
|
-
|
|
58
|
-
def push *texts
|
|
59
|
-
self.parts.concat texts
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
##
|
|
63
|
-
# The raw text
|
|
64
|
-
|
|
65
|
-
def text
|
|
66
|
-
@parts.join ' '
|
|
67
|
-
end
|
|
68
|
-
|
|
69
66
|
end
|
data/lib/rdoc/markup/table.rb
CHANGED
|
@@ -1,52 +1,60 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
##
|
|
3
|
-
# A section of table
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
module RDoc
|
|
4
|
+
class Markup
|
|
5
|
+
# A section of table
|
|
6
|
+
class Table < Element
|
|
7
|
+
# Headers of each column
|
|
8
|
+
#: Array[String]
|
|
9
|
+
attr_accessor :header
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
# Alignments of each column
|
|
12
|
+
#: Array[Symbol?]
|
|
13
|
+
attr_accessor :align
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
# Body texts of each column
|
|
16
|
+
#: Array[String]
|
|
17
|
+
attr_accessor :body
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# :stopdoc:
|
|
21
|
-
def ==(other)
|
|
22
|
-
self.class == other.class and
|
|
23
|
-
@header == other.header and
|
|
24
|
-
@align == other.align and
|
|
25
|
-
@body == other.body
|
|
26
|
-
end
|
|
19
|
+
#: (Array[String], Array[Symbol?], Array[String]) -> void
|
|
20
|
+
def initialize(header, align, body)
|
|
21
|
+
@header, @align, @body = header, align, body
|
|
22
|
+
end
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
#: (Object) -> bool
|
|
25
|
+
def ==(other)
|
|
26
|
+
self.class == other.class && @header == other.header &&
|
|
27
|
+
@align == other.align && @body == other.body
|
|
28
|
+
end
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
q.pp text
|
|
37
|
-
if align
|
|
38
|
-
q.text ":"
|
|
39
|
-
q.breakable
|
|
40
|
-
q.text align.to_s
|
|
41
|
-
end
|
|
42
|
-
end
|
|
30
|
+
# @override
|
|
31
|
+
#: (untyped) -> void
|
|
32
|
+
def accept(visitor)
|
|
33
|
+
visitor.accept_table(@header, @body, @align)
|
|
43
34
|
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
|
|
36
|
+
# @override
|
|
37
|
+
#: (untyped) -> String
|
|
38
|
+
def pretty_print(q)
|
|
39
|
+
q.group 2, '[Table: ', ']' do
|
|
40
|
+
q.group 2, '[Head: ', ']' do
|
|
41
|
+
q.seplist @header.zip(@align) do |text, align|
|
|
49
42
|
q.pp text
|
|
43
|
+
if align
|
|
44
|
+
q.text ":"
|
|
45
|
+
q.breakable
|
|
46
|
+
q.text align.to_s
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
q.breakable
|
|
51
|
+
q.group 2, '[Body: ', ']' do
|
|
52
|
+
q.seplist @body do |body|
|
|
53
|
+
q.group 2, '[', ']' do
|
|
54
|
+
q.seplist body do |text|
|
|
55
|
+
q.pp text
|
|
56
|
+
end
|
|
57
|
+
end
|
|
50
58
|
end
|
|
51
59
|
end
|
|
52
60
|
end
|
data/lib/rdoc/markup.rb
CHANGED
|
@@ -210,6 +210,7 @@ https://github.com/ruby/rdoc/issues
|
|
|
210
210
|
autoload :BlankLine, "#{__dir__}/markup/blank_line"
|
|
211
211
|
autoload :BlockQuote, "#{__dir__}/markup/block_quote"
|
|
212
212
|
autoload :Document, "#{__dir__}/markup/document"
|
|
213
|
+
autoload :Element, "#{__dir__}/markup/element"
|
|
213
214
|
autoload :HardBreak, "#{__dir__}/markup/hard_break"
|
|
214
215
|
autoload :Heading, "#{__dir__}/markup/heading"
|
|
215
216
|
autoload :Include, "#{__dir__}/markup/include"
|
data/lib/rdoc/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rdoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.0.
|
|
4
|
+
version: 7.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric Hodel
|
|
@@ -13,7 +13,7 @@ authors:
|
|
|
13
13
|
- ITOYANAGI Sakura
|
|
14
14
|
bindir: exe
|
|
15
15
|
cert_chain: []
|
|
16
|
-
date: 2025-12-
|
|
16
|
+
date: 2025-12-24 00:00:00.000000000 Z
|
|
17
17
|
dependencies:
|
|
18
18
|
- !ruby/object:Gem::Dependency
|
|
19
19
|
name: psych
|
|
@@ -234,6 +234,7 @@ files:
|
|
|
234
234
|
- lib/rdoc/markup/blank_line.rb
|
|
235
235
|
- lib/rdoc/markup/block_quote.rb
|
|
236
236
|
- lib/rdoc/markup/document.rb
|
|
237
|
+
- lib/rdoc/markup/element.rb
|
|
237
238
|
- lib/rdoc/markup/formatter.rb
|
|
238
239
|
- lib/rdoc/markup/hard_break.rb
|
|
239
240
|
- lib/rdoc/markup/heading.rb
|