yard 0.9.40 → 0.9.42
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/CHANGELOG.md +17 -0
- data/docs/Parser.md +17 -42
- data/lib/yard/server/commands/base.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +168 -88
- data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +202 -207
- data/lib/yard/templates/helpers/markup/hybrid_markdown.rb +22 -0
- data/lib/yard/version.rb +1 -1
- data/templates/default/fulldoc/html/css/common.css +1 -1
- data/templates/default/fulldoc/html/css/full_list.css +201 -53
- data/templates/default/fulldoc/html/css/style.css +988 -389
- data/templates/default/fulldoc/html/js/app.js +800 -578
- data/templates/default/fulldoc/html/js/full_list.js +333 -341
- data/templates/default/layout/html/layout.erb +3 -1
- data/templates/guide/fulldoc/html/css/style.css +347 -97
- data/templates/guide/fulldoc/html/js/app.js +61 -64
- data/templates/guide/layout/html/layout.erb +67 -68
- metadata +2 -2
|
@@ -1,208 +1,203 @@
|
|
|
1
|
-
(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
ready(function() {
|
|
205
|
-
var input = query("#search_box");
|
|
206
|
-
if (input) createAutocomplete(input);
|
|
207
|
-
});
|
|
1
|
+
(() => {
|
|
2
|
+
function query(selector, root) {
|
|
3
|
+
return (root || document).querySelector(selector);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function ready(callback) {
|
|
7
|
+
if (document.readyState === "loading") {
|
|
8
|
+
document.addEventListener("DOMContentLoaded", callback, { once: true });
|
|
9
|
+
} else {
|
|
10
|
+
callback();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function createAutocomplete(input) {
|
|
15
|
+
const form = input.form;
|
|
16
|
+
const results = document.createElement("div");
|
|
17
|
+
const list = document.createElement("ul");
|
|
18
|
+
let requestTimer = null;
|
|
19
|
+
let controller = null;
|
|
20
|
+
let items = [];
|
|
21
|
+
let activeIndex = -1;
|
|
22
|
+
let blurTimer = null;
|
|
23
|
+
|
|
24
|
+
if (!form) return;
|
|
25
|
+
|
|
26
|
+
results.className = "ac_results";
|
|
27
|
+
results.hidden = true;
|
|
28
|
+
results.setAttribute("role", "listbox");
|
|
29
|
+
results.id = `${input.id}_results`;
|
|
30
|
+
list.setAttribute("role", "presentation");
|
|
31
|
+
results.appendChild(list);
|
|
32
|
+
input.setAttribute("autocomplete", "off");
|
|
33
|
+
input.setAttribute("aria-autocomplete", "list");
|
|
34
|
+
input.setAttribute("aria-controls", results.id);
|
|
35
|
+
input.setAttribute("aria-expanded", "false");
|
|
36
|
+
form.appendChild(results);
|
|
37
|
+
|
|
38
|
+
function syncResultsWidth() {
|
|
39
|
+
results.style.width = `${input.offsetWidth}px`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function hideResults() {
|
|
43
|
+
results.hidden = true;
|
|
44
|
+
input.setAttribute("aria-expanded", "false");
|
|
45
|
+
input.removeAttribute("aria-activedescendant");
|
|
46
|
+
activeIndex = -1;
|
|
47
|
+
items = [];
|
|
48
|
+
list.innerHTML = "";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function setActive(index) {
|
|
52
|
+
if (!items.length) return;
|
|
53
|
+
activeIndex = (index + items.length) % items.length;
|
|
54
|
+
items.forEach((item, itemIndex) => {
|
|
55
|
+
item.element.classList.toggle("ac_over", itemIndex === activeIndex);
|
|
56
|
+
});
|
|
57
|
+
input.setAttribute(
|
|
58
|
+
"aria-activedescendant",
|
|
59
|
+
items[activeIndex].element.id,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function selectItem(item) {
|
|
64
|
+
input.value = item.values[1];
|
|
65
|
+
window.location.href = item.values[3];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function renderItems(lines) {
|
|
69
|
+
syncResultsWidth();
|
|
70
|
+
list.innerHTML = "";
|
|
71
|
+
items = lines.map((line, index) => {
|
|
72
|
+
const values = line.split(",");
|
|
73
|
+
const element = document.createElement("li");
|
|
74
|
+
const label = document.createElement("span");
|
|
75
|
+
const namespace = document.createElement("small");
|
|
76
|
+
|
|
77
|
+
element.id = `${results.id}_item_${index}`;
|
|
78
|
+
element.setAttribute("role", "option");
|
|
79
|
+
element.className = index % 2 === 0 ? "ac_even" : "ac_odd";
|
|
80
|
+
label.textContent = values[0];
|
|
81
|
+
element.appendChild(label);
|
|
82
|
+
|
|
83
|
+
if (values[1] !== "") {
|
|
84
|
+
namespace.textContent = `(${values[1]})`;
|
|
85
|
+
element.appendChild(document.createTextNode(" "));
|
|
86
|
+
element.appendChild(namespace);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
element.addEventListener("mouseenter", () => {
|
|
90
|
+
setActive(index);
|
|
91
|
+
});
|
|
92
|
+
element.addEventListener("mousedown", (event) => {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
selectItem(items[index]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
list.appendChild(element);
|
|
98
|
+
|
|
99
|
+
return { element: element, values: values };
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
if (items.length) {
|
|
103
|
+
results.hidden = false;
|
|
104
|
+
input.setAttribute("aria-expanded", "true");
|
|
105
|
+
setActive(0);
|
|
106
|
+
} else {
|
|
107
|
+
hideResults();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function fetchResults(term) {
|
|
112
|
+
if (controller) controller.abort();
|
|
113
|
+
controller = new AbortController();
|
|
114
|
+
input.classList.add("ac_loading");
|
|
115
|
+
|
|
116
|
+
fetch(`${form.action}?q=${encodeURIComponent(term)}&_=${Date.now()}`, {
|
|
117
|
+
headers: {
|
|
118
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
119
|
+
},
|
|
120
|
+
signal: controller.signal,
|
|
121
|
+
})
|
|
122
|
+
.then((response) => response.text())
|
|
123
|
+
.then((text) => {
|
|
124
|
+
const lines = text
|
|
125
|
+
.split("\n")
|
|
126
|
+
.map((line) => line.trim())
|
|
127
|
+
.filter(Boolean);
|
|
128
|
+
|
|
129
|
+
renderItems(lines);
|
|
130
|
+
})
|
|
131
|
+
.catch((error) => {
|
|
132
|
+
if (error.name !== "AbortError") hideResults();
|
|
133
|
+
})
|
|
134
|
+
.finally(() => {
|
|
135
|
+
input.classList.remove("ac_loading");
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
input.addEventListener("input", () => {
|
|
140
|
+
clearTimeout(requestTimer);
|
|
141
|
+
if (blurTimer) clearTimeout(blurTimer);
|
|
142
|
+
|
|
143
|
+
if (!input.value.trim()) {
|
|
144
|
+
hideResults();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
requestTimer = setTimeout(() => {
|
|
149
|
+
fetchResults(input.value.trim());
|
|
150
|
+
}, 200);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
input.addEventListener("keydown", (event) => {
|
|
154
|
+
if (
|
|
155
|
+
results.hidden &&
|
|
156
|
+
(event.key === "ArrowDown" || event.key === "ArrowUp")
|
|
157
|
+
) {
|
|
158
|
+
if (!input.value.trim()) return;
|
|
159
|
+
fetchResults(input.value.trim());
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (event.key === "ArrowDown") {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
setActive(activeIndex + 1);
|
|
166
|
+
} else if (event.key === "ArrowUp") {
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
setActive(activeIndex - 1);
|
|
169
|
+
} else if (event.key === "Enter") {
|
|
170
|
+
if (activeIndex >= 0 && items[activeIndex]) {
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
selectItem(items[activeIndex]);
|
|
173
|
+
}
|
|
174
|
+
} else if (event.key === "Escape") {
|
|
175
|
+
hideResults();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
input.addEventListener("blur", () => {
|
|
180
|
+
blurTimer = setTimeout(hideResults, 150);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
input.addEventListener("focus", () => {
|
|
184
|
+
syncResultsWidth();
|
|
185
|
+
if (items.length) {
|
|
186
|
+
results.hidden = false;
|
|
187
|
+
input.setAttribute("aria-expanded", "true");
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
document.addEventListener("click", (event) => {
|
|
192
|
+
if (!form.contains(event.target)) hideResults();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
window.addEventListener("resize", syncResultsWidth);
|
|
196
|
+
syncResultsWidth();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
ready(() => {
|
|
200
|
+
const input = query("#search_box");
|
|
201
|
+
if (input) createAutocomplete(input);
|
|
202
|
+
});
|
|
208
203
|
})();
|
|
@@ -503,6 +503,7 @@ module YARD
|
|
|
503
503
|
while index < lines.length
|
|
504
504
|
line = lines[index]
|
|
505
505
|
break if blank_line?(line)
|
|
506
|
+
break if !buffer.empty? && colon_indented_code_block_start?(lines, index)
|
|
506
507
|
break if thematic_break?(line)
|
|
507
508
|
break if parse_setext_heading(lines, index)
|
|
508
509
|
break if parse_heading(line)
|
|
@@ -528,6 +529,7 @@ module YARD
|
|
|
528
529
|
text = protect_code_spans(text, placeholders)
|
|
529
530
|
text = protect_autolinks(text, placeholders)
|
|
530
531
|
text = protect_hard_breaks(text, placeholders)
|
|
532
|
+
text = protect_rdoc_images(text, placeholders)
|
|
531
533
|
text = protect_inline_images(text, placeholders)
|
|
532
534
|
text = protect_inline_links(text, placeholders)
|
|
533
535
|
text = protect_braced_text_links(text, placeholders)
|
|
@@ -634,6 +636,14 @@ module YARD
|
|
|
634
636
|
text.gsub(/(?:\\|\s{2,})\n/) { store_placeholder(placeholders, "<br />\n") }
|
|
635
637
|
end
|
|
636
638
|
|
|
639
|
+
def protect_rdoc_images(text, placeholders)
|
|
640
|
+
text.gsub(/(^|[ \t\n])rdoc-image:([A-Za-z][A-Za-z0-9+.-]*:\/\/\S+)(?=$|[ \t\n])/) do
|
|
641
|
+
prefix = Regexp.last_match(1)
|
|
642
|
+
dest = Regexp.last_match(2)
|
|
643
|
+
prefix + store_placeholder(placeholders, image_html('', dest))
|
|
644
|
+
end
|
|
645
|
+
end
|
|
646
|
+
|
|
637
647
|
def protect_inline_images(text, placeholders)
|
|
638
648
|
replace_inline_constructs(text, placeholders, '!') do |label, dest, title|
|
|
639
649
|
store_placeholder(placeholders, image_html(
|
|
@@ -918,6 +928,7 @@ module YARD
|
|
|
918
928
|
def indented_code_block_start?(lines, index, previous_block_type = nil)
|
|
919
929
|
return false unless indented_code_start?(lines[index])
|
|
920
930
|
return true if leading_columns(lines[index]) >= 4
|
|
931
|
+
return true if colon_indented_code_block_start?(lines, index)
|
|
921
932
|
return false if previous_block_type == :list
|
|
922
933
|
return false if html_block_start?(lines[index])
|
|
923
934
|
return false if parse_setext_heading(lines, index)
|
|
@@ -925,6 +936,17 @@ module YARD
|
|
|
925
936
|
!index.zero? && blank_line?(lines[index - 1])
|
|
926
937
|
end
|
|
927
938
|
|
|
939
|
+
def colon_indented_code_block_start?(lines, index)
|
|
940
|
+
return false if index.zero?
|
|
941
|
+
return false unless leading_columns(lines[index]) >= 2
|
|
942
|
+
return false if leading_columns(lines[index]) >= 4
|
|
943
|
+
|
|
944
|
+
previous_line = lines[index - 1]
|
|
945
|
+
return false if blank_line?(previous_line)
|
|
946
|
+
|
|
947
|
+
previous_line.rstrip.end_with?(':')
|
|
948
|
+
end
|
|
949
|
+
|
|
928
950
|
def yard_indented_code_start?(lines, index)
|
|
929
951
|
return false unless leading_columns(lines[index]) >= 2
|
|
930
952
|
return false unless consume_columns(lines[index], 2) =~ /^!!!([\w.+-]+)[ \t]*$/
|
data/lib/yard/version.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/* Override this file with custom rules */
|
|
1
|
+
/* Override this file with custom rules */
|