bitclust-core 1.2.1 → 1.2.6
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/data/bitclust/catalog/ja_JP.UTF-8 +4 -0
- data/data/bitclust/template.lillia/layout +1 -1
- data/data/bitclust/template.offline/class +127 -34
- data/data/bitclust/template.offline/class-index +33 -6
- data/data/bitclust/template.offline/doc +41 -8
- data/data/bitclust/template.offline/function +42 -9
- data/data/bitclust/template.offline/function-index +33 -7
- data/data/bitclust/template.offline/layout +21 -14
- data/data/bitclust/template.offline/library +48 -12
- data/data/bitclust/template.offline/library-index +33 -6
- data/data/bitclust/template.offline/method +56 -11
- data/lib/bitclust/classentry.rb +13 -2
- data/lib/bitclust/compat.rb +8 -0
- data/lib/bitclust/completion.rb +1 -0
- data/lib/bitclust/docentry.rb +4 -2
- data/lib/bitclust/entry.rb +3 -0
- data/lib/bitclust/functionentry.rb +8 -7
- data/lib/bitclust/functionreferenceparser.rb +2 -0
- data/lib/bitclust/libraryentry.rb +4 -1
- data/lib/bitclust/lineinput.rb +6 -2
- data/lib/bitclust/methoddatabase.rb +3 -0
- data/lib/bitclust/methodentry.rb +10 -8
- data/lib/bitclust/methodid.rb +1 -0
- data/lib/bitclust/nameutils.rb +15 -11
- data/lib/bitclust/preprocessor.rb +26 -21
- data/lib/bitclust/rdcompiler.rb +29 -19
- data/lib/bitclust/requesthandler.rb +3 -3
- data/lib/bitclust/ridatabase.rb +2 -1
- data/lib/bitclust/rrdparser.rb +19 -20
- data/lib/bitclust/screen.rb +39 -4
- data/lib/bitclust/silent_progress_bar.rb +8 -4
- data/lib/bitclust/simplesearcher.rb +1 -1
- data/lib/bitclust/subcommand.rb +9 -0
- data/lib/bitclust/subcommands/chm_command.rb +3 -3
- data/lib/bitclust/subcommands/methods_command.rb +1 -1
- data/lib/bitclust/subcommands/server_command.rb +6 -1
- data/lib/bitclust/subcommands/setup_command.rb +2 -2
- data/lib/bitclust/subcommands/statichtml_command.rb +44 -21
- data/lib/bitclust/syntax_highlighter.rb +5 -3
- data/lib/bitclust/version.rb +1 -1
- data/test/test_bitclust.rb +1 -1
- data/test/test_entry.rb +14 -1
- data/test/test_functionreferenceparser.rb +4 -4
- data/test/test_preprocessor.rb +21 -0
- data/test/test_rdcompiler.rb +240 -0
- data/test/test_rrdparser.rb +16 -0
- data/test/test_syntax_highlighter.rb +22 -4
- data/theme/default/rurema.png +0 -0
- data/theme/default/rurema.svg +31 -0
- data/theme/default/script.js +34 -0
- data/theme/default/style.css +112 -8
- metadata +32 -19
@@ -122,17 +122,18 @@ module BitClust
|
|
122
122
|
@stack = []
|
123
123
|
@name_buffer = []
|
124
124
|
@__lexer.define_singleton_method(:on_parse_error) do |message|
|
125
|
-
raise ParseError.new(filename, self.lineno, self.column, message)
|
125
|
+
raise ParseError.new(filename, self.lineno, self.column, "#{message}\n#{src}")
|
126
126
|
end
|
127
127
|
@__lexer.define_singleton_method(:compile_error) do |message|
|
128
|
-
raise CompileError.new(filename, self.lineno, self.column, message)
|
128
|
+
raise CompileError.new(filename, self.lineno, self.column, "#{message}\n#{src}")
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
132
|
def on_default(event, token, data)
|
133
133
|
event_name = event.to_s.sub(/\Aon_/, "") # :on_event --> "event"
|
134
134
|
style = COLORS[event_name.to_sym]
|
135
|
-
|
135
|
+
escaped_token = escape_html(token)
|
136
|
+
data << (style ? "<span class=\"#{style}\">#{escaped_token}</span>" : escaped_token)
|
136
137
|
data
|
137
138
|
end
|
138
139
|
|
@@ -215,6 +216,7 @@ module BitClust
|
|
215
216
|
when token == "::" && [:class, :module].include?(@stack.last)
|
216
217
|
@name_buffer << token
|
217
218
|
else
|
219
|
+
@stack.pop if @stack.last == :method_call
|
218
220
|
on_default(:on_op, token, data)
|
219
221
|
end
|
220
222
|
data
|
data/lib/bitclust/version.rb
CHANGED
data/test/test_bitclust.rb
CHANGED
data/test/test_entry.rb
CHANGED
@@ -9,6 +9,14 @@ alias HogeHoge
|
|
9
9
|
alias HogeHogeHoge
|
10
10
|
== Class Methods
|
11
11
|
--- hoge
|
12
|
+
hoge
|
13
|
+
--- fuga
|
14
|
+
@undef
|
15
|
+
fuga
|
16
|
+
== Instance Methods
|
17
|
+
--- fugafuga
|
18
|
+
@undef
|
19
|
+
fugafuga
|
12
20
|
= class Bar < Hoge
|
13
21
|
== Class Methods
|
14
22
|
--- bar
|
@@ -19,7 +27,7 @@ HERE
|
|
19
27
|
end
|
20
28
|
|
21
29
|
def test_entries
|
22
|
-
assert_equal(['bar', 'hoge'],
|
30
|
+
assert_equal(['bar', 'fuga', 'fugafuga', 'hoge'],
|
23
31
|
@lib.fetch_class("Bar").entries(1).map{|e| e.name}.sort)
|
24
32
|
end
|
25
33
|
|
@@ -45,6 +53,11 @@ HERE
|
|
45
53
|
assert(@lib.fetch_class("ErrErr").error_class?)
|
46
54
|
end
|
47
55
|
|
56
|
+
def test_partitioned_entries
|
57
|
+
parts = @lib.fetch_class('Hoge').partitioned_entries
|
58
|
+
assert_equal(['fuga', 'fugafuga'], parts.undefined.map(&:name))
|
59
|
+
end
|
60
|
+
|
48
61
|
def test_superclass
|
49
62
|
assert('Exception', @lib.fetch_class("Err").superclass.name)
|
50
63
|
assert('Exception', @lib.fetch_class("ErrErr").superclass.name)
|
@@ -33,12 +33,12 @@ HERE
|
|
33
33
|
:version => "1.9.3",
|
34
34
|
:expected => ["some text 2\n"],
|
35
35
|
},
|
36
|
-
"2.
|
37
|
-
:version => "2.
|
36
|
+
"2.5.0" => {
|
37
|
+
:version => "2.5.0",
|
38
38
|
:expected => ["some text 1\n"],
|
39
39
|
},
|
40
|
-
"2.
|
41
|
-
:version => "2.
|
40
|
+
"2.6.0" => {
|
41
|
+
:version => "2.6.0",
|
42
42
|
:expected => ["some text 1\n"],
|
43
43
|
})
|
44
44
|
def test_parse_file(data)
|
data/test/test_preprocessor.rb
CHANGED
@@ -109,6 +109,27 @@ HERE
|
|
109
109
|
assert_equal(expected, ret.join)
|
110
110
|
end
|
111
111
|
|
112
|
+
def test_nested_condition
|
113
|
+
params = { 'version' => '2.4.0' }
|
114
|
+
src = <<~'HERE'
|
115
|
+
#@until 2.4.0
|
116
|
+
#@since 1.8.7
|
117
|
+
#@since 1.9.3
|
118
|
+
#@since 2.0.0
|
119
|
+
Not display here!
|
120
|
+
#@end
|
121
|
+
#@end
|
122
|
+
#@end
|
123
|
+
#@end
|
124
|
+
Display here!
|
125
|
+
HERE
|
126
|
+
expected = <<~HERE
|
127
|
+
Display here!
|
128
|
+
HERE
|
129
|
+
ret = Preprocessor.wrap(StringIO.new(src), params).to_a
|
130
|
+
assert_equal(expected, ret.join)
|
131
|
+
end
|
132
|
+
|
112
133
|
sub_test_case("samplecode") do
|
113
134
|
|
114
135
|
def test_samplecode
|
data/test/test_rdcompiler.rb
CHANGED
@@ -3,6 +3,7 @@ require 'bitclust/database'
|
|
3
3
|
require 'bitclust/methoddatabase'
|
4
4
|
require 'bitclust/screen'
|
5
5
|
require 'test/unit'
|
6
|
+
require 'test/unit/rr'
|
6
7
|
require 'timeout'
|
7
8
|
|
8
9
|
class TestRDCompiler < Test::Unit::TestCase
|
@@ -835,4 +836,243 @@ HERE
|
|
835
836
|
def test_rdoc_link(data)
|
836
837
|
assert_equal(data[:expected], @c.rdoc_link(data[:method_id], data[:version]))
|
837
838
|
end
|
839
|
+
|
840
|
+
def test_paragraph_with_single_line
|
841
|
+
source = <<~SOURCE
|
842
|
+
a
|
843
|
+
SOURCE
|
844
|
+
expected = <<~HTML
|
845
|
+
<p>
|
846
|
+
a
|
847
|
+
</p>
|
848
|
+
HTML
|
849
|
+
assert_equal(
|
850
|
+
expected,
|
851
|
+
@c.compile(source)
|
852
|
+
)
|
853
|
+
end
|
854
|
+
|
855
|
+
def test_paragraph_with_newline_between_ascii_and_ascii
|
856
|
+
source = <<~SOURCE
|
857
|
+
a
|
858
|
+
a
|
859
|
+
SOURCE
|
860
|
+
expected = <<~HTML
|
861
|
+
<p>
|
862
|
+
a
|
863
|
+
a
|
864
|
+
</p>
|
865
|
+
HTML
|
866
|
+
assert_equal(
|
867
|
+
expected,
|
868
|
+
@c.compile(source)
|
869
|
+
)
|
870
|
+
end
|
871
|
+
|
872
|
+
def test_paragraph_with_newline_between_ascii_and_non_ascii
|
873
|
+
source = <<~SOURCE
|
874
|
+
a
|
875
|
+
あ
|
876
|
+
SOURCE
|
877
|
+
expected = <<~HTML
|
878
|
+
<p>
|
879
|
+
a
|
880
|
+
あ
|
881
|
+
</p>
|
882
|
+
HTML
|
883
|
+
assert_equal(
|
884
|
+
expected,
|
885
|
+
@c.compile(source)
|
886
|
+
)
|
887
|
+
end
|
888
|
+
|
889
|
+
def test_paragraph_with_newline_between_non_ascii_and_ascii
|
890
|
+
source = <<~SOURCE
|
891
|
+
あ
|
892
|
+
a
|
893
|
+
SOURCE
|
894
|
+
expected = <<~HTML
|
895
|
+
<p>
|
896
|
+
あ
|
897
|
+
a
|
898
|
+
</p>
|
899
|
+
HTML
|
900
|
+
assert_equal(
|
901
|
+
expected,
|
902
|
+
@c.compile(source)
|
903
|
+
)
|
904
|
+
end
|
905
|
+
|
906
|
+
def test_paragraph_with_newline_between_non_ascii_and_non_ascii
|
907
|
+
source = <<~SOURCE
|
908
|
+
あ
|
909
|
+
あ
|
910
|
+
SOURCE
|
911
|
+
expected = <<~HTML
|
912
|
+
<p>
|
913
|
+
ああ
|
914
|
+
</p>
|
915
|
+
HTML
|
916
|
+
assert_equal(
|
917
|
+
expected,
|
918
|
+
@c.compile(source)
|
919
|
+
)
|
920
|
+
end
|
921
|
+
|
922
|
+
def test_definition_list_with_ascii
|
923
|
+
source = <<~SOURCE
|
924
|
+
: b
|
925
|
+
あ
|
926
|
+
あ
|
927
|
+
SOURCE
|
928
|
+
expected = <<~HTML
|
929
|
+
<dl>
|
930
|
+
<dt>b</dt>
|
931
|
+
<dd>
|
932
|
+
<p>
|
933
|
+
ああ
|
934
|
+
</p>
|
935
|
+
</dd>
|
936
|
+
</dl>
|
937
|
+
HTML
|
938
|
+
assert_equal(
|
939
|
+
expected,
|
940
|
+
@c.compile(source)
|
941
|
+
)
|
942
|
+
end
|
943
|
+
|
944
|
+
def test_definition_list_with_non_ascii
|
945
|
+
source = <<~SOURCE
|
946
|
+
: b
|
947
|
+
a
|
948
|
+
a
|
949
|
+
SOURCE
|
950
|
+
expected = <<~HTML
|
951
|
+
<dl>
|
952
|
+
<dt>b</dt>
|
953
|
+
<dd>
|
954
|
+
<p>
|
955
|
+
a
|
956
|
+
a
|
957
|
+
</p>
|
958
|
+
</dd>
|
959
|
+
</dl>
|
960
|
+
HTML
|
961
|
+
assert_equal(
|
962
|
+
expected,
|
963
|
+
@c.compile(source)
|
964
|
+
)
|
965
|
+
end
|
966
|
+
|
967
|
+
def test_entry_info_with_ascii
|
968
|
+
source = <<~SOURCE
|
969
|
+
--- b
|
970
|
+
|
971
|
+
@param arg あ
|
972
|
+
あ
|
973
|
+
SOURCE
|
974
|
+
expected = <<~HTML
|
975
|
+
<dt class="method-heading" id="dummy"><code>b</code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
|
976
|
+
<dd class="method-description">
|
977
|
+
<dl>
|
978
|
+
<dt class='method-param'>[PARAM] arg:</dt>
|
979
|
+
<dd>
|
980
|
+
ああ
|
981
|
+
</dd>
|
982
|
+
</dl>
|
983
|
+
</dd>
|
984
|
+
HTML
|
985
|
+
assert_compiled_method_source(expected, source)
|
986
|
+
end
|
987
|
+
|
988
|
+
def test_entry_info_with_non_ascii
|
989
|
+
source = <<~SOURCE
|
990
|
+
--- b
|
991
|
+
@param arg a
|
992
|
+
a
|
993
|
+
SOURCE
|
994
|
+
expected = <<~HTML
|
995
|
+
<dt class="method-heading" id="dummy"><code>b</code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
|
996
|
+
<dd class="method-description">
|
997
|
+
<dl>
|
998
|
+
<dt class='method-param'>[PARAM] arg:</dt>
|
999
|
+
<dd>
|
1000
|
+
a
|
1001
|
+
a
|
1002
|
+
</dd>
|
1003
|
+
</dl>
|
1004
|
+
</dd>
|
1005
|
+
HTML
|
1006
|
+
assert_compiled_method_source(expected, source)
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
def test_entry_paragraph_with_ascii
|
1010
|
+
source = <<~SOURCE
|
1011
|
+
--- b
|
1012
|
+
あ
|
1013
|
+
あ
|
1014
|
+
SOURCE
|
1015
|
+
expected = <<~HTML
|
1016
|
+
<dt class="method-heading" id="dummy"><code>b</code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
|
1017
|
+
<dd class="method-description">
|
1018
|
+
<p>
|
1019
|
+
ああ
|
1020
|
+
</p>
|
1021
|
+
</dd>
|
1022
|
+
HTML
|
1023
|
+
assert_compiled_method_source(expected, source)
|
1024
|
+
end
|
1025
|
+
|
1026
|
+
def test_entry_paragraph_with_non_ascii
|
1027
|
+
source = <<~SOURCE
|
1028
|
+
--- b
|
1029
|
+
a
|
1030
|
+
a
|
1031
|
+
SOURCE
|
1032
|
+
expected = <<~HTML
|
1033
|
+
<dt class="method-heading" id="dummy"><code>b</code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
|
1034
|
+
<dd class="method-description">
|
1035
|
+
<p>
|
1036
|
+
a
|
1037
|
+
a
|
1038
|
+
</p>
|
1039
|
+
</dd>
|
1040
|
+
HTML
|
1041
|
+
assert_compiled_method_source(expected, source)
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
def test_entry_see_with_ascii
|
1045
|
+
source = <<~SOURCE
|
1046
|
+
--- b
|
1047
|
+
@see あ
|
1048
|
+
あ
|
1049
|
+
SOURCE
|
1050
|
+
expected = <<~HTML
|
1051
|
+
<dt class="method-heading" id="dummy"><code>b</code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
|
1052
|
+
<dd class="method-description">
|
1053
|
+
<p>
|
1054
|
+
[SEE_ALSO] ああ
|
1055
|
+
</p>
|
1056
|
+
</dd>
|
1057
|
+
HTML
|
1058
|
+
assert_compiled_method_source(expected, source)
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
def test_entry_see_with_non_ascii
|
1062
|
+
source = <<~SOURCE
|
1063
|
+
--- b
|
1064
|
+
@see a
|
1065
|
+
a
|
1066
|
+
SOURCE
|
1067
|
+
expected = <<~HTML
|
1068
|
+
<dt class="method-heading" id="dummy"><code>b</code><span class="permalink">[<a href="dummy/method/String/i/index">permalink</a>][<a href="https://docs.ruby-lang.org/en/2.0.0/String.html#method-i-index">rdoc</a>]</span></dt>
|
1069
|
+
<dd class="method-description">
|
1070
|
+
<p>
|
1071
|
+
[SEE_ALSO] a
|
1072
|
+
a
|
1073
|
+
</p>
|
1074
|
+
</dd>
|
1075
|
+
HTML
|
1076
|
+
assert_compiled_method_source(expected, source)
|
1077
|
+
end
|
838
1078
|
end
|
data/test/test_rrdparser.rb
CHANGED
@@ -23,4 +23,20 @@ a
|
|
23
23
|
HERE
|
24
24
|
assert_equal(["", "==[a:hoge]hoge\na\n"], result)
|
25
25
|
end
|
26
|
+
|
27
|
+
def test_undef
|
28
|
+
result = BitClust::RRDParser.parse(<<HERE, 'dummy')
|
29
|
+
= module Dummy
|
30
|
+
== Instance Methods
|
31
|
+
--- test_undef
|
32
|
+
|
33
|
+
@undef
|
34
|
+
|
35
|
+
このメソッドは利用できない
|
36
|
+
|
37
|
+
HERE
|
38
|
+
_library, methoddatabase = result
|
39
|
+
test_undef_spec = BitClust::MethodSpec.parse('Dummy#test_undef')
|
40
|
+
assert_equal(:undefined, methoddatabase.get_method(test_undef_spec).kind)
|
41
|
+
end
|
26
42
|
end
|
@@ -7,15 +7,15 @@ class TestSyntaxHighlighter < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
sub_test_case "syntax error" do
|
9
9
|
test "single line" do
|
10
|
-
src = "
|
11
|
-
assert_raise(BitClust::SyntaxHighlighter::ParseError.new("-", 1,
|
10
|
+
src = "foo(\n"
|
11
|
+
assert_raise(BitClust::SyntaxHighlighter::ParseError.new("-", 1, 5, "syntax error, unexpected end-of-input, expecting ')'\n#{src}")) do
|
12
12
|
highlight(src)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
test "multiple line" do
|
17
|
-
src = "a = 1\n
|
18
|
-
assert_raise(BitClust::SyntaxHighlighter::ParseError.new("-", 2,
|
17
|
+
src = "a = 1\nfoo(\n"
|
18
|
+
assert_raise(BitClust::SyntaxHighlighter::ParseError.new("-", 2, 5, "syntax error, unexpected end-of-input, expecting ')'\n#{src}")) do
|
19
19
|
highlight(src)
|
20
20
|
end
|
21
21
|
end
|
@@ -64,4 +64,22 @@ class TestSyntaxHighlighter < Test::Unit::TestCase
|
|
64
64
|
assert_equal(expected, highlight(source))
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
test 'htmlescape' do
|
69
|
+
source = 'puts /<a>/'
|
70
|
+
expected = '<span class="nb">puts</span> <span class="sr">/<a>/</span>'
|
71
|
+
assert_equal(expected, highlight(source))
|
72
|
+
end
|
73
|
+
|
74
|
+
test 'symbol method' do
|
75
|
+
source = <<~END
|
76
|
+
p 1.!
|
77
|
+
p 2
|
78
|
+
END
|
79
|
+
expected = <<~END
|
80
|
+
<span class="nb">p</span> <span class="mi">1</span><span class="p">.</span><span class="o">!</span>
|
81
|
+
<span class="nb">p</span> <span class="mi">2</span>
|
82
|
+
END
|
83
|
+
assert_equal(expected, highlight(source))
|
84
|
+
end
|
67
85
|
end
|
data/theme/default/rurema.png
CHANGED
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<svg width="16" height="16" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
3
|
+
<rect x="2" y="1" width="12" height="12" fill="#33a"/>
|
4
|
+
|
5
|
+
<rect x="4" y="2" width="8" height="10" fill="#f00"/>
|
6
|
+
<rect x="3" y="3" width="1" height="8" fill="#000"/>
|
7
|
+
<rect x="5" y="1" width="6" height="1" fill="#000"/>
|
8
|
+
<rect x="12" y="3" width="1" height="8" fill="#000"/>
|
9
|
+
<rect x="5" y="12" width="6" height="1" fill="#000"/>
|
10
|
+
|
11
|
+
<rect x="4" y="2" width="1" height="1" fill="#300"/>
|
12
|
+
<rect x="11" y="2" width="1" height="1" fill="#300"/>
|
13
|
+
<rect x="4" y="11" width="1" height="1" fill="#300"/>
|
14
|
+
<rect x="11" y="11" width="1" height="1" fill="#300"/>
|
15
|
+
|
16
|
+
<rect x="5" y="3" width="1" height="1" fill="#600"/>
|
17
|
+
<rect x="10" y="3" width="1" height="1" fill="#600"/>
|
18
|
+
<rect x="5" y="10" width="1" height="1" fill="#600"/>
|
19
|
+
<rect x="10" y="10" width="1" height="1" fill="#600"/>
|
20
|
+
|
21
|
+
<rect x="6" y="4" width="4" height="6" fill="#000"/>
|
22
|
+
<rect x="7" y="5" width="2" height="4" fill="#f00"/>
|
23
|
+
|
24
|
+
<rect x="2" y="0" width="12" height="1" fill="#000"/>
|
25
|
+
<rect x="14" y="0" width="1" height="14" fill="#000"/>
|
26
|
+
<rect x="2" y="13" width="12" height="1" fill="#000"/>
|
27
|
+
<rect x="1" y="1" width="1" height="14" fill="#000"/>
|
28
|
+
<rect x="2" y="14" width="11" height="1" fill="#ccc"/>
|
29
|
+
<rect x="13" y="14" width="1" height="1" fill="#000"/>
|
30
|
+
<rect x="2" y="15" width="13" height="1" fill="#000"/>
|
31
|
+
</svg>
|