bitclust-core 1.6.0 → 1.7.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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -0
  3. data/data/bitclust/catalog/ja_JP.UTF-8 +4 -2
  4. data/data/bitclust/template/function-index +1 -0
  5. data/data/bitclust/template/layout +1 -0
  6. data/data/bitclust/template.offline/function-index +1 -0
  7. data/data/bitclust/template.offline/layout +3 -0
  8. data/lib/bitclust/classentry.rb +1 -1
  9. data/lib/bitclust/docentry.rb +1 -1
  10. data/lib/bitclust/functionentry.rb +1 -1
  11. data/lib/bitclust/irb.rb +68 -0
  12. data/lib/bitclust/markdown_exporter.rb +311 -0
  13. data/lib/bitclust/mdcompiler.rb +15 -1
  14. data/lib/bitclust/mdparser.rb +42 -1
  15. data/lib/bitclust/methoddatabase.rb +4 -0
  16. data/lib/bitclust/methodentry.rb +24 -0
  17. data/lib/bitclust/methodsignature.rb +1 -1
  18. data/lib/bitclust/preprocessor.rb +4 -1
  19. data/lib/bitclust/rbs_overload_matcher.rb +179 -0
  20. data/lib/bitclust/rbs_sig_importer.rb +276 -0
  21. data/lib/bitclust/rbs_signatures.rb +125 -0
  22. data/lib/bitclust/rdcompiler.rb +12 -1
  23. data/lib/bitclust/runner.rb +2 -0
  24. data/lib/bitclust/screen.rb +4 -0
  25. data/lib/bitclust/search_index_generator.rb +28 -10
  26. data/lib/bitclust/searcher.rb +12 -2
  27. data/lib/bitclust/subcommands/rbssig_command.rb +99 -0
  28. data/lib/bitclust/subcommands/setup_command.rb +4 -1
  29. data/lib/bitclust/subcommands/statichtml_command.rb +59 -0
  30. data/lib/bitclust/version.rb +1 -1
  31. data/lib/bitclust-irb.rb +2 -0
  32. data/test/test_irb_plugin.rb +118 -0
  33. data/test/test_link_checker.rb +1 -1
  34. data/test/test_markdown_exporter.rb +260 -0
  35. data/test/test_mdcompiler.rb +47 -5
  36. data/test/test_mdparser.rb +219 -4
  37. data/test/test_methodentry.rb +111 -0
  38. data/test/test_methodsignature.rb +3 -1
  39. data/test/test_preprocessor.rb +26 -0
  40. data/test/test_rbs_overload_matcher.rb +170 -0
  41. data/test/test_rbs_sig_importer.rb +237 -0
  42. data/test/test_rbssig_command.rb +186 -0
  43. data/test/test_rdcompiler.rb +99 -1
  44. data/test/test_search_index_generator.rb +81 -0
  45. data/test/test_setup_command.rb +21 -0
  46. data/test/test_statichtml_command.rb +137 -0
  47. data/theme/default/js/run.js +14 -0
  48. data/theme/default/js/search_init.js +3 -1
  49. data/theme/default/js/search_page.js +7 -1
  50. data/theme/default/js/version_switcher.js +147 -0
  51. data/theme/default/search.css +21 -0
  52. data/theme/default/style.css +83 -7
  53. data/theme/lillia/style.css +26 -0
  54. metadata +35 -1
@@ -0,0 +1,147 @@
1
+ // Version switcher for statichtml pages served under a /ja/<version>/ tree.
2
+ //
3
+ // Renders a <select> into the #version-switcher slot in the top bar. Picking
4
+ // a version navigates to the same page under that version; if the page does
5
+ // not exist there, it falls back to the newest version that has it, and as a
6
+ // last resort to that version's top page. On the first interaction every
7
+ // other version is probed with a HEAD request and missing ones are disabled.
8
+ //
9
+ // Pages not served under a versioned path (local previews, /ja/search/) get
10
+ // no switcher: attach() is a no-op there.
11
+ (function () {
12
+ 'use strict';
13
+
14
+ // 公開済みの版(新しい順)。doctree の Rakefile の
15
+ // SUPPORTED_VERSIONS / OLD_VERSIONS と揃える。
16
+ var RELEASED_VERSIONS = [
17
+ '4.0', '3.4', '3.3', '3.2', '3.1', '3.0',
18
+ '2.7.0', '2.6.0', '2.5.0', '2.4.0', '2.3.0', '2.2.0', '2.1.0', '2.0.0',
19
+ '1.9.3', '1.8.7'
20
+ ];
21
+ var EDGE_VERSION = 'master';
22
+ var ALIASES = ['latest', EDGE_VERSION];
23
+
24
+ function knownVersion(version) {
25
+ return RELEASED_VERSIONS.indexOf(version) !== -1 ||
26
+ ALIASES.indexOf(version) !== -1;
27
+ }
28
+
29
+ function parsePath(pathname) {
30
+ var m = /^(.*\/ja\/)([^\/]+)(\/.+)$/.exec(pathname);
31
+ if (!m || !knownVersion(m[2])) return null;
32
+ return { base: m[1], version: m[2], rest: m[3] };
33
+ }
34
+
35
+ function targetUrl(parsed, version) {
36
+ return parsed.base + version + parsed.rest;
37
+ }
38
+
39
+ function optionVersions(currentVersion) {
40
+ var versions = [EDGE_VERSION].concat(RELEASED_VERSIONS);
41
+ if (versions.indexOf(currentVersion) === -1) {
42
+ versions.unshift(currentVersion);
43
+ }
44
+ return versions;
45
+ }
46
+
47
+ // true: exists / false: does not exist / null: unknown (network error)
48
+ function checkExists(url) {
49
+ return fetch(url, { method: 'HEAD' })
50
+ .then(function (res) { return res.ok; })
51
+ .catch(function () { return null; });
52
+ }
53
+
54
+ // Resolve where picking `version` should go. Unknown existence keeps the
55
+ // target so an offline or CORS-restricted page still just navigates.
56
+ function resolveTarget(parsed, version, exists) {
57
+ var target = targetUrl(parsed, version);
58
+ return exists(target).then(function (ok) {
59
+ if (ok !== false) return target;
60
+ var candidates = RELEASED_VERSIONS.filter(function (v) {
61
+ return v !== version;
62
+ });
63
+ var tryNext = function (i) {
64
+ if (i >= candidates.length) return parsed.base + version + '/';
65
+ var url = targetUrl(parsed, candidates[i]);
66
+ return exists(url).then(function (found) {
67
+ return found === true ? url : tryNext(i + 1);
68
+ });
69
+ };
70
+ return tryNext(0);
71
+ });
72
+ }
73
+
74
+ function attach(deps) {
75
+ var doc = deps.document;
76
+ var slot = doc.getElementById('version-switcher');
77
+ var parsed = parsePath(deps.location.pathname);
78
+ if (!slot || !parsed) return false;
79
+ var exists = deps.checkExists || checkExists;
80
+
81
+ var select = doc.createElement('select');
82
+ select.setAttribute('aria-label', '他のバージョンの同じページを表示');
83
+ optionVersions(parsed.version).forEach(function (version) {
84
+ var option = doc.createElement('option');
85
+ option.value = version;
86
+ option.textContent = version;
87
+ option.selected = version === parsed.version;
88
+ select.appendChild(option);
89
+ });
90
+ select.value = parsed.version;
91
+
92
+ var probed = false;
93
+ var probe = function () {
94
+ if (probed) return;
95
+ probed = true;
96
+ Array.prototype.forEach.call(select.children, function (option) {
97
+ if (option.value === parsed.version) return;
98
+ exists(targetUrl(parsed, option.value)).then(function (ok) {
99
+ if (ok === false) option.disabled = true;
100
+ });
101
+ });
102
+ };
103
+ select.addEventListener('focus', probe);
104
+ select.addEventListener('mousedown', probe);
105
+ select.addEventListener('touchstart', probe);
106
+
107
+ select.addEventListener('change', function () {
108
+ var version = select.value;
109
+ if (version === parsed.version) return;
110
+ resolveTarget(parsed, version, exists).then(function (url) {
111
+ deps.setHref(url);
112
+ });
113
+ });
114
+
115
+ slot.appendChild(select);
116
+ return true;
117
+ }
118
+
119
+ var api = {
120
+ RELEASED_VERSIONS: RELEASED_VERSIONS,
121
+ EDGE_VERSION: EDGE_VERSION,
122
+ parsePath: parsePath,
123
+ targetUrl: targetUrl,
124
+ optionVersions: optionVersions,
125
+ checkExists: checkExists,
126
+ resolveTarget: resolveTarget,
127
+ attach: attach
128
+ };
129
+ if (typeof globalThis !== 'undefined') {
130
+ globalThis.RuremaVersionSwitcher = api;
131
+ }
132
+
133
+ if (typeof document !== 'undefined' && typeof location !== 'undefined') {
134
+ var init = function () {
135
+ attach({
136
+ document: document,
137
+ location: location,
138
+ setHref: function (url) { location.href = url; }
139
+ });
140
+ };
141
+ if (document.readyState === 'loading') {
142
+ document.addEventListener('DOMContentLoaded', init);
143
+ } else {
144
+ init();
145
+ }
146
+ }
147
+ })();
@@ -26,6 +26,27 @@
26
26
  text-overflow: ellipsis;
27
27
  }
28
28
 
29
+ /* Version switcher: sits next to the brand; the auto margin keeps the
30
+ search box pinned to the right. The slot is empty until
31
+ version_switcher.js fills it (only on /ja/<version>/ pages). */
32
+ #version-switcher {
33
+ flex: 0 0 auto;
34
+ margin-right: auto;
35
+ }
36
+
37
+ #version-switcher:empty {
38
+ display: none;
39
+ }
40
+
41
+ #version-switcher select {
42
+ font-size: 0.9em;
43
+ padding: 0.2em 0.3em;
44
+ border: 1px solid #99a;
45
+ border-radius: 4px;
46
+ background: #fff;
47
+ color: inherit;
48
+ }
49
+
29
50
  #search-section {
30
51
  position: relative;
31
52
  flex: 0 0 auto;
@@ -273,6 +273,25 @@ pre.highlight.ruby[data-editing="true"] > code:focus {
273
273
  left: -1000px;
274
274
  }
275
275
 
276
+ /* for ?(RUN のヘルプページへのリンク。highlight__button-group の中で
277
+ COPY の右に入る)。ボタン(RUN・COPY)と違いページ遷移するリンクなので、
278
+ 色・ホバーはサイト共通のリンクの見た目(a のスタイル)に任せて、
279
+ ここでは丸囲みの形と配置だけ整える */
280
+ .highlight__help-link {
281
+ display: inline-block;
282
+ box-sizing: border-box;
283
+ width: 1.5em;
284
+ height: 1.5em;
285
+ line-height: calc(1.5em - 2px);
286
+ text-align: center;
287
+ /* ただの ? だとクリックできると気付きにくいので、丸囲みはてなにして
288
+ ヘルプアイコンらしくする。枠は currentColor なので、リンク色にも
289
+ ホバーの反転(白文字+#33a 背景)にもそのまま追従する */
290
+ border: 1px solid currentColor;
291
+ border-radius: 50%;
292
+ margin: 0 0.25em 0.25em 0.5em;
293
+ }
294
+
276
295
  /* サンプルコードのキャプション。pre の上に密着したタブとして表示する
277
296
  (上だけ角丸でタブらしく)。script.js がツールバー行の左端に取り込む。
278
297
  下のコード部分と同じ背景色にして「つながったタブ」に見せる(ヘッダー
@@ -329,26 +348,57 @@ dd {
329
348
  margin: 0.3em 0em 1em 4em;
330
349
  }
331
350
 
351
+ /* 表の基本スタイルは本文中のコンテンツ表(Markdown のテーブル)向け:
352
+ セルに罫線と余白を付けて読みやすくする。text-align はセルの
353
+ インラインスタイル(列揃え指定)が上書きする。
354
+ メソッド一覧などのカード状レイアウト表は後続の .entries 系の
355
+ 上書きで従来の見た目を維持する */
332
356
  table {
333
357
  border-collapse: collapse;
358
+ margin: 0.5em 0 1em;
334
359
  }
335
360
 
336
- th {
361
+ th,
362
+ td {
337
363
  text-align: left;
338
364
  vertical-align: top;
339
- background-color: #AAC;
340
- border: 3px solid white;
341
- padding: 0.3em;
365
+ border: 1px solid #bbb;
366
+ padding: 0.3em 0.8em;
342
367
  }
343
368
 
344
- td {
345
- text-align: left;
346
- vertical-align: top;
369
+ th {
370
+ background-color: #dde;
371
+ }
372
+
373
+ tbody tr:nth-child(even) {
374
+ background-color: #f5f5f5;
347
375
  }
348
376
 
349
377
  table.entries {
350
378
  width: 100%;
351
379
  height: 100%;
380
+ margin: 0;
381
+ }
382
+
383
+ /* セルの打ち消しは .entries 前置で書く。td.signature 等の個別ルール
384
+ (このファイルの後方)と同格の詳細度に抑えて、後勝ちでそちらを
385
+ 優先させるため(table.entries td だと個別ルールより強くなる) */
386
+ .entries th {
387
+ background-color: #AAC;
388
+ border: 3px solid white;
389
+ padding: 0.3em;
390
+ }
391
+
392
+ .entries td {
393
+ border: none;
394
+ padding: 0;
395
+ }
396
+
397
+ /* tbody はテンプレートでは書かれないがブラウザが補うため、
398
+ コンテンツ表向けの縞がここにも当たるのを打ち消す
399
+ (セル自身の背景で見えないが明示的に無効化しておく) */
400
+ .entries tr:nth-child(even) {
401
+ background-color: transparent;
352
402
  }
353
403
 
354
404
  table.entries tr {
@@ -586,3 +636,29 @@ span.method-until-badge {
586
636
  }
587
637
  span.method-since-badge { background-color: #e6f2e6; color: #2d6a2d; }
588
638
  span.method-until-badge { background-color: #f7e6e6; color: #aa3333; }
639
+
640
+ /* RBS 型シグネチャ(rbssig サブコマンドが 4.0 以降の DB に書き込み、
641
+ メソッド見出しの <dt> 群の直後に 1 オーバーロード 1 行の
642
+ <dt class="rbs-signature"> として出る)。参考情報なので rdoc の型表示の
643
+ ように小さく・薄く・少し字下げして、メソッド定義の見出しと明確に
644
+ 区別する。行の大半はクラスへのリンクなので、リンクの太字(a の既定)と
645
+ リンク色もここで打ち消さないと見出しと同じ太字の青になってしまう。
646
+ インラインコードのチップ背景も外す */
647
+ dt.rbs-signature {
648
+ font-weight: normal;
649
+ font-size: 80%;
650
+ color: #999;
651
+ line-height: 1.4;
652
+ margin-left: 2em;
653
+ }
654
+ dt.rbs-signature code {
655
+ background-color: transparent;
656
+ padding: 0;
657
+ border-radius: 0;
658
+ font-size: 100%; /* code の 90% 縮小と二重に掛けない(実効 80%) */
659
+ }
660
+ dt.rbs-signature a:link,
661
+ dt.rbs-signature a:visited {
662
+ font-weight: normal;
663
+ color: #8895b5;
664
+ }
@@ -317,6 +317,32 @@ span.method-until-badge {
317
317
  span.method-since-badge { background-color: #e6f2e6; color: #2d6a2d; }
318
318
  span.method-until-badge { background-color: #f7e6e6; color: #aa3333; }
319
319
 
320
+ /* RBS 型シグネチャ(rbssig サブコマンドが 4.0 以降の DB に書き込み、
321
+ メソッド見出しの <dt> 群の直後に 1 オーバーロード 1 行の
322
+ <dt class="rbs-signature"> として出る)。参考情報なので rdoc の型表示の
323
+ ように小さく・薄く・少し字下げして、メソッド定義の見出しと明確に
324
+ 区別する。行の大半はクラスへのリンクなので、リンクの太字(a の既定)と
325
+ リンク色もここで打ち消さないと見出しと同じ太字の青になってしまう。
326
+ インラインコードのチップ背景も外す */
327
+ dt.rbs-signature {
328
+ font-weight: normal;
329
+ font-size: 80%;
330
+ color: #999;
331
+ line-height: 1.4;
332
+ margin-left: 2em;
333
+ }
334
+ dt.rbs-signature code {
335
+ background-color: transparent;
336
+ padding: 0;
337
+ border-radius: 0;
338
+ font-size: 100%; /* code の縮小と二重に掛けない(実効 80%) */
339
+ }
340
+ dt.rbs-signature a:link,
341
+ dt.rbs-signature a:visited {
342
+ font-weight: normal;
343
+ color: #8895b5;
344
+ }
345
+
320
346
  .method-description{
321
347
  padding-bottom: 10px;
322
348
  margin-bottom: 90px ;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitclust-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/rurema
@@ -155,6 +155,20 @@ dependencies:
155
155
  - - ">="
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: rbs
160
+ requirement: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '3.10'
165
+ type: :runtime
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '3.10'
158
172
  description: |
159
173
  Rurema is a Japanese ruby documentation project, and
160
174
  bitclust is a rurema document processor.
@@ -215,6 +229,7 @@ files:
215
229
  - data/bitclust/template/method
216
230
  - data/bitclust/template/opensearchdescription
217
231
  - data/bitclust/template/search
232
+ - lib/bitclust-irb.rb
218
233
  - lib/bitclust.rb
219
234
  - lib/bitclust/app.rb
220
235
  - lib/bitclust/capi_converter.rb
@@ -236,10 +251,12 @@ files:
236
251
  - lib/bitclust/include_graph.rb
237
252
  - lib/bitclust/include_pruner.rb
238
253
  - lib/bitclust/interface.rb
254
+ - lib/bitclust/irb.rb
239
255
  - lib/bitclust/libraryentry.rb
240
256
  - lib/bitclust/lineinput.rb
241
257
  - lib/bitclust/link_checker.rb
242
258
  - lib/bitclust/markdown_bridge.rb
259
+ - lib/bitclust/markdown_exporter.rb
243
260
  - lib/bitclust/markdown_orchestrator.rb
244
261
  - lib/bitclust/markdown_to_rrd.rb
245
262
  - lib/bitclust/markdown_tree.rb
@@ -255,6 +272,9 @@ files:
255
272
  - lib/bitclust/parseutils.rb
256
273
  - lib/bitclust/preprocessor.rb
257
274
  - lib/bitclust/progress_bar.rb
275
+ - lib/bitclust/rbs_overload_matcher.rb
276
+ - lib/bitclust/rbs_sig_importer.rb
277
+ - lib/bitclust/rbs_signatures.rb
258
278
  - lib/bitclust/rdcompiler.rb
259
279
  - lib/bitclust/refsdatabase.rb
260
280
  - lib/bitclust/reloadable_request_handler.rb
@@ -285,6 +305,7 @@ files:
285
305
  - lib/bitclust/subcommands/preproc_command.rb
286
306
  - lib/bitclust/subcommands/property_command.rb
287
307
  - lib/bitclust/subcommands/query_command.rb
308
+ - lib/bitclust/subcommands/rbssig_command.rb
288
309
  - lib/bitclust/subcommands/searchpage_command.rb
289
310
  - lib/bitclust/subcommands/server_command.rb
290
311
  - lib/bitclust/subcommands/setup_command.rb
@@ -309,10 +330,12 @@ files:
309
330
  - test/test_functionreferenceparser.rb
310
331
  - test/test_include_graph.rb
311
332
  - test/test_include_pruner.rb
333
+ - test/test_irb_plugin.rb
312
334
  - test/test_libraryentry.rb
313
335
  - test/test_link_checker.rb
314
336
  - test/test_lookup_command.rb
315
337
  - test/test_markdown_bridge.rb
338
+ - test/test_markdown_exporter.rb
316
339
  - test/test_markdown_orchestrator.rb
317
340
  - test/test_markdown_to_rrd.rb
318
341
  - test/test_markdown_tree.rb
@@ -326,6 +349,9 @@ files:
326
349
  - test/test_methodsince_command.rb
327
350
  - test/test_nameutils.rb
328
351
  - test/test_preprocessor.rb
352
+ - test/test_rbs_overload_matcher.rb
353
+ - test/test_rbs_sig_importer.rb
354
+ - test/test_rbssig_command.rb
329
355
  - test/test_rdcompiler.rb
330
356
  - test/test_refsdatabase.rb
331
357
  - test/test_rrd_to_markdown.rb
@@ -337,6 +363,7 @@ files:
337
363
  - test/test_search_screen.rb
338
364
  - test/test_searcher.rb
339
365
  - test/test_searchpage_command.rb
366
+ - test/test_setup_command.rb
340
367
  - test/test_simplesearcher.rb
341
368
  - test/test_statichtml_command.rb
342
369
  - test/test_syntax_highlighter.rb
@@ -350,6 +377,7 @@ files:
350
377
  - theme/default/js/search_navigation.js
351
378
  - theme/default/js/search_page.js
352
379
  - theme/default/js/search_ranker.js
380
+ - theme/default/js/version_switcher.js
353
381
  - theme/default/rurema.png
354
382
  - theme/default/rurema.svg
355
383
  - theme/default/script.js
@@ -400,10 +428,12 @@ test_files:
400
428
  - test/test_functionreferenceparser.rb
401
429
  - test/test_include_graph.rb
402
430
  - test/test_include_pruner.rb
431
+ - test/test_irb_plugin.rb
403
432
  - test/test_libraryentry.rb
404
433
  - test/test_link_checker.rb
405
434
  - test/test_lookup_command.rb
406
435
  - test/test_markdown_bridge.rb
436
+ - test/test_markdown_exporter.rb
407
437
  - test/test_markdown_orchestrator.rb
408
438
  - test/test_markdown_to_rrd.rb
409
439
  - test/test_markdown_tree.rb
@@ -417,6 +447,9 @@ test_files:
417
447
  - test/test_methodsince_command.rb
418
448
  - test/test_nameutils.rb
419
449
  - test/test_preprocessor.rb
450
+ - test/test_rbs_overload_matcher.rb
451
+ - test/test_rbs_sig_importer.rb
452
+ - test/test_rbssig_command.rb
420
453
  - test/test_rdcompiler.rb
421
454
  - test/test_refsdatabase.rb
422
455
  - test/test_rrd_to_markdown.rb
@@ -428,6 +461,7 @@ test_files:
428
461
  - test/test_search_screen.rb
429
462
  - test/test_searcher.rb
430
463
  - test/test_searchpage_command.rb
464
+ - test/test_setup_command.rb
431
465
  - test/test_simplesearcher.rb
432
466
  - test/test_statichtml_command.rb
433
467
  - test/test_syntax_highlighter.rb