sdoc 0.3.4 → 0.3.5
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.
- data/lib/rdoc/generator/template/rails/_context.rhtml +9 -7
- data/lib/rdoc/generator/template/rails/resources/css/main.css +42 -3
- data/lib/rdoc/generator/template/rails/resources/css/panel.css +2 -2
- data/lib/rdoc/generator/template/rails/resources/js/main.js +1 -5
- data/lib/rdoc/generator/template/sdoc/_context.rhtml +9 -7
- data/lib/rdoc/generator/template/sdoc/resources/css/main.css +41 -2
- data/lib/rdoc/generator/template/sdoc/resources/js/main.js +1 -1
- data/lib/sdoc/generator.rb +73 -2
- data/lib/sdoc/github.rb +1 -1
- data/sdoc.gemspec +1 -1
- metadata +3 -3
@@ -121,7 +121,7 @@
|
|
121
121
|
<div class="sectiontitle"><%= type.capitalize %> <%= visibility.to_s.capitalize %> methods</div>
|
122
122
|
<% methods.each do |method| %>
|
123
123
|
<div class="method">
|
124
|
-
<div class="title" id="<%= method.aref %>">
|
124
|
+
<div class="title method-title" id="<%= method.aref %>">
|
125
125
|
<% if method.call_seq %>
|
126
126
|
<a name="<%= method.aref %>"></a><b><%= method.call_seq.gsub(/->/, '→') %></b>
|
127
127
|
<% else %>
|
@@ -142,24 +142,26 @@
|
|
142
142
|
</div>
|
143
143
|
<% end %>
|
144
144
|
<% if method.token_stream %>
|
145
|
-
<% markup = method.
|
145
|
+
<% markup = method.sdoc_markup_code %>
|
146
146
|
<div class="sourcecode">
|
147
147
|
<p class="source-link">
|
148
148
|
Source: <a href="javascript:toggleSource('<%= method.aref %>_source')" id="l_<%= method.aref %>_source">show</a>
|
149
149
|
<%
|
150
|
-
if options.github
|
151
150
|
if markup =~ /File\s(\S+), line (\d+)/
|
152
151
|
path = $1
|
153
152
|
line = $2.to_i
|
154
153
|
end
|
155
|
-
|
156
|
-
|
154
|
+
%>
|
155
|
+
<%
|
156
|
+
if options.github && path
|
157
|
+
github = github_url(path)
|
158
|
+
if github
|
157
159
|
%>
|
158
160
|
| <a href="<%= "#{github}#L#{line}" %>" target="_blank" class="github_url">on GitHub</a>
|
159
161
|
<% end end %>
|
160
162
|
</p>
|
161
|
-
<div id="<%= method.aref %>_source" class="dyn-source
|
162
|
-
<pre><%=
|
163
|
+
<div id="<%= method.aref %>_source" class="dyn-source">
|
164
|
+
<pre><%= markup %></pre>
|
163
165
|
</div>
|
164
166
|
</div>
|
165
167
|
<% end %>
|
@@ -147,7 +147,7 @@ ol li
|
|
147
147
|
margin-bottom: 0;
|
148
148
|
}
|
149
149
|
|
150
|
-
pre
|
150
|
+
pre
|
151
151
|
{
|
152
152
|
margin-bottom: 1em;
|
153
153
|
}
|
@@ -261,7 +261,7 @@ tt {
|
|
261
261
|
font-size: 1.1em;
|
262
262
|
color:#333;
|
263
263
|
}
|
264
|
-
.method .title {
|
264
|
+
.method .method-title {
|
265
265
|
border-bottom: 1px dotted #666;
|
266
266
|
padding: 0 0 0.15em 0;
|
267
267
|
margin: 0 0 0.5em 0;
|
@@ -284,4 +284,43 @@ tt {
|
|
284
284
|
.method .source-link
|
285
285
|
{
|
286
286
|
font-size: 0.85em;
|
287
|
-
}
|
287
|
+
}
|
288
|
+
|
289
|
+
.ruby-constant {
|
290
|
+
color: teal;
|
291
|
+
}
|
292
|
+
.ruby-keyword {
|
293
|
+
color: #000;
|
294
|
+
font-weight: bold
|
295
|
+
}
|
296
|
+
.ruby-title {
|
297
|
+
color: #900;
|
298
|
+
font-weight: bold;
|
299
|
+
}
|
300
|
+
.ruby-ivar {
|
301
|
+
color: teal;
|
302
|
+
}
|
303
|
+
.ruby-operator {
|
304
|
+
color: #000;
|
305
|
+
font-weight: bold
|
306
|
+
}
|
307
|
+
.ruby-identifier {
|
308
|
+
color: #000;
|
309
|
+
}
|
310
|
+
.ruby-string,
|
311
|
+
.ruby-node {
|
312
|
+
color: #D14;
|
313
|
+
}
|
314
|
+
.ruby-comment {
|
315
|
+
color: #998;
|
316
|
+
font-style: italic;
|
317
|
+
}
|
318
|
+
.ruby-regexp {
|
319
|
+
color: #009926;
|
320
|
+
}
|
321
|
+
.ruby-value {
|
322
|
+
color: #990073;
|
323
|
+
}
|
324
|
+
.ruby-number {
|
325
|
+
color: #40A070;
|
326
|
+
}
|
@@ -51,7 +51,7 @@
|
|
51
51
|
font-size: 12px;
|
52
52
|
line-height: 29px;
|
53
53
|
margin-left: 3px;
|
54
|
-
color: #
|
54
|
+
color: #777;
|
55
55
|
cursor: text;
|
56
56
|
}
|
57
57
|
|
@@ -127,7 +127,7 @@
|
|
127
127
|
.panel .result ul li h1 i,
|
128
128
|
.panel .result ul li p.snippet
|
129
129
|
{
|
130
|
-
color: #
|
130
|
+
color: #777;
|
131
131
|
}
|
132
132
|
|
133
133
|
.panel .result ul li b
|
@@ -1,12 +1,8 @@
|
|
1
|
-
function toggleSource(
|
1
|
+
function toggleSource(id)
|
2
2
|
{
|
3
3
|
var src = $('#' + id).toggle();
|
4
4
|
var isVisible = src.is(':visible');
|
5
5
|
$('#l_' + id).html(isVisible ? 'hide' : 'show');
|
6
|
-
if (!src.data('syntax-higlighted')) {
|
7
|
-
src.data('syntax-higlighted', 1);
|
8
|
-
hljs.highlightBlock(src[0]);
|
9
|
-
}
|
10
6
|
}
|
11
7
|
|
12
8
|
window.highlight = function(url) {
|
@@ -121,7 +121,7 @@
|
|
121
121
|
<div class="sectiontitle"><%= type.capitalize %> <%= visibility.to_s.capitalize %> methods</div>
|
122
122
|
<% methods.each do |method| %>
|
123
123
|
<div class="method">
|
124
|
-
<div class="title" id="<%= method.aref %>">
|
124
|
+
<div class="title method-title" id="<%= method.aref %>">
|
125
125
|
<% if method.call_seq %>
|
126
126
|
<a name="<%= method.aref %>"></a><b><%= method.call_seq.gsub(/->/, '→') %></b>
|
127
127
|
<% else %>
|
@@ -142,24 +142,26 @@
|
|
142
142
|
</div>
|
143
143
|
<% end %>
|
144
144
|
<% if method.token_stream %>
|
145
|
-
<% markup = method.
|
145
|
+
<% markup = method.sdoc_markup_code %>
|
146
146
|
<div class="sourcecode">
|
147
147
|
<p class="source-link">
|
148
148
|
Source: <a href="javascript:toggleSource('<%= method.aref %>_source')" id="l_<%= method.aref %>_source">show</a>
|
149
149
|
<%
|
150
|
-
if options.github
|
151
150
|
if markup =~ /File\s(\S+), line (\d+)/
|
152
151
|
path = $1
|
153
152
|
line = $2.to_i
|
154
153
|
end
|
155
|
-
|
156
|
-
|
154
|
+
%>
|
155
|
+
<%
|
156
|
+
if options.github && path
|
157
|
+
github = github_url(path)
|
158
|
+
if github
|
157
159
|
%>
|
158
160
|
| <a href="<%= "#{github}#L#{line}" %>" target="_blank" class="github_url">on GitHub</a>
|
159
161
|
<% end end %>
|
160
162
|
</p>
|
161
|
-
<div id="<%= method.aref %>_source" class="dyn-source
|
162
|
-
<pre><%=
|
163
|
+
<div id="<%= method.aref %>_source" class="dyn-source">
|
164
|
+
<pre><%= markup %></pre>
|
163
165
|
</div>
|
164
166
|
</div>
|
165
167
|
<% end %>
|
@@ -252,7 +252,7 @@ tt {
|
|
252
252
|
font-size: 1.1em;
|
253
253
|
color:#333;
|
254
254
|
}
|
255
|
-
.method .title {
|
255
|
+
.method .method-title {
|
256
256
|
border-bottom: 1px dotted #666;
|
257
257
|
padding: 0 0 0.15em 0;
|
258
258
|
margin: 0 0 0.5em 0;
|
@@ -275,4 +275,43 @@ tt {
|
|
275
275
|
.method .source-link
|
276
276
|
{
|
277
277
|
font-size: 0.85em;
|
278
|
-
}
|
278
|
+
}
|
279
|
+
|
280
|
+
.ruby-constant {
|
281
|
+
color: teal;
|
282
|
+
}
|
283
|
+
.ruby-keyword {
|
284
|
+
color: #000;
|
285
|
+
font-weight: bold
|
286
|
+
}
|
287
|
+
.ruby-title {
|
288
|
+
color: #900;
|
289
|
+
font-weight: bold;
|
290
|
+
}
|
291
|
+
.ruby-ivar {
|
292
|
+
color: teal;
|
293
|
+
}
|
294
|
+
.ruby-operator {
|
295
|
+
color: #000;
|
296
|
+
font-weight: bold
|
297
|
+
}
|
298
|
+
.ruby-identifier {
|
299
|
+
color: #000;
|
300
|
+
}
|
301
|
+
.ruby-string,
|
302
|
+
.ruby-node {
|
303
|
+
color: #D14;
|
304
|
+
}
|
305
|
+
.ruby-comment {
|
306
|
+
color: #998;
|
307
|
+
font-style: italic;
|
308
|
+
}
|
309
|
+
.ruby-regexp {
|
310
|
+
color: #009926;
|
311
|
+
}
|
312
|
+
.ruby-value {
|
313
|
+
color: #990073;
|
314
|
+
}
|
315
|
+
.ruby-number {
|
316
|
+
color: #40A070;
|
317
|
+
}
|
data/lib/sdoc/generator.rb
CHANGED
@@ -31,6 +31,77 @@ class RDoc::Options
|
|
31
31
|
attr_accessor :se_index
|
32
32
|
end
|
33
33
|
|
34
|
+
class RDoc::AnyMethod
|
35
|
+
|
36
|
+
TITLE_AFTER = %w(def class module)
|
37
|
+
|
38
|
+
##
|
39
|
+
# Turns the method's token stream into HTML.
|
40
|
+
#
|
41
|
+
# Prepends line numbers if +add_line_numbers+ is true.
|
42
|
+
|
43
|
+
def sdoc_markup_code
|
44
|
+
return '' unless @token_stream
|
45
|
+
|
46
|
+
src = ""
|
47
|
+
starting_title = false
|
48
|
+
|
49
|
+
@token_stream.each do |t|
|
50
|
+
next unless t
|
51
|
+
|
52
|
+
style = case t
|
53
|
+
when RDoc::RubyToken::TkFLOAT then 'ruby-number'
|
54
|
+
when RDoc::RubyToken::TkINTEGER then 'ruby-number'
|
55
|
+
when RDoc::RubyToken::TkCONSTANT then 'ruby-constant'
|
56
|
+
when RDoc::RubyToken::TkKW then 'ruby-keyword'
|
57
|
+
when RDoc::RubyToken::TkIVAR then 'ruby-ivar'
|
58
|
+
when RDoc::RubyToken::TkOp then 'ruby-operator'
|
59
|
+
when RDoc::RubyToken::TkId then 'ruby-identifier'
|
60
|
+
when RDoc::RubyToken::TkNode then 'ruby-node'
|
61
|
+
when RDoc::RubyToken::TkCOMMENT then 'ruby-comment'
|
62
|
+
when RDoc::RubyToken::TkREGEXP then 'ruby-regexp'
|
63
|
+
when RDoc::RubyToken::TkSTRING then 'ruby-string'
|
64
|
+
when RDoc::RubyToken::TkVal then 'ruby-value'
|
65
|
+
end
|
66
|
+
|
67
|
+
if RDoc::RubyToken::TkId === t && starting_title
|
68
|
+
starting_title = false
|
69
|
+
style = 'ruby-keyword ruby-title'
|
70
|
+
end
|
71
|
+
|
72
|
+
if RDoc::RubyToken::TkKW === t && TITLE_AFTER.include?(t.text)
|
73
|
+
starting_title = true
|
74
|
+
end
|
75
|
+
|
76
|
+
text = CGI.escapeHTML t.text
|
77
|
+
|
78
|
+
if style then
|
79
|
+
src << "<span class=\"#{style}\">#{text}</span>"
|
80
|
+
else
|
81
|
+
src << text
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# dedent the source
|
86
|
+
indent = src.length
|
87
|
+
lines = src.lines.to_a
|
88
|
+
lines.shift if src =~ /\A.*#\ *File/i # remove '# File' comment
|
89
|
+
lines.each do |line|
|
90
|
+
if line =~ /^ *(?=\S)/
|
91
|
+
n = $&.length
|
92
|
+
indent = n if n < indent
|
93
|
+
break if n == 0
|
94
|
+
end
|
95
|
+
end
|
96
|
+
src.gsub!(/^#{' ' * indent}/, '') if indent > 0
|
97
|
+
|
98
|
+
add_line_numbers(src) if self.class.add_line_numbers
|
99
|
+
|
100
|
+
src
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
34
105
|
class RDoc::Generator::SDoc
|
35
106
|
RDoc::RDoc.add_generator self
|
36
107
|
|
@@ -85,7 +156,7 @@ class RDoc::Generator::SDoc
|
|
85
156
|
options.se_index = false
|
86
157
|
end
|
87
158
|
opt.separator nil
|
88
|
-
|
159
|
+
|
89
160
|
end
|
90
161
|
|
91
162
|
def initialize(options)
|
@@ -94,7 +165,7 @@ class RDoc::Generator::SDoc
|
|
94
165
|
@options.diagram = false
|
95
166
|
end
|
96
167
|
@github_url_cache = {}
|
97
|
-
|
168
|
+
|
98
169
|
@template_dir = Pathname.new(options.template_dir)
|
99
170
|
@basedir = Pathname.pwd.expand_path
|
100
171
|
end
|
data/lib/sdoc/github.rb
CHANGED
@@ -40,7 +40,7 @@ module SDoc::GitHub
|
|
40
40
|
`git config --get remote.origin.url`
|
41
41
|
end
|
42
42
|
m = s.match(%r{github.com[/:](.*)\.git$})
|
43
|
-
m ? "
|
43
|
+
m ? "https://github.com/#{m[1]}/blob/" : false
|
44
44
|
end
|
45
45
|
|
46
46
|
def path_relative_to_repository(path)
|
data/sdoc.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Vladimir Kolesnikov
|