bitclust-core 1.0.0 → 1.1.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/data/bitclust/template.lillia/class +4 -1
  3. data/data/bitclust/template.lillia/class-index +4 -1
  4. data/data/bitclust/template.lillia/doc +4 -1
  5. data/data/bitclust/template.lillia/layout +2 -0
  6. data/data/bitclust/template.lillia/library +4 -1
  7. data/data/bitclust/template.lillia/library-index +4 -1
  8. data/data/bitclust/template.lillia/method +2 -1
  9. data/data/bitclust/template.offline/class +4 -1
  10. data/data/bitclust/template.offline/class-index +4 -1
  11. data/data/bitclust/template.offline/doc +4 -1
  12. data/data/bitclust/template.offline/function +1 -0
  13. data/data/bitclust/template.offline/function-index +4 -1
  14. data/data/bitclust/template.offline/layout +3 -0
  15. data/data/bitclust/template.offline/library +4 -1
  16. data/data/bitclust/template.offline/library-index +4 -1
  17. data/data/bitclust/template.offline/method +1 -0
  18. data/data/bitclust/template/class +4 -1
  19. data/data/bitclust/template/class-index +4 -1
  20. data/data/bitclust/template/doc +4 -1
  21. data/data/bitclust/template/function +4 -1
  22. data/data/bitclust/template/layout +3 -0
  23. data/data/bitclust/template/library +4 -1
  24. data/data/bitclust/template/library-index +4 -1
  25. data/data/bitclust/template/method +1 -0
  26. data/lib/bitclust/classentry.rb +4 -0
  27. data/lib/bitclust/docentry.rb +4 -1
  28. data/lib/bitclust/functionentry.rb +3 -1
  29. data/lib/bitclust/libraryentry.rb +5 -3
  30. data/lib/bitclust/methodentry.rb +3 -1
  31. data/lib/bitclust/preprocessor.rb +74 -14
  32. data/lib/bitclust/rdcompiler.rb +35 -15
  33. data/lib/bitclust/screen.rb +12 -1
  34. data/lib/bitclust/subcommands/preproc_command.rb +1 -1
  35. data/lib/bitclust/subcommands/statichtml_command.rb +12 -1
  36. data/lib/bitclust/syntax_highlighter.rb +318 -0
  37. data/lib/bitclust/version.rb +1 -1
  38. data/test/test_preprocessor.rb +209 -1
  39. data/test/test_rdcompiler.rb +79 -0
  40. data/theme/default/style.css +12 -0
  41. data/theme/default/syntax-highlight.css +209 -0
  42. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57ecbefe517245c38d624eba7c094b15dd74dd58
4
- data.tar.gz: d14fb80a4c36eb4d31691e445cbae3b72c7640d6
3
+ metadata.gz: 65bc872cdee2bcbfa401dd333e2da96d4baf89b0
4
+ data.tar.gz: 6eba8bfb09fdb1cabff3c622cf80ef89e090bfb1
5
5
  SHA512:
6
- metadata.gz: 772d801368ebabf759e8ed938ad80f56ba26bfaa542bcd62a5bb7e4635b26032a6dd84b98c72f2fbe6d67e2baa559a838689c3f8155fe994a3b25a545cddc979
7
- data.tar.gz: ef0bfae49465846e9e449ac3840148de2f630881048b768eaf345f42bf8f1d845b22d3e8ee8f9e7ef6f1181dd9e7210ea091ea3cc05a913013a488ecc2efa2a4
6
+ metadata.gz: 1e5df249ca6c12c2523615ed9f5eb2a6105961eeba64427e3040b0ebf203994f3c9c0eecfd2123704a7dad4fed624122491bf1f049a13a3806cc4ec8848a209e
7
+ data.tar.gz: 32ae4f1ee90a470735707c86bda648e810ff7d4cce10253ad02c54924b6b45845f8b15da35cc6c65cf6b5e79d469bd80a26db52e958a4f77c6a23357ab2e3492
@@ -1,4 +1,7 @@
1
- <% @title = "#{@entry.type} #{@entry.name}" %>
1
+ <%
2
+ @title = "#{@entry.type} #{@entry.name}"
3
+ @description = @entry.description
4
+ %>
2
5
  <div id="main">
3
6
 
4
7
  <p>
@@ -1,4 +1,7 @@
1
- <% @title = _('Class Index') %>
1
+ <%
2
+ @title = _('Class Index')
3
+ @description = _('Class Index')
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <%= _('All Classes') %>
@@ -1,4 +1,7 @@
1
- <% @title = @entry.title %>
1
+ <%
2
+ @title = @entry.title
3
+ @description = @entry.description
4
+ %>
2
5
  <div id="main">
3
6
  <p>
4
7
  <% if @entry.name == 'index' %>
@@ -2,12 +2,14 @@
2
2
  <html lang="ja-JP">
3
3
  <head>
4
4
  <%= google_tag_manager %>
5
+ <%= meta_robots %>
5
6
  <meta http-equiv="Content-Type" content="text/html; charset=<%=h charset() %>">
6
7
  <meta http-equiv="Content-Language" content="ja-JP">
7
8
  <link rel="stylesheet" type="text/css" href="<%=h css_url() %>">
8
9
  <script type="text/javascript" src="<%=h js_url() %>"></script>
9
10
  <link rel="icon" type="image/png" href="<%=h favicon_url() %>">
10
11
  <title><%=h @title %> (Ruby <%=h ruby_version %>)</title>
12
+ <meta name="description" content="<%=h @description %>">
11
13
  </head>
12
14
  <body>
13
15
  <%= yield %>
@@ -1,4 +1,7 @@
1
- <% @title = "library #{@entry.name}" %>
1
+ <%
2
+ @title = "library #{@entry.name}"
3
+ @description = @entry.description
4
+ %>
2
5
  <div id="main">
3
6
 
4
7
  <p>
@@ -1,4 +1,7 @@
1
- <% @title = _('Library Index') %>
1
+ <%
2
+ @title = _('Library Index')
3
+ @description = _('Library Index')
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <%= _("All Libraries") %>
@@ -1,7 +1,8 @@
1
1
  <%
2
2
  entry = @entries.sort.first
3
+ @title = "#{entry.type_label} #{entry.label}"
4
+ @description = entry.description
3
5
  %>
4
- <% @title = "#{entry.type_label} #{entry.label}" %>
5
6
  <p>
6
7
  <%= manual_home_link() %>
7
8
  &gt; <a href="<%= library_index_url() %>"><%= _('All Libraries') %></a>
@@ -1,4 +1,7 @@
1
- <% @title = "#{@entry.type} #{@entry.name}" %>
1
+ <%
2
+ @title = "#{@entry.type} #{@entry.name}"
3
+ @description = @entry.description
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <a href="<%= library_index_url() %>"><%= _('All Libraries') %></a>
@@ -1,4 +1,7 @@
1
- <% @title = _('Class Index') %>
1
+ <%
2
+ @title = _('Class Index')
3
+ @description = _('Class Index')
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <%= _('All Classes') %>
@@ -1,4 +1,7 @@
1
- <% @title = @entry.title %>
1
+ <%
2
+ @title = @entry.title
3
+ @description = @entry.description
4
+ %>
2
5
  <p>
3
6
  <% if @entry.name == 'index' %>
4
7
  <%= _('Ruby %s Reference Manual', ruby_version()) %>
@@ -1,6 +1,7 @@
1
1
  <%
2
2
  entry = @entry
3
3
  @title = "#{entry.type_label} #{entry.label}"
4
+ @description = @entry.description
4
5
  %>
5
6
  <p>
6
7
  <%= manual_home_link() %>
@@ -1,4 +1,7 @@
1
- <% @title = _('Function Index') %>
1
+ <%
2
+ @title = _('Function Index')
3
+ @description = _('Function Index')
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <%= _('All Functions') %>
@@ -2,14 +2,17 @@
2
2
  <html lang="ja-JP">
3
3
  <head>
4
4
  <%= google_tag_manager %>
5
+ <%= meta_robots %>
5
6
  <meta http-equiv="Content-Type" content="text/html; charset=<%=h charset() %>">
6
7
  <meta http-equiv="Content-Language" content="ja-JP">
7
8
  <link rel="stylesheet" type="text/css" href="<%=h css_url() %>">
9
+ <link rel="stylesheet" type="text/css" href="<%=h custom_css_url("syntax-highlight.css") %>">
8
10
  <link rel="icon" type="image/png" href="<%=h favicon_url() %>">
9
11
  <% if @conf[:canonical_base_url] %>
10
12
  <link rel="canonical" href="<%= canonical_url() %>">
11
13
  <% end %>
12
14
  <title><%=h @title %> (Ruby <%=h ruby_version %>)</title>
15
+ <meta name="description" content="<%=h @description %>">
13
16
  </head>
14
17
  <body>
15
18
  <%= yield %>
@@ -1,4 +1,7 @@
1
- <% @title = "library #{@entry.name}" %>
1
+ <%
2
+ @title = "library #{@entry.name}"
3
+ @description = @entry.description
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <a href="<%= library_index_url() %>"><%= _('All Libraries') %></a>
@@ -1,4 +1,7 @@
1
- <% @title = _('Library Index') %>
1
+ <%
2
+ @title = _('Library Index')
3
+ @description = _('Library Index')
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <%= _("All Libraries") %>
@@ -1,6 +1,7 @@
1
1
  <%
2
2
  entry = @entries.sort.first
3
3
  @title = "#{entry.type_label} #{entry.label}"
4
+ @description = entry.description
4
5
  %>
5
6
  <p>
6
7
  <%= manual_home_link() %>
@@ -1,4 +1,7 @@
1
- <% @title = "#{@entry.type} #{@entry.name}" %>
1
+ <%
2
+ @title = "#{@entry.type} #{@entry.name}"
3
+ @description = @entry.description
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <a href="<%= library_index_url() %>"><%= _('All Libraries') %></a>
@@ -1,4 +1,7 @@
1
- <% @title = _('Class Index') %>
1
+ <%
2
+ @title = _('Class Index')
3
+ @description = _('Class Index')
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <%= _('All Classes') %>
@@ -1,4 +1,7 @@
1
- <% @title = @entry.title %>
1
+ <%
2
+ @title = @entry.title
3
+ @description = @entry.description
4
+ %>
2
5
  <p>
3
6
  <% if @entry.name == 'index' %>
4
7
  <%= _('Ruby %s Reference Manual', ruby_version()) %>
@@ -1,4 +1,7 @@
1
- <% @title = "#{@entry.type_label} #{@entry.label}" %>
1
+ <%
2
+ @title = "#{@entry.type_label} #{@entry.label}"
3
+ @description = @entry.description
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <a href="<%= function_index_url() %>"><%= _('All Functions') %></a>
@@ -2,11 +2,14 @@
2
2
  <html lang="ja-JP">
3
3
  <head>
4
4
  <%= google_tag_manager %>
5
+ <%= meta_robots %>
5
6
  <meta http-equiv="Content-Type" content="text/html; charset=<%=h charset() %>">
6
7
  <meta http-equiv="Content-Language" content="ja-JP">
7
8
  <link rel="stylesheet" type="text/css" href="<%=h css_url() %>">
9
+ <link rel="stylesheet" type="text/css" href="<%=h custom_css_url("syntax-highlight.css") %>">
8
10
  <link rel="icon" type="image/png" href="<%=h favicon_url() %>">
9
11
  <title><%=h @title %> (Ruby <%=h ruby_version %>)</title>
12
+ <meta name="description" content="<%=h @description %>">
10
13
  <link rel="search" type="application/opensearchdescription+xml" title="<%= _('Ruby %s Reference Manual', ruby_version()) %>" href="<%=h opensearchdescription_url() %>">
11
14
  </head>
12
15
  <body>
@@ -1,4 +1,7 @@
1
- <% @title = "library #{@entry.name}" %>
1
+ <%
2
+ @title = "library #{@entry.name}"
3
+ @description = @entry.description
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <a href="<%= library_index_url() %>"><%= _('All Libraries') %></a>
@@ -1,4 +1,7 @@
1
- <% @title = _('Library Index') %>
1
+ <%
2
+ @title = _('Library Index')
3
+ @description = _('Library Index')
4
+ %>
2
5
  <p>
3
6
  <%= manual_home_link() %>
4
7
  &gt; <%= _("All Libraries") %>
@@ -1,6 +1,7 @@
1
1
  <%
2
2
  entry = @entries.sort.first
3
3
  @title = "#{entry.type_label} #{entry.label}"
4
+ @description = entry.description
4
5
  %>
5
6
  <p>
6
7
  <%= manual_home_link() %>
@@ -392,6 +392,10 @@ module BitClust
392
392
  .reject {|spec| spec.klass == cname }.uniq
393
393
  end
394
394
 
395
+ def description
396
+ source.split(/\n\n+/, 2)[0].strip
397
+ end
398
+
395
399
  def clear_cache
396
400
  @_smap = @_imap = @_cmap = nil
397
401
  end
@@ -79,6 +79,9 @@ module BitClust
79
79
  def libraries
80
80
  @db.libraries
81
81
  end
82
- end
83
82
 
83
+ def description
84
+ source.split(/\n\n/, 2)[0].strip
85
+ end
86
+ end
84
87
  end
@@ -76,6 +76,8 @@ module BitClust
76
76
  "#{private? ? 'static ' : ''}#{base}"
77
77
  end
78
78
 
79
+ def description
80
+ source.split(/\n\n+/, 2)[0].strip
81
+ end
79
82
  end
80
-
81
83
  end
@@ -77,6 +77,10 @@ module BitClust
77
77
  "#<library #{@id}>"
78
78
  end
79
79
 
80
+ def description
81
+ source.split(/\n\n+/, 2)[0]
82
+ end
83
+
80
84
  def check_link(path = [])
81
85
  return if @link_checked
82
86
  if path.include?(name())
@@ -213,7 +217,5 @@ module BitClust
213
217
  @db.dirty_library self
214
218
  end
215
219
  end
216
-
217
- end
218
-
220
+ end
219
221
  end
@@ -202,6 +202,8 @@ module BitClust
202
202
  kind() == :redefined
203
203
  end
204
204
 
205
+ def description
206
+ source.split(/\n\n+/, 3)[1]
207
+ end
205
208
  end
206
-
207
209
  end
@@ -79,9 +79,9 @@ module BitClust
79
79
  when /\A\#@\#/ # preprocessor comment
80
80
  ;
81
81
  when /\A\#@todo/i
82
- @buf.push line.gsub(/\A#/, '') if current_cond
82
+ @buf.push line.gsub(/\A\#/, '') if current_cond.processing?
83
83
  when /\A\#@include\s*\((.*?)\)/
84
- next unless current_cond
84
+ next unless current_cond.processing?
85
85
  begin
86
86
  file = $1.strip
87
87
  basedir = File.dirname(line.location.file)
@@ -93,18 +93,24 @@ module BitClust
93
93
  cond_stmt_begin line, build_cond_by_value(line, 'version >=')
94
94
  when /\A\#@until\b/
95
95
  cond_stmt_begin line, build_cond_by_value(line, 'version <')
96
+ when /\A\#@samplecode\b/
97
+ samplecode_begin(line, samplecode_description_by_value(line))
96
98
  when /\A\#@if\b/
97
99
  cond_stmt_begin line, line.sub(/\A\#@if/, '').strip
98
100
  when /\A\#@else\s*\z/
99
- parse_error "no matching #@if", line if cond_toplevel?
101
+ parse_error "no matching \#@if", line if cond_toplevel?
100
102
  cond_invert
101
103
  when /\A\#@end\s*\z/
102
- parse_error "no matching #@if", line if cond_toplevel?
103
- cond_pop
104
+ if samplecode_processing?
105
+ samplecode_end
106
+ else
107
+ parse_error "no matching \#@if", line if cond_toplevel?
108
+ cond_pop
109
+ end
104
110
  when /\A\#@/
105
111
  parse_error "unknown preprocessor directive", line
106
112
  else
107
- if current_cond
113
+ if current_cond.processing?
108
114
  @buf.push line
109
115
  break
110
116
  end
@@ -139,28 +145,30 @@ module BitClust
139
145
  end
140
146
 
141
147
  def current_cond
142
- @cond_stack.last
148
+ @state_stack.last
143
149
  end
144
150
 
145
151
  def cond_init
146
- @cond_stack = [true]
152
+ @state_stack = [State.new(nil, :toplevel)]
147
153
  end
148
154
 
149
155
  def cond_toplevel?
150
- @cond_stack.size == 1
156
+ @state_stack.size == 1
151
157
  end
152
158
 
153
159
  def cond_push(bool)
154
- @cond_stack.push(@cond_stack.last && bool)
160
+ last = @state_stack.last
161
+ @state_stack.push(State.new(last.current, bool))
155
162
  end
156
163
 
157
164
  def cond_invert
158
- b = @cond_stack.pop
159
- @cond_stack.push(!b && @cond_stack.last)
165
+ b = @state_stack.pop.processing?
166
+ last = @state_stack.last
167
+ @state_stack.push(State.new(last.current, !b))
160
168
  end
161
169
 
162
170
  def cond_pop
163
- @cond_stack.pop
171
+ @state_stack.pop
164
172
  end
165
173
 
166
174
  def eval_cond(str)
@@ -231,12 +239,64 @@ module BitClust
231
239
  end
232
240
  end
233
241
 
242
+ def samplecode_begin(line, description)
243
+ description = description.strip
244
+ samplecode_push(description)
245
+ return unless current_cond.processing?
246
+ @buf.push("//emlist[#{description}][ruby]{\n")
247
+ end
248
+
249
+ def samplecode_end
250
+ samplecode_pop
251
+ return unless current_cond.processing?
252
+ @buf.push("//}\n")
253
+ end
254
+
255
+ def samplecode_push(description)
256
+ last = @state_stack.last
257
+ @state_stack.push(State.new(last.current, :samplecode))
258
+ end
259
+
260
+ def samplecode_pop
261
+ @state_stack.pop
262
+ end
263
+
264
+ def samplecode_processing?
265
+ @state_stack.last.samplecode?
266
+ end
267
+
268
+ def samplecode_description_by_value(line)
269
+ line.sub(/\A\#@samplecode/, "")
270
+ end
271
+
234
272
  def scan_error(msg)
235
273
  raise ScanError, msg
236
274
  end
237
275
 
238
- end
276
+ class State
277
+ attr_reader :current
278
+
279
+ def initialize(previous, current)
280
+ @previous = previous
281
+ @current = current
282
+ end
283
+
284
+ def toplevel?
285
+ @current == :toplevel
286
+ end
239
287
 
288
+ def processing?
289
+ toplevel? ||
290
+ (@current == true && @previous != false) ||
291
+ (@current == :samplecode && @previous == true) ||
292
+ (@current == :samplecode && @previous == :toplevel)
293
+ end
294
+
295
+ def samplecode?
296
+ @current == :samplecode
297
+ end
298
+ end
299
+ end
240
300
 
241
301
  # Used by tools/stattodo.rb
242
302
  class LineCollector < LineFilter