bitclust-core 1.2.6 → 1.6.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/Gemfile +3 -0
- data/README.md +65 -0
- data/Rakefile +32 -0
- data/data/bitclust/catalog/ja_JP.UTF-8 +19 -1
- data/data/bitclust/searchpage/index.html +90 -0
- data/data/bitclust/template/class +69 -8
- data/data/bitclust/template/function +2 -2
- data/data/bitclust/template/layout +11 -3
- data/data/bitclust/template/method +2 -2
- data/data/bitclust/template/search +1 -1
- data/data/bitclust/template.epub/class +22 -1
- data/data/bitclust/template.epub/function +2 -2
- data/data/bitclust/template.epub/layout +1 -3
- data/data/bitclust/template.epub/method +2 -2
- data/data/bitclust/template.lillia/class +26 -5
- data/data/bitclust/template.lillia/layout +1 -3
- data/data/bitclust/template.lillia/method +2 -2
- data/data/bitclust/template.offline/class +49 -5
- data/data/bitclust/template.offline/function +2 -2
- data/data/bitclust/template.offline/layout +27 -3
- data/data/bitclust/template.offline/method +2 -2
- data/lib/bitclust/app.rb +17 -17
- data/lib/bitclust/capi_converter.rb +20 -0
- data/lib/bitclust/classentry.rb +68 -17
- data/lib/bitclust/compat.rb +3 -2
- data/lib/bitclust/completion.rb +59 -27
- data/lib/bitclust/crossrubyutils.rb +9 -5
- data/lib/bitclust/database.rb +29 -8
- data/lib/bitclust/doc_converter.rb +63 -0
- data/lib/bitclust/docentry.rb +2 -1
- data/lib/bitclust/entity_splitter.rb +221 -0
- data/lib/bitclust/entry.rb +48 -7
- data/lib/bitclust/exception.rb +1 -0
- data/lib/bitclust/functiondatabase.rb +14 -1
- data/lib/bitclust/functionentry.rb +6 -1
- data/lib/bitclust/functionreferenceparser.rb +5 -4
- data/lib/bitclust/generators/epub.rb +11 -3
- data/lib/bitclust/htmlutils.rb +2 -1
- data/lib/bitclust/include_graph.rb +375 -0
- data/lib/bitclust/include_pruner.rb +144 -0
- data/lib/bitclust/interface.rb +2 -1
- data/lib/bitclust/libraryentry.rb +9 -7
- data/lib/bitclust/lineinput.rb +8 -5
- data/lib/bitclust/link_checker.rb +179 -0
- data/lib/bitclust/markdown_bridge.rb +186 -0
- data/lib/bitclust/markdown_orchestrator.rb +267 -0
- data/lib/bitclust/markdown_to_rrd.rb +824 -0
- data/lib/bitclust/markdown_tree.rb +217 -0
- data/lib/bitclust/mdcompiler.rb +883 -0
- data/lib/bitclust/mdparser.rb +347 -0
- data/lib/bitclust/messagecatalog.rb +4 -3
- data/lib/bitclust/method_since_calculator.rb +117 -0
- data/lib/bitclust/methoddatabase.rb +125 -14
- data/lib/bitclust/methodentry.rb +130 -7
- data/lib/bitclust/methodid.rb +13 -11
- data/lib/bitclust/methodsignature.rb +11 -4
- data/lib/bitclust/nameutils.rb +42 -22
- data/lib/bitclust/parseutils.rb +1 -0
- data/lib/bitclust/preprocessor.rb +70 -32
- data/lib/bitclust/progress_bar.rb +1 -0
- data/lib/bitclust/rdcompiler.rb +197 -96
- data/lib/bitclust/refsdatabase.rb +24 -8
- data/lib/bitclust/reloadable_request_handler.rb +72 -0
- data/lib/bitclust/requesthandler.rb +22 -16
- data/lib/bitclust/ridatabase.rb +11 -4
- data/lib/bitclust/rrd_to_markdown.rb +925 -0
- data/lib/bitclust/rrdparser.rb +197 -30
- data/lib/bitclust/runner.rb +18 -2
- data/lib/bitclust/screen.rb +81 -11
- data/lib/bitclust/search_index_generator.rb +288 -0
- data/lib/bitclust/searcher.rb +72 -22
- data/lib/bitclust/server.rb +6 -1
- data/lib/bitclust/silent_progress_bar.rb +1 -0
- data/lib/bitclust/simplesearcher.rb +25 -12
- data/lib/bitclust/subcommand.rb +8 -1
- data/lib/bitclust/subcommands/ancestors_command.rb +10 -2
- data/lib/bitclust/subcommands/checklink_command.rb +54 -0
- data/lib/bitclust/subcommands/chm_command.rb +16 -7
- data/lib/bitclust/subcommands/classes_command.rb +6 -0
- data/lib/bitclust/subcommands/epub_command.rb +1 -0
- data/lib/bitclust/subcommands/extract_command.rb +6 -0
- data/lib/bitclust/subcommands/htmlfile_command.rb +22 -7
- data/lib/bitclust/subcommands/init_command.rb +5 -1
- data/lib/bitclust/subcommands/list_command.rb +13 -4
- data/lib/bitclust/subcommands/lookup_command.rb +29 -9
- data/lib/bitclust/subcommands/methods_command.rb +11 -2
- data/lib/bitclust/subcommands/methodsince_command.rb +80 -0
- data/lib/bitclust/subcommands/preproc_command.rb +6 -0
- data/lib/bitclust/subcommands/property_command.rb +3 -1
- data/lib/bitclust/subcommands/query_command.rb +1 -0
- data/lib/bitclust/subcommands/searchpage_command.rb +102 -0
- data/lib/bitclust/subcommands/server_command.rb +16 -10
- data/lib/bitclust/subcommands/setup_command.rb +25 -10
- data/lib/bitclust/subcommands/statichtml_command.rb +132 -6
- data/lib/bitclust/subcommands/update_command.rb +111 -2
- data/lib/bitclust/syntax_highlighter.rb +52 -5
- data/lib/bitclust/textutils.rb +4 -3
- data/lib/bitclust/version.rb +2 -1
- data/lib/bitclust/version_badges.rb +90 -0
- data/lib/bitclust/whole_file_gate.rb +137 -0
- data/lib/bitclust.rb +1 -0
- data/test/test_app.rb +269 -0
- data/test/test_bitclust.rb +2 -0
- data/test/test_capi_converter.rb +91 -0
- data/test/test_class_screen.rb +413 -0
- data/test/test_copy_doc_md.rb +53 -0
- data/test/test_doc_converter.rb +78 -0
- data/test/test_entity_splitter.rb +231 -0
- data/test/test_entry.rb +207 -2
- data/test/test_eol_warning.rb +43 -0
- data/test/test_functionreferenceparser.rb +11 -0
- data/test/test_include_graph.rb +640 -0
- data/test/test_include_pruner.rb +133 -0
- data/test/test_link_checker.rb +114 -0
- data/test/test_lookup_command.rb +135 -0
- data/test/test_markdown_bridge.rb +217 -0
- data/test/test_markdown_orchestrator.rb +478 -0
- data/test/test_markdown_to_rrd.rb +757 -0
- data/test/test_markdown_tree.rb +369 -0
- data/test/test_mdcompiler.rb +1276 -0
- data/test/test_mdparser.rb +538 -0
- data/test/test_method_screen.rb +166 -0
- data/test/test_method_since_calculator.rb +290 -0
- data/test/test_methoddatabase.rb +16 -0
- data/test/test_methodentry.rb +328 -0
- data/test/test_methodsignature.rb +3 -1
- data/test/test_methodsince_command.rb +168 -0
- data/test/test_nameutils.rb +22 -0
- data/test/test_preprocessor.rb +215 -0
- data/test/test_rdcompiler.rb +429 -27
- data/test/test_refsdatabase.rb +32 -0
- data/test/test_rrd_to_markdown.rb +968 -0
- data/test/test_rrdparser.rb +295 -2
- data/test/test_run_ruby_wasm.rb +54 -0
- data/test/test_run_worker_prelude.rb +83 -0
- data/test/test_runner.rb +51 -0
- data/test/test_search_index_generator.rb +513 -0
- data/test/test_search_screen.rb +48 -0
- data/test/test_searcher.rb +153 -0
- data/test/test_searchpage_command.rb +167 -0
- data/test/test_simplesearcher.rb +28 -0
- data/test/test_statichtml_command.rb +204 -0
- data/test/test_syntax_highlighter.rb +60 -0
- data/test/test_whole_file_gate.rb +175 -0
- data/theme/default/js/NOTICE +42 -0
- data/theme/default/js/run-worker.js +111 -0
- data/theme/default/js/run.js +350 -0
- data/theme/default/js/search_controller.js +134 -0
- data/theme/default/js/search_init.js +176 -0
- data/theme/default/js/search_navigation.js +110 -0
- data/theme/default/js/search_page.js +202 -0
- data/theme/default/js/search_ranker.js +244 -0
- data/theme/default/script.js +91 -18
- data/theme/default/search.css +149 -0
- data/theme/default/style.css +193 -21
- data/theme/default/syntax-highlight.css +8 -0
- data/theme/lillia/style.css +45 -1
- metadata +178 -21
- data/README +0 -32
|
@@ -120,7 +120,11 @@
|
|
|
120
120
|
[_('Instance Methods'), ents.instance_methods ],
|
|
121
121
|
[_('Private Singleton Methods'), ents.private_singleton_methods ],
|
|
122
122
|
[_('Private Instance Methods'), ents.private_instance_methods ],
|
|
123
|
+
[_('Protected Instance Methods'),ents.protected_instance_methods ],
|
|
123
124
|
[_('Module Functions'), ents.module_functions ],
|
|
125
|
+
[_('Added Methods'), ents.added ],
|
|
126
|
+
[_('Redefined Methods'), ents.redefined ],
|
|
127
|
+
[_('Undefined Methods for Explanation'), ents.nomethod ],
|
|
124
128
|
[_('Constants'), ents.constants ],
|
|
125
129
|
[_('Special Variables'), ents.special_variables ,'$']] %>
|
|
126
130
|
<%= headline(_("Index")) %>
|
|
@@ -146,18 +150,39 @@
|
|
|
146
150
|
|
|
147
151
|
<%
|
|
148
152
|
_myself, *ancestors = @entry.ancestors.reject { |c| %w[Object Kernel BasicObject].include?(c.name) }
|
|
149
|
-
|
|
153
|
+
displayed_instance_methods = Set.new((ents.instance_methods + ents.redefined.select(&:instance_method?)).flat_map(&:names))
|
|
154
|
+
displayed_singleton_methods = Set.new((ents.singleton_methods + ents.redefined.select(&:singleton_method?)).flat_map(&:names))
|
|
155
|
+
undefined_methods = @entry.partitioned_entries.undefined
|
|
156
|
+
undefined_instance_methods = undefined_methods.select(&:instance_method?)
|
|
157
|
+
undefined_singleton_methods = undefined_methods.select(&:singleton_method?)
|
|
150
158
|
%>
|
|
151
159
|
|
|
152
160
|
<% unless ancestors.empty? %>
|
|
153
161
|
<%= headline(_("Ancestor Methods")) %>
|
|
154
162
|
<dl>
|
|
163
|
+
<%# Singleton methods are inherited only through the superclass chain, not from included modules. %>
|
|
164
|
+
<% ancestors.select(&:class?).each do |c|
|
|
165
|
+
methods = c.partitioned_entries(@alevel).singleton_methods
|
|
166
|
+
.flat_map { |m| m.names.map { |n| [n, m] } }
|
|
167
|
+
.reject { |name,| displayed_singleton_methods.include?(name) }
|
|
168
|
+
.reject { |name,| undefined_singleton_methods.any? { |m| m.names.include?(name) } }
|
|
169
|
+
.sort
|
|
170
|
+
next if methods.empty? %>
|
|
171
|
+
<dt><%= _('Ancestor Singleton Methods %s', c.name) %></dt>
|
|
172
|
+
<dd>
|
|
173
|
+
<ul class="class-toc">
|
|
174
|
+
<% methods.each do |name, m| %>
|
|
175
|
+
<li><%= method_link(m.spec_string, name) %></li>
|
|
176
|
+
<% displayed_singleton_methods << name %>
|
|
177
|
+
<% end %>
|
|
178
|
+
</ul>
|
|
179
|
+
</dd>
|
|
180
|
+
<% end %>
|
|
155
181
|
<% ancestors.each do |c|
|
|
156
|
-
undefined_methods = @entry.partitioned_entries.undefined
|
|
157
182
|
methods = c.partitioned_entries(@alevel).instance_methods
|
|
158
183
|
.flat_map { |m| m.names.map { |n| [n, m] } }
|
|
159
|
-
.reject { |name,|
|
|
160
|
-
.reject { |name,|
|
|
184
|
+
.reject { |name,| displayed_instance_methods.include?(name) }
|
|
185
|
+
.reject { |name,| undefined_instance_methods.any? { |m| m.names.include?(name) } }
|
|
161
186
|
.sort
|
|
162
187
|
next if methods.empty? %>
|
|
163
188
|
<dt><%= _('Ancestor Methods %s', c.name) %></dt>
|
|
@@ -165,7 +190,7 @@ displayed_methods = Set.new(ents.instance_methods.map(&:name))
|
|
|
165
190
|
<ul class="class-toc">
|
|
166
191
|
<% methods.each do |name, m| %>
|
|
167
192
|
<li><%= method_link(m.spec_string, name) %></li>
|
|
168
|
-
<%
|
|
193
|
+
<% displayed_instance_methods << name %>
|
|
169
194
|
<% end %>
|
|
170
195
|
</ul>
|
|
171
196
|
</dd>
|
|
@@ -174,6 +199,25 @@ displayed_methods = Set.new(ents.instance_methods.map(&:name))
|
|
|
174
199
|
end %>
|
|
175
200
|
</dl>
|
|
176
201
|
|
|
202
|
+
<%
|
|
203
|
+
dyninc_groups = @entry.dynamically_included_entries.group_by(&:klass)
|
|
204
|
+
%>
|
|
205
|
+
<% unless dyninc_groups.empty? %>
|
|
206
|
+
<%= headline(_("Methods Added by Dynamic Include")) %>
|
|
207
|
+
<dl>
|
|
208
|
+
<% dyninc_groups.each do |mod, mod_entries| %>
|
|
209
|
+
<dt><%= mod.name %> (by <%= mod.library.name %>)</dt>
|
|
210
|
+
<dd>
|
|
211
|
+
<ul class="class-toc">
|
|
212
|
+
<% mod_entries.each do |m| %>
|
|
213
|
+
<li><%= method_link(m.spec_string, m.name) %></li>
|
|
214
|
+
<% end %>
|
|
215
|
+
</ul>
|
|
216
|
+
</dd>
|
|
217
|
+
<% end %>
|
|
218
|
+
</dl>
|
|
219
|
+
<% end %>
|
|
220
|
+
|
|
177
221
|
<%
|
|
178
222
|
items.each do |label, entries|
|
|
179
223
|
unless entries.empty? %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%
|
|
2
2
|
entry = @entry
|
|
3
|
-
@title = "#{entry.type_label} #{entry.
|
|
3
|
+
@title = "#{entry.type_label} #{entry.display_label}"
|
|
4
4
|
@description = @entry.description
|
|
5
5
|
@edit_url = edit_url(@entry.source_location) if @conf[:edit_base_url] && @entry.source_location
|
|
6
6
|
%>
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
</ol>
|
|
42
42
|
</nav>
|
|
43
43
|
<% headline_init %>
|
|
44
|
-
<%= headline("#{entry.type_label} #{entry.
|
|
44
|
+
<%= headline("#{entry.type_label} #{entry.display_label}", edit_url: @edit_url) %>
|
|
45
45
|
</header>
|
|
46
46
|
|
|
47
47
|
<main>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
8
|
<link rel="stylesheet" href="<%=h css_url() %>">
|
|
9
9
|
<link rel="stylesheet" href="<%=h custom_css_url("syntax-highlight.css") %>">
|
|
10
|
+
<link rel="stylesheet" href="<%=h custom_css_url("search.css") %>">
|
|
10
11
|
<link rel="icon" type="image/png" href="<%=h favicon_url() %>">
|
|
11
12
|
<% if @conf[:canonical_base_url] %>
|
|
12
13
|
<link rel="canonical" href="<%= canonical_url() %>">
|
|
@@ -14,13 +15,36 @@
|
|
|
14
15
|
<title><%=h @title %> (Ruby <%=h ruby_version %> リファレンスマニュアル)</title>
|
|
15
16
|
<meta name="description" content="<%=h @description %>">
|
|
16
17
|
<script src="<%=h custom_js_url('script.js') %>"></script>
|
|
18
|
+
<script>var index_rel_prefix = "<%=h html_base() %>/";</script>
|
|
19
|
+
<script src="<%=h custom_js_url('js/search_data.js') %>"></script>
|
|
20
|
+
<script src="<%=h custom_js_url('js/search_navigation.js') %>"></script>
|
|
21
|
+
<script src="<%=h custom_js_url('js/search_ranker.js') %>"></script>
|
|
22
|
+
<script src="<%=h custom_js_url('js/search_controller.js') %>"></script>
|
|
23
|
+
<script src="<%=h custom_js_url('js/search_init.js') %>"></script>
|
|
24
|
+
<% if run_ruby_wasm_url %>
|
|
25
|
+
<meta name="rurema-run-ruby-wasm" content="<%=h run_ruby_wasm_url %>">
|
|
26
|
+
<script type="module" src="<%=h custom_js_url('js/run.js') %>"></script>
|
|
27
|
+
<% end %>
|
|
17
28
|
</head>
|
|
18
29
|
<body>
|
|
30
|
+
<% if eol_warning?() %>
|
|
31
|
+
<p class="eol-warning">
|
|
32
|
+
<%= _('This reference manual is for a version of Ruby that is no longer maintained.') %>
|
|
33
|
+
<a href="https://docs.ruby-lang.org/ja/latest/"><%= _('Latest version') %></a>
|
|
34
|
+
</p>
|
|
35
|
+
<% end %>
|
|
36
|
+
<div id="rurema-topbar">
|
|
37
|
+
<div id="rurema-brand"><%= manual_home_link %></div>
|
|
38
|
+
<div id="search-section" role="search">
|
|
39
|
+
<input id="search-field" type="text" autocomplete="off" spellcheck="false"
|
|
40
|
+
placeholder="クラス・メソッドを検索 (/)"
|
|
41
|
+
aria-label="検索" aria-autocomplete="list" aria-controls="search-results">
|
|
42
|
+
<ul id="search-results" class="search-results" aria-expanded="false"></ul>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
19
45
|
<%= yield %>
|
|
20
46
|
<footer id="footer">
|
|
21
|
-
<a rel="license" href="https://creativecommons.org/licenses/by/3.0/">
|
|
22
|
-
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/3.0/88x31.png" />
|
|
23
|
-
</a>
|
|
47
|
+
<a rel="license" href="https://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/3.0/88x31.png" /></a>
|
|
24
48
|
|
|
25
49
|
<a href="https://github.com/rurema/doctree/issues/new" id="feedback-link">フィードバックを送る</a>
|
|
26
50
|
<% if defined?(@edit_url) && @edit_url %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%
|
|
2
2
|
entry = @entries.sort.first
|
|
3
|
-
@title = entry.
|
|
3
|
+
@title = entry.display_title_labels.join(', ')
|
|
4
4
|
@description = entry.description
|
|
5
5
|
@edit_url = edit_url(entry.source_location) if @conf[:edit_base_url] && entry.source_location
|
|
6
6
|
%>
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
</ol>
|
|
56
56
|
</nav>
|
|
57
57
|
<% headline_init %>
|
|
58
|
-
<%= headline("#{entry.type_label} #{entry.
|
|
58
|
+
<%= headline("#{entry.type_label} #{entry.display_label}") %>
|
|
59
59
|
</header>
|
|
60
60
|
|
|
61
61
|
<main>
|
data/lib/bitclust/app.rb
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'bitclust'
|
|
2
3
|
require 'bitclust/interface'
|
|
4
|
+
require 'bitclust/reloadable_request_handler'
|
|
3
5
|
|
|
4
6
|
module BitClust
|
|
5
7
|
|
|
6
8
|
# Main class of BitClust server application.
|
|
7
|
-
# Actual actions are
|
|
9
|
+
# Actual actions are implemented by RequestHandler.
|
|
8
10
|
#
|
|
9
11
|
# Supports Rack and WEBrick.
|
|
10
12
|
class App
|
|
@@ -25,11 +27,8 @@ module BitClust
|
|
|
25
27
|
@interfaces = {}
|
|
26
28
|
case dbpath
|
|
27
29
|
when String
|
|
30
|
+
# @type var viewpath: String
|
|
28
31
|
dbpath = File.expand_path(dbpath)
|
|
29
|
-
db = BitClust::MethodDatabase.new(dbpath)
|
|
30
|
-
if capi
|
|
31
|
-
db = [db, BitClust::FunctionDatabase.new(dbpath)]
|
|
32
|
-
end
|
|
33
32
|
manager = BitClust::ScreenManager.new(
|
|
34
33
|
:base_url => baseurl,
|
|
35
34
|
:cgi_url => File.join(baseurl, viewpath),
|
|
@@ -38,25 +37,22 @@ module BitClust
|
|
|
38
37
|
:theme => options[:theme],
|
|
39
38
|
:encoding => encoding
|
|
40
39
|
)
|
|
41
|
-
handler =
|
|
40
|
+
handler = BitClust::ReloadableRequestHandler.new(dbpath, capi, manager, request_handler_class)
|
|
42
41
|
@interfaces[viewpath] = BitClust::Interface.new { handler }
|
|
43
42
|
when Array
|
|
43
|
+
# @type var viewpath: String?
|
|
44
44
|
dbpaths = dbpath
|
|
45
45
|
@versions = []
|
|
46
46
|
dbpaths.each do |dbpath|
|
|
47
47
|
next unless /db-([\d_\.]+)/ =~ dbpath
|
|
48
48
|
dbpath = File.expand_path(dbpath)
|
|
49
|
-
version = $1.tr("_", ".")
|
|
49
|
+
version = ($1 || raise).tr("_", ".")
|
|
50
50
|
@versions << version
|
|
51
51
|
if viewpath
|
|
52
52
|
version_viewpath = File.join(version, viewpath)
|
|
53
53
|
else
|
|
54
54
|
version_viewpath = version
|
|
55
55
|
end
|
|
56
|
-
db = BitClust::MethodDatabase.new(dbpath)
|
|
57
|
-
if capi
|
|
58
|
-
db = [db, BitClust::FunctionDatabase.new(dbpath)]
|
|
59
|
-
end
|
|
60
56
|
manager = BitClust::ScreenManager.new(
|
|
61
57
|
:base_url => baseurl,
|
|
62
58
|
:cgi_url => File.join(baseurl, version_viewpath),
|
|
@@ -65,7 +61,7 @@ module BitClust
|
|
|
65
61
|
:theme => options[:theme],
|
|
66
62
|
:encoding => encoding
|
|
67
63
|
)
|
|
68
|
-
handler =
|
|
64
|
+
handler = BitClust::ReloadableRequestHandler.new(dbpath, capi, manager, request_handler_class)
|
|
69
65
|
@interfaces[version_viewpath] = BitClust::Interface.new { handler }
|
|
70
66
|
$bitclust_context_cache = nil # clear cache
|
|
71
67
|
end
|
|
@@ -87,13 +83,15 @@ module BitClust
|
|
|
87
83
|
req.path_info
|
|
88
84
|
end
|
|
89
85
|
if @versions.any?{|version| %r|\A/?#{version}/?\z| =~ request_path }
|
|
90
|
-
viewpath =
|
|
86
|
+
viewpath = @options[:viewpath]
|
|
87
|
+
raise unless viewpath.is_a?(String)
|
|
88
|
+
viewpath = File.join(request_path || raise, viewpath)
|
|
91
89
|
@index = "<html><head><meta http-equiv='Refresh' content='0;URL=#{viewpath}'></head></html>"
|
|
92
90
|
else
|
|
93
91
|
links = "<ul>"
|
|
94
92
|
@interfaces.keys.sort.each do |v|
|
|
95
|
-
if @options[:viewpath]
|
|
96
|
-
version = v.sub(
|
|
93
|
+
if (viewpath = @options[:viewpath]).is_a?(String)
|
|
94
|
+
version = v.sub(viewpath, '')
|
|
97
95
|
else
|
|
98
96
|
version = v
|
|
99
97
|
end
|
|
@@ -107,15 +105,17 @@ module BitClust
|
|
|
107
105
|
@index = "<html><head><title>bitclust</title></head><body>#{links}</body></html>"
|
|
108
106
|
end
|
|
109
107
|
end
|
|
108
|
+
else
|
|
109
|
+
raise '[BUG]'
|
|
110
110
|
end
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
def get_instance(
|
|
113
|
+
def get_instance(_server, *_)
|
|
114
114
|
self
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def service(req, res)
|
|
118
|
-
unless %r|/#{File.basename(@options[:baseurl])}/?\z| =~ req.path
|
|
118
|
+
unless %r|/#{File.basename(@options[:baseurl] || raise)}/?\z| =~ req.path
|
|
119
119
|
raise WEBrick::HTTPStatus::NotFound
|
|
120
120
|
end
|
|
121
121
|
res.body = index(req)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bitclust/rrd_to_markdown'
|
|
4
|
+
|
|
5
|
+
module BitClust
|
|
6
|
+
# refm/capi(C API リファレンス)の Markdown 変換。
|
|
7
|
+
#
|
|
8
|
+
# capi の構造は「--- シグネチャ + 本文」の列のみで、見出し・include・
|
|
9
|
+
# ライブラリ等のクロスファイル情報が無い(FunctionReferenceParser 参照)。
|
|
10
|
+
# front matter は使わず、シグネチャは capi モードの変換
|
|
11
|
+
# 「--- <C sig>」↔「### <C sig>」(def 等のキーワード無し。C の
|
|
12
|
+
# シグネチャは型から始まるため自己記述的)で表す。本文の記法は api と共通。
|
|
13
|
+
module CapiConverter
|
|
14
|
+
module_function
|
|
15
|
+
|
|
16
|
+
def convert(rrd)
|
|
17
|
+
RRDToMarkdown.convert(rrd, capi: true)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/bitclust/classentry.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#
|
|
2
3
|
# bitclust/classentry.rb
|
|
3
4
|
#
|
|
@@ -78,7 +79,7 @@ module BitClust
|
|
|
78
79
|
end
|
|
79
80
|
|
|
80
81
|
persistent_properties {
|
|
81
|
-
property :type, 'Symbol'
|
|
82
|
+
property :type, 'Symbol' ## :class | :module | :object
|
|
82
83
|
property :superclass, 'ClassEntry'
|
|
83
84
|
property :included, '[ClassEntry]'
|
|
84
85
|
property :extended, '[ClassEntry]'
|
|
@@ -216,8 +217,10 @@ module BitClust
|
|
|
216
217
|
[ myself, included().map {|m| m.ancestors },
|
|
217
218
|
ancestors ].flatten
|
|
218
219
|
else
|
|
220
|
+
# steep:ignore:start
|
|
219
221
|
[ self, included().map {|m| m.ancestors },
|
|
220
222
|
superclass() ? superclass().ancestors : [] ].flatten
|
|
223
|
+
# steep:ignore:end
|
|
221
224
|
end
|
|
222
225
|
end
|
|
223
226
|
|
|
@@ -227,6 +230,24 @@ module BitClust
|
|
|
227
230
|
list
|
|
228
231
|
end
|
|
229
232
|
|
|
233
|
+
# Public instance methods contributed by modules that are dynamically
|
|
234
|
+
# included into this class (via `# reopen` + `include:`/`include`).
|
|
235
|
+
#
|
|
236
|
+
# Unlike +included+, +dynamically_included+ does not affect +ancestors+
|
|
237
|
+
# or the method resolution order, so these methods are never returned by
|
|
238
|
+
# +entries+/+partitioned_entries+. This method exists so that screens and
|
|
239
|
+
# templates can list them separately, attributed to the module (and its
|
|
240
|
+
# library) that defines them, without disturbing the MRO.
|
|
241
|
+
#
|
|
242
|
+
# Only each module's own public instance methods are returned (i.e. its
|
|
243
|
+
# +entries(0)+ filtered like +public_instance_methods+); methods that the
|
|
244
|
+
# dynamically included module itself inherits are not followed. If no
|
|
245
|
+
# module has been dynamically included, this returns an empty array, so
|
|
246
|
+
# output for classes without dynamic include is unaffected.
|
|
247
|
+
def dynamically_included_entries
|
|
248
|
+
dynamically_included().flat_map {|m| m.public_instance_methods(0) }
|
|
249
|
+
end
|
|
250
|
+
|
|
230
251
|
def extended_modules
|
|
231
252
|
ancestors().select(&:class?).map(&:extended).flatten
|
|
232
253
|
end
|
|
@@ -234,8 +255,8 @@ module BitClust
|
|
|
234
255
|
def entries(level = 0)
|
|
235
256
|
@entries ||= @db.entries("method/#{@id}")\
|
|
236
257
|
.map {|ent| MethodEntry.new(@db, "#{@id}/#{ent}") }
|
|
237
|
-
ret = @entries
|
|
238
|
-
ancestors[1..level].each{|c| ret += c.entries }
|
|
258
|
+
ret = @entries || raise
|
|
259
|
+
(ancestors[1..level] || raise).each{|c| ret += c.entries }
|
|
239
260
|
ret
|
|
240
261
|
end
|
|
241
262
|
|
|
@@ -251,26 +272,43 @@ module BitClust
|
|
|
251
272
|
end
|
|
252
273
|
|
|
253
274
|
Parts = Struct.new(:singleton_methods, :private_singleton_methods,
|
|
254
|
-
:instance_methods, :private_instance_methods,
|
|
275
|
+
:instance_methods, :private_instance_methods, :protected_instance_methods,
|
|
255
276
|
:module_functions,
|
|
256
277
|
:constants, :special_variables,
|
|
257
|
-
:
|
|
278
|
+
:redefined,
|
|
279
|
+
:added, :undefined, :nomethod)
|
|
258
280
|
|
|
259
281
|
def partitioned_entries(level = 0)
|
|
282
|
+
# @type var s: Array[MethodEntry]
|
|
283
|
+
# @type var spv: Array[MethodEntry]
|
|
284
|
+
# @type var i: Array[MethodEntry]
|
|
285
|
+
# @type var ipv: Array[MethodEntry]
|
|
286
|
+
# @type var ipt: Array[MethodEntry]
|
|
287
|
+
# @type var mf: Array[MethodEntry]
|
|
288
|
+
# @type var c: Array[MethodEntry]
|
|
289
|
+
# @type var v: Array[MethodEntry]
|
|
290
|
+
# @type var redefined: Array[MethodEntry]
|
|
291
|
+
# @type var added: Array[MethodEntry]
|
|
292
|
+
# @type var undefined: Array[MethodEntry]
|
|
293
|
+
# @type var nomethod: Array[MethodEntry]
|
|
260
294
|
s = []; spv = []
|
|
261
|
-
i = []; ipv = []
|
|
295
|
+
i = []; ipv = []; ipt = []
|
|
262
296
|
mf = []
|
|
263
297
|
c = []; v = []
|
|
298
|
+
redefined = []
|
|
264
299
|
added = []
|
|
265
300
|
undefined = []
|
|
301
|
+
nomethod = []
|
|
266
302
|
entries(level).sort_by(&:name).each do |m|
|
|
267
303
|
case m.kind
|
|
268
|
-
when :defined
|
|
304
|
+
when :defined
|
|
269
305
|
case m.type
|
|
270
306
|
when :singleton_method
|
|
271
307
|
(m.public? ? s : spv).push m
|
|
272
308
|
when :instance_method
|
|
273
|
-
|
|
309
|
+
tmp = m.public? ? i : ipv
|
|
310
|
+
tmp = ipt if m.protected?
|
|
311
|
+
tmp.push m
|
|
274
312
|
when :module_function
|
|
275
313
|
mf.push m
|
|
276
314
|
when :constant
|
|
@@ -280,13 +318,19 @@ module BitClust
|
|
|
280
318
|
else
|
|
281
319
|
raise "must not happen: m.type=#{m.type.inspect} (#{m.inspect})"
|
|
282
320
|
end
|
|
321
|
+
when :redefined
|
|
322
|
+
redefined.push m
|
|
283
323
|
when :added
|
|
284
324
|
added.push m
|
|
285
325
|
when :undefined
|
|
286
326
|
undefined.push m
|
|
327
|
+
when :nomethod
|
|
328
|
+
nomethod.push m
|
|
287
329
|
end
|
|
288
330
|
end
|
|
289
|
-
|
|
331
|
+
# steep:ignore:start
|
|
332
|
+
Parts.new(s,spv, i,ipv,ipt, mf, c, v, redefined, added, undefined, nomethod)
|
|
333
|
+
# steep:ignore:end
|
|
290
334
|
end
|
|
291
335
|
|
|
292
336
|
def singleton_methods(level = 0)
|
|
@@ -321,6 +365,10 @@ module BitClust
|
|
|
321
365
|
|
|
322
366
|
alias private_methods private_instance_methods
|
|
323
367
|
|
|
368
|
+
def protected_instance_methods(level = 0)
|
|
369
|
+
entries(level).select(&:protected_instance_method?).sort_by(&:sort_key)
|
|
370
|
+
end
|
|
371
|
+
|
|
324
372
|
def constants(level = 0)
|
|
325
373
|
entries(level).select(&:constant?).sort_by(&:sort_key)
|
|
326
374
|
end
|
|
@@ -333,7 +381,7 @@ module BitClust
|
|
|
333
381
|
if inherit
|
|
334
382
|
_smap().key?(name)
|
|
335
383
|
else
|
|
336
|
-
singleton_methods(
|
|
384
|
+
singleton_methods(0).detect {|m| m.name?(name) }
|
|
337
385
|
end
|
|
338
386
|
end
|
|
339
387
|
|
|
@@ -341,7 +389,7 @@ module BitClust
|
|
|
341
389
|
if inherit
|
|
342
390
|
_imap().key?(name)
|
|
343
391
|
else
|
|
344
|
-
instance_methods(
|
|
392
|
+
instance_methods(0).detect {|m| m.name?(name) }
|
|
345
393
|
end
|
|
346
394
|
end
|
|
347
395
|
|
|
@@ -349,7 +397,7 @@ module BitClust
|
|
|
349
397
|
if inherit
|
|
350
398
|
ancestors().any? {|c| c.constant?(name, false) }
|
|
351
399
|
else
|
|
352
|
-
constants(
|
|
400
|
+
constants(0).detect {|m| m.name?(name) }
|
|
353
401
|
end
|
|
354
402
|
end
|
|
355
403
|
|
|
@@ -382,15 +430,15 @@ module BitClust
|
|
|
382
430
|
|
|
383
431
|
def singleton_method_names
|
|
384
432
|
# should remove module functions?
|
|
385
|
-
_index().keys.select {|name| /\A\./ =~ name }.
|
|
433
|
+
_index().keys.select {|name| /\A\./ =~ name }.filter_map {|name| name[1..-1] }
|
|
386
434
|
end
|
|
387
435
|
|
|
388
436
|
def instance_method_names
|
|
389
|
-
_index().keys.select {|name| /\A\#/ =~ name }.
|
|
437
|
+
_index().keys.select {|name| /\A\#/ =~ name }.filter_map {|name| name[1..-1] }
|
|
390
438
|
end
|
|
391
439
|
|
|
392
440
|
def constant_names
|
|
393
|
-
_index().keys.select {|name| /\A\:/ =~ name }.
|
|
441
|
+
_index().keys.select {|name| /\A\:/ =~ name }.filter_map {|name| name[1..-1] }
|
|
394
442
|
end
|
|
395
443
|
|
|
396
444
|
def special_variable_names
|
|
@@ -404,7 +452,7 @@ module BitClust
|
|
|
404
452
|
end
|
|
405
453
|
|
|
406
454
|
def description
|
|
407
|
-
source.split(/\n\n+/, 2)[0].strip
|
|
455
|
+
description_text(source.split(/\n\n+/, 2)[0].strip)
|
|
408
456
|
end
|
|
409
457
|
|
|
410
458
|
def clear_cache
|
|
@@ -433,11 +481,12 @@ module BitClust
|
|
|
433
481
|
return aliasof().__send__("_#{typechar}map").dup
|
|
434
482
|
end
|
|
435
483
|
s = superclass()
|
|
484
|
+
# @type var map: Hash[String, String]
|
|
436
485
|
map = s ? s.__send__("_#{typechar}map").dup : {}
|
|
437
486
|
inherited_modules.each do |mod|
|
|
438
487
|
map.update mod.__send__("_#{typechar == 'c' ? 'c' : 'i'}map")
|
|
439
488
|
end
|
|
440
|
-
defined, undefined =
|
|
489
|
+
defined, undefined = ents.partition {|m| m.defined? }
|
|
441
490
|
(undefined + defined).each do |m|
|
|
442
491
|
m.names.each do |name|
|
|
443
492
|
map[name] = m.spec_string
|
|
@@ -464,9 +513,11 @@ module BitClust
|
|
|
464
513
|
def _index
|
|
465
514
|
@_index ||=
|
|
466
515
|
begin
|
|
516
|
+
# @type var h: Hash[String, String]
|
|
467
517
|
h = {}
|
|
468
518
|
@db.foreach_line("method/#{@id}/=index") do |line|
|
|
469
519
|
name, spec = line.split
|
|
520
|
+
name || raise; spec || raise
|
|
470
521
|
h[name] = spec
|
|
471
522
|
end
|
|
472
523
|
h
|
data/lib/bitclust/compat.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
#
|
|
2
3
|
# Compatibility for older rubies
|
|
3
4
|
#
|
|
@@ -37,7 +38,7 @@ end
|
|
|
37
38
|
def fopen(*args, &block)
|
|
38
39
|
option = args[1]
|
|
39
40
|
if option and !Object.const_defined?(:Encoding)
|
|
40
|
-
args[1] = option.sub(/:.*\z/, '')
|
|
41
|
+
args[1] = option.sub(/:.*\z/, '') # steep:ignore
|
|
41
42
|
end
|
|
42
|
-
File.open(*args, &block)
|
|
43
|
+
File.open(*args, &block) # steep:ignore
|
|
43
44
|
end
|