sdoc_local_editor 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.gitignore +3 -0
  2. data/.rake_tasks~ +20 -0
  3. data/LICENSE +110 -0
  4. data/README.rdoc +37 -0
  5. data/Rakefile +12 -0
  6. data/bin/sdoc_local_editor +27 -0
  7. data/bin/sdoc_local_editor_merge +24 -0
  8. data/lib/rdoc/discover.rb +5 -0
  9. data/lib/rdoc/generator/template/merge/index.rhtml +14 -0
  10. data/lib/rdoc/generator/template/rails/_context.rhtml +210 -0
  11. data/lib/rdoc/generator/template/rails/_head.rhtml +7 -0
  12. data/lib/rdoc/generator/template/rails/class.rhtml +39 -0
  13. data/lib/rdoc/generator/template/rails/file.rhtml +37 -0
  14. data/lib/rdoc/generator/template/rails/index.rhtml +13 -0
  15. data/lib/rdoc/generator/template/rails/resources/apple-touch-icon.png +0 -0
  16. data/lib/rdoc/generator/template/rails/resources/css/github.css +129 -0
  17. data/lib/rdoc/generator/template/rails/resources/css/main.css +346 -0
  18. data/lib/rdoc/generator/template/rails/resources/css/panel.css +389 -0
  19. data/lib/rdoc/generator/template/rails/resources/css/reset.css +48 -0
  20. data/lib/rdoc/generator/template/rails/resources/favicon.ico +0 -0
  21. data/lib/rdoc/generator/template/rails/resources/i/arrows.png +0 -0
  22. data/lib/rdoc/generator/template/rails/resources/i/results_bg.png +0 -0
  23. data/lib/rdoc/generator/template/rails/resources/i/tree_bg.png +0 -0
  24. data/lib/rdoc/generator/template/rails/resources/js/highlight.pack.js +1 -0
  25. data/lib/rdoc/generator/template/rails/resources/js/jquery-1.3.2.min.js +19 -0
  26. data/lib/rdoc/generator/template/rails/resources/js/jquery-effect.js +593 -0
  27. data/lib/rdoc/generator/template/rails/resources/js/main.js +20 -0
  28. data/lib/rdoc/generator/template/rails/resources/js/searchdoc.js +441 -0
  29. data/lib/rdoc/generator/template/rails/resources/panel/index.html +73 -0
  30. data/lib/rdoc/generator/template/rails/se_index.rhtml +8 -0
  31. data/lib/rdoc/generator/template/sdoc/_context.rhtml +221 -0
  32. data/lib/rdoc/generator/template/sdoc/_head.rhtml +7 -0
  33. data/lib/rdoc/generator/template/sdoc/class.rhtml +39 -0
  34. data/lib/rdoc/generator/template/sdoc/file.rhtml +29 -0
  35. data/lib/rdoc/generator/template/sdoc/index.rhtml +13 -0
  36. data/lib/rdoc/generator/template/sdoc/resources/apple-touch-icon.png +0 -0
  37. data/lib/rdoc/generator/template/sdoc/resources/css/github.css +129 -0
  38. data/lib/rdoc/generator/template/sdoc/resources/css/main.css +333 -0
  39. data/lib/rdoc/generator/template/sdoc/resources/css/panel.css +384 -0
  40. data/lib/rdoc/generator/template/sdoc/resources/css/reset.css +48 -0
  41. data/lib/rdoc/generator/template/sdoc/resources/favicon.ico +0 -0
  42. data/lib/rdoc/generator/template/sdoc/resources/i/arrows.png +0 -0
  43. data/lib/rdoc/generator/template/sdoc/resources/i/results_bg.png +0 -0
  44. data/lib/rdoc/generator/template/sdoc/resources/i/tree_bg.png +0 -0
  45. data/lib/rdoc/generator/template/sdoc/resources/js/highlight.pack.js +1 -0
  46. data/lib/rdoc/generator/template/sdoc/resources/js/jquery-1.3.2.min.js +19 -0
  47. data/lib/rdoc/generator/template/sdoc/resources/js/jquery-effect.js +593 -0
  48. data/lib/rdoc/generator/template/sdoc/resources/js/main.js +24 -0
  49. data/lib/rdoc/generator/template/sdoc/resources/js/searchdoc.js +442 -0
  50. data/lib/rdoc/generator/template/sdoc/resources/panel/index.html +73 -0
  51. data/lib/rdoc/generator/template/sdoc/se_index.rhtml +8 -0
  52. data/lib/sdoc_local_editor.rb +9 -0
  53. data/lib/sdoc_local_editor/generator.rb +418 -0
  54. data/lib/sdoc_local_editor/github.rb +61 -0
  55. data/lib/sdoc_local_editor/helpers.rb +26 -0
  56. data/lib/sdoc_local_editor/merge.rb +223 -0
  57. data/lib/sdoc_local_editor/templatable.rb +60 -0
  58. data/sdoc_local_editor.gemspec +31 -0
  59. metadata +139 -0
@@ -0,0 +1,73 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
6
+ <head>
7
+ <title>search index</title>
8
+ <link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" charset="utf-8" />
9
+ <link rel="stylesheet" href="../css/panel.css" type="text/css" media="screen" charset="utf-8" />
10
+ <script src="../js/search_index.js" type="text/javascript" charset="utf-8"></script>
11
+ <script src="../js/searcher.js" type="text/javascript" charset="utf-8"></script>
12
+ <script src="tree.js" type="text/javascript" charset="utf-8"></script>
13
+ <script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="../js/searchdoc.js" type="text/javascript" charset="utf-8"></script>
15
+ <script type="text/javascript" charset="utf-8">
16
+ function placeholder() {
17
+ if ($('<input type="text">')[0].placeholder !== undefined) return;
18
+
19
+ $('#search-label').click(function() {
20
+ $('#search').focus();
21
+ $('#search-label').hide();
22
+ });
23
+
24
+ $('#search').focus(function() {
25
+ $('#search-label').hide();
26
+ });
27
+ $('#search').blur(function() {
28
+ this.value == '' && $('#search-label').show()
29
+ });
30
+
31
+ $('#search')[0].value == '' && $('#search-label').show();
32
+ }
33
+ $(function() {
34
+ placeholder();
35
+ $('#links').hide();
36
+ var panel = new Searchdoc.Panel($('#panel'), search_data, tree, top.frames[1]);
37
+ $('#search').focus();
38
+
39
+ var s = window.parent.location.search.match(/\?q=([^&]+)/);
40
+ if (s) {
41
+ s = decodeURIComponent(s[1]).replace(/\+/g, ' ');
42
+ if (s.length > 0)
43
+ {
44
+ $('#search').val(s);
45
+ panel.search(s, true);
46
+ }
47
+ }
48
+ })
49
+ </script>
50
+ </head>
51
+ <body>
52
+ <div class="panel panel_tree" id="panel">
53
+ <div class="header">
54
+ <div>
55
+ <label for="search" id="search-label" style="display: none">Search</label>
56
+ <table>
57
+ <tr><td>
58
+ <input type="Search" placeholder="Search" autosave="searchdoc" results="10" id="search" autocomplete="off"/>
59
+ </td></tr>
60
+ </table></div>
61
+ </div>
62
+ <div class="tree">
63
+ <ul>
64
+ </ul>
65
+ </div>
66
+ <div class="result">
67
+ <ul>
68
+ </ul>
69
+ </div>
70
+ </div>
71
+ <a href="links.html" id="links">index</a>
72
+ </body>
73
+ </html>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>File index</head>
3
+ <body>
4
+ <% @files.each do |file| %>
5
+ <a href="../<%= file.path %>"><%= file.relative_name %></a>
6
+ <% end %>
7
+ </body>
8
+ </html>
@@ -0,0 +1,221 @@
1
+ <div id="content">
2
+ <% unless (description = context.description).empty? %>
3
+ <div class="description">
4
+ <%= description %>
5
+ </div>
6
+ <% end %>
7
+
8
+
9
+ <% unless context.requires.empty? %>
10
+ <!-- File only: requires -->
11
+ <div class="sectiontitle">Required Files</div>
12
+ <ul>
13
+ <% context.requires.each do |req| %>
14
+ <li><%= h req.name %></li>
15
+ <% end %>
16
+ </ul>
17
+ <% end %>
18
+
19
+
20
+ <% sections = context.sections.select { |s| s.title }.sort_by{ |s| s.title.to_s } %>
21
+ <% unless sections.empty? then %>
22
+ <!-- Sections -->
23
+ <div class="sectiontitle">Sections</div>
24
+ <ul>
25
+ <% sections.each do |section| %>
26
+ <li><a href="#<%= section.aref %>"><%= h section.title %></a></li>
27
+ <% end %>
28
+ </ul>
29
+ <% end %>
30
+
31
+
32
+ <% unless context.classes_and_modules.empty? %>
33
+ <!-- Namespace -->
34
+ <div class="sectiontitle">Namespace</div>
35
+ <ul>
36
+ <% (context.modules.sort + context.classes.sort).each do |mod| %>
37
+ <li>
38
+ <span class="type"><%= mod.type.upcase %></span>
39
+ <a href="<%= context.aref_to mod.path %>"><%= mod.full_name %></a>
40
+ </li>
41
+ <% end %>
42
+ </ul>
43
+ <% end %>
44
+
45
+
46
+ <% unless context.method_list.empty? %>
47
+ <!-- Method ref -->
48
+ <div class="sectiontitle">Methods</div>
49
+ <dl class="methods">
50
+ <% each_letter_group(context.method_list) do |group| %>
51
+ <dt><%= group[:name] %></dt>
52
+ <dd>
53
+ <ul>
54
+ <% group[:methods].each_with_index do |method, i| %>
55
+ <%
56
+ comma = group[:methods].size == i+1 ? '' : ','
57
+ %>
58
+ <li>
59
+ <a href="#<%= method.aref %>"><%= h method.name %></a><%= comma %>
60
+ </li>
61
+ <% end %>
62
+ </ul>
63
+ </dd>
64
+ <% end %>
65
+ </dl>
66
+ <% end %>
67
+
68
+ <% unless context.includes.empty? %>
69
+ <!-- Includes -->
70
+ <div class="sectiontitle">Included Modules</div>
71
+ <ul>
72
+ <% context.includes.each do |inc| %>
73
+ <li>
74
+ <% unless String === inc.module %>
75
+ <a href="<%= context.aref_to inc.module.path %>">
76
+ <%= h inc.module.full_name %>
77
+ </a>
78
+ <% else %>
79
+ <%= h inc.name %>
80
+ <% end %>
81
+ </li>
82
+ <% end %>
83
+ </ul>
84
+ <% end %>
85
+
86
+
87
+
88
+ <% context.each_section do |section, constants, attributes| %>
89
+
90
+ <% if section.title then %>
91
+ <div class="contenttitle" id="<%= h section.aref %>">
92
+ <%= h section.title %>
93
+ </div>
94
+ <% end %>
95
+
96
+ <% if section.comment then %>
97
+ <div class="description">
98
+ <%= section.description %>
99
+ </div>
100
+ <% end %>
101
+
102
+ <% unless constants.empty? %>
103
+ <!-- Section constants -->
104
+ <div class="sectiontitle">Constants</div>
105
+ <table border='0' cellpadding='5'>
106
+ <% context.each_constant do |const| %>
107
+ <tr valign='top'>
108
+ <td class="attr-name"><%= h const.name %></td>
109
+ <td>=</td>
110
+ <td class="attr-value"><%= h const.value %></td>
111
+ </tr>
112
+ <% if const.comment %>
113
+ <tr valign='top'>
114
+ <td>&nbsp;</td>
115
+ <td colspan="2" class="attr-desc"><%= const.description.strip %></td>
116
+ </tr>
117
+ <% end %>
118
+ <% end %>
119
+ </table>
120
+ <% end %>
121
+
122
+
123
+ <% unless attributes.empty? %>
124
+ <!-- Section attributes -->
125
+ <div class="sectiontitle">Attributes</div>
126
+ <table border='0' cellpadding='5'>
127
+ <% attributes.each do |attrib| %>
128
+ <tr valign='top'>
129
+ <td class='attr-rw'>
130
+ [<%= attrib.rw %>]
131
+ </td>
132
+ <td class='attr-name'><%= h attrib.name %></td>
133
+ <td class='attr-desc'><%= attrib.description.strip %></td>
134
+ </tr>
135
+ <% end %>
136
+ </table>
137
+ <% end %>
138
+
139
+
140
+ <!-- Methods -->
141
+ <%
142
+ context.methods_by_type(section).each do |type, visibilities|
143
+ next if visibilities.empty?
144
+
145
+ visibilities.each do |visibility, methods|
146
+ next if methods.empty?
147
+ %>
148
+ <div class="sectiontitle"><%= type.capitalize %> <%= visibility.to_s.capitalize %> methods</div>
149
+ <% methods.each do |method| %>
150
+ <div class="method">
151
+ <div class="title method-title" id="<%= method.aref %>">
152
+ <% if method.call_seq %>
153
+ <b><%= method.call_seq.gsub(/->/, '&rarr;') %></b>
154
+ <% else %>
155
+ <b><%= h method.name %></b><%= h method.params %>
156
+ <% end %>
157
+ <a href="<%= "#{rel_prefix}/#{context.path}##{method.aref}"%>" name="<%= method.aref %>" class="permalink">Link</a>
158
+ </div>
159
+
160
+ <% if method.comment %>
161
+ <div class="description">
162
+ <%= method.description.strip %>
163
+ </div>
164
+ <% end %>
165
+
166
+ <% unless method.aliases.empty? %>
167
+ <div class="aka">
168
+ Also aliased as: <%= method.aliases.map do |aka|
169
+ if aka.parent then # HACK lib/rexml/encodings
170
+ %{<a href="#{context.aref_to aka.path}">#{h aka.name}</a>}
171
+ else
172
+ h aka.name
173
+ end
174
+ end.join ", " %>
175
+ </div>
176
+ <% end %>
177
+
178
+ <% if method.token_stream %>
179
+ <% markup = method.sdoc_markup_code %>
180
+ <div class="sourcecode">
181
+ <%
182
+ # generate links
183
+ if markup =~ /File\s(\S+), line (\d+)/
184
+ path = $1
185
+ line = $2.to_i
186
+
187
+ github = if options.github
188
+ path && github_url(path)
189
+ else
190
+ false
191
+ end
192
+
193
+ local_editor = if options.local_editor
194
+ # SOURCE_DIR is set at the beginning of lib/sdoc_local_editor.rb
195
+ path && "javascript:$.post('/open_editor/?file=#{SOURCE_DIR}/#{path}&line=#{line}')"
196
+ else
197
+ false
198
+ end
199
+ end
200
+ %>
201
+ <p class="source-link">
202
+ Source:
203
+ <a href="javascript:toggleSource('<%= method.aref %>_source')" id="l_<%= method.aref %>_source">show</a>
204
+ <% if github %>
205
+ | <a href="<%= "#{github}#L#{line}" %>" target="_blank" class="github_url">on GitHub</a>
206
+ <% end %>
207
+ <% if local_editor %>
208
+ | <a href="<%= local_editor %>" target="_blank" class="editor_url">open in <%= ENV['EDITOR_NAME'] %></a>
209
+ <% end %>
210
+ </p>
211
+ <div id="<%= method.aref %>_source" class="dyn-source">
212
+ <pre><%= markup %></pre>
213
+ </div>
214
+ </div>
215
+ <% end %>
216
+ </div>
217
+ <% end #methods.each %>
218
+ <% end #visibilities.each %>
219
+ <% end #context.methods_by_type %>
220
+ <% end #context.each_section %>
221
+ </div>
@@ -0,0 +1,7 @@
1
+ <link rel="stylesheet" href="<%= "#{rel_prefix}/css/reset.css" %>" type="text/css" media="screen" />
2
+ <link rel="stylesheet" href="<%= "#{rel_prefix}/css/main.css" %>" type="text/css" media="screen" />
3
+ <link rel="stylesheet" href="<%= "#{rel_prefix}/css/github.css" %>" type="text/css" media="screen" />
4
+ <script src="<%= "#{rel_prefix}/js/jquery-1.3.2.min.js" %>" type="text/javascript" charset="utf-8"></script>
5
+ <script src="<%= "#{rel_prefix}/js/jquery-effect.js" %>" type="text/javascript" charset="utf-8"></script>
6
+ <script src="<%= "#{rel_prefix}/js/main.js" %>" type="text/javascript" charset="utf-8"></script>
7
+ <script src="<%= "#{rel_prefix}/js/highlight.pack.js" %>" type="text/javascript" charset="utf-8"></script>
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <title><%= h klass.full_name %></title>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=<%= @options.charset %>" />
8
+ <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix} %>
9
+ </head>
10
+
11
+ <body>
12
+ <div class="banner">
13
+ <% if ENV['HORO_PROJECT_NAME'] %>
14
+ <span><%= ERB::Util.html_escape(ENV['HORO_PROJECT_NAME']) %> <%= ERB::Util.html_escape(ENV['HORO_PROJECT_VERSION']) %></span><br />
15
+ <% end %>
16
+ <h1>
17
+ <span class="type"><%= klass.module? ? 'Module' : 'Class' %></span>
18
+ <%= h klass.full_name %>
19
+ <% if klass.type == 'class' %>
20
+ <span class="parent">&lt;
21
+ <% if String === klass.superclass %>
22
+ <%= klass.superclass %>
23
+ <% elsif !klass.superclass.nil? %>
24
+ <a href="<%= klass.aref_to klass.superclass.path %>"><%= h klass.superclass.full_name %></a>
25
+ <% end %>
26
+ </span>
27
+ <% end %>
28
+ </h1>
29
+ <ul class="files">
30
+ <% klass.in_files.each do |file| %>
31
+ <li><a href="<%= "#{rel_prefix}/#{h file.path}" %>"><%= h file.absolute_name %></a></li>
32
+ <% end %>
33
+ </ul>
34
+ </div>
35
+ <div id="bodyContent">
36
+ <%= include_template '_context.rhtml', {:context => klass, :rel_prefix => rel_prefix} %>
37
+ </div>
38
+ </body>
39
+ </html>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <title><%= h file.name %></title>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=<%= @options.charset %>" />
8
+ <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix} %>
9
+ </head>
10
+
11
+ <body>
12
+ <div class="banner">
13
+ <% if ENV['HORO_PROJECT_NAME'] %>
14
+ <span><%= ERB::Util.html_escape(ENV['HORO_PROJECT_NAME']) %> <%= ERB::Util.html_escape(ENV['HORO_PROJECT_VERSION']) %></span><br />
15
+ <% end %>
16
+ <h1>
17
+ <%= h file.name %>
18
+ </h1>
19
+ <ul class="files">
20
+ <li><%= h file.relative_name %></li>
21
+ <li>Last modified: <%= file.file_stat.mtime %></li>
22
+ </ul>
23
+ </div>
24
+
25
+ <div id="bodyContent">
26
+ <%= include_template '_context.rhtml', {:context => file, :rel_prefix => rel_prefix} %>
27
+ </div>
28
+ </body>
29
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html
2
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=<%= @options.charset %>" />
7
+ <title><%= @options.title %></title>
8
+ </head>
9
+ <frameset cols="300,*" frameborder="1" border="1" bordercolor="#999999" framespacing="1">
10
+ <frame src="panel/index.html" title="Search" name="panel" />
11
+ <frame src="<%= index_path %>" name="docwin" />
12
+ </frameset>
13
+ </html>
@@ -0,0 +1,129 @@
1
+ /*
2
+
3
+ github.com style (c) Vasily Polovnyov <vast@whiteants.net>
4
+
5
+ */
6
+
7
+ pre code {
8
+ display: block; padding: 0.5em;
9
+ color: #000;
10
+ background: #f8f8ff
11
+ }
12
+
13
+ pre .comment,
14
+ pre .template_comment,
15
+ pre .diff .header,
16
+ pre .javadoc {
17
+ color: #998;
18
+ font-style: italic
19
+ }
20
+
21
+ pre .keyword,
22
+ pre .css .rule .keyword,
23
+ pre .winutils,
24
+ pre .javascript .title,
25
+ pre .lisp .title,
26
+ pre .subst {
27
+ color: #000;
28
+ font-weight: bold
29
+ }
30
+
31
+ pre .number,
32
+ pre .hexcolor {
33
+ color: #40a070
34
+ }
35
+
36
+ pre .string,
37
+ pre .tag .value,
38
+ pre .phpdoc,
39
+ pre .tex .formula {
40
+ color: #d14
41
+ }
42
+
43
+ pre .title,
44
+ pre .id {
45
+ color: #900;
46
+ font-weight: bold
47
+ }
48
+
49
+ pre .javascript .title,
50
+ pre .lisp .title,
51
+ pre .subst {
52
+ font-weight: normal
53
+ }
54
+
55
+ pre .class .title,
56
+ pre .haskell .label,
57
+ pre .tex .command {
58
+ color: #458;
59
+ font-weight: bold
60
+ }
61
+
62
+ pre .tag,
63
+ pre .tag .title,
64
+ pre .rules .property,
65
+ pre .django .tag .keyword {
66
+ color: #000080;
67
+ font-weight: normal
68
+ }
69
+
70
+ pre .attribute,
71
+ pre .variable,
72
+ pre .instancevar,
73
+ pre .lisp .body {
74
+ color: #008080
75
+ }
76
+
77
+ pre .regexp {
78
+ color: #009926
79
+ }
80
+
81
+ pre .class {
82
+ color: #458;
83
+ font-weight: bold
84
+ }
85
+
86
+ pre .symbol,
87
+ pre .ruby .symbol .string,
88
+ pre .ruby .symbol .keyword,
89
+ pre .ruby .symbol .keymethods,
90
+ pre .lisp .keyword,
91
+ pre .tex .special,
92
+ pre .input_number {
93
+ color: #990073
94
+ }
95
+
96
+ pre .builtin,
97
+ pre .built_in,
98
+ pre .lisp .title {
99
+ color: #0086b3
100
+ }
101
+
102
+ pre .preprocessor,
103
+ pre .pi,
104
+ pre .doctype,
105
+ pre .shebang,
106
+ pre .cdata {
107
+ color: #999;
108
+ font-weight: bold
109
+ }
110
+
111
+ pre .deletion {
112
+ background: #fdd
113
+ }
114
+
115
+ pre .addition {
116
+ background: #dfd
117
+ }
118
+
119
+ pre .diff .change {
120
+ background: #0086b3
121
+ }
122
+
123
+ pre .chunk {
124
+ color: #aaa
125
+ }
126
+
127
+ pre .tex .formula {
128
+ opacity: 0.5;
129
+ }