sdoc 1.0.0.rc2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -1
  3. data/.travis.yml +12 -11
  4. data/CHANGELOG.md +31 -0
  5. data/Gemfile +1 -1
  6. data/README.md +15 -5
  7. data/Rakefile +1 -2
  8. data/bin/sdoc +1 -1
  9. data/bin/sdoc-merge +1 -1
  10. data/lib/rdoc/discover.rb +1 -1
  11. data/lib/rdoc/generator/template/rails/_context.rhtml +216 -0
  12. data/lib/rdoc/generator/template/rails/_head.rhtml +39 -0
  13. data/lib/rdoc/generator/template/rails/_panel.rhtml +14 -0
  14. data/lib/rdoc/generator/template/rails/class.rhtml +51 -0
  15. data/lib/rdoc/generator/template/rails/file.rhtml +38 -0
  16. data/lib/rdoc/generator/template/rails/index.rhtml +33 -0
  17. data/lib/rdoc/generator/template/rails/resources/apple-touch-icon.png +0 -0
  18. data/lib/rdoc/generator/template/rails/resources/css/github.css +123 -0
  19. data/lib/rdoc/generator/template/rails/resources/css/main.css +378 -0
  20. data/lib/rdoc/generator/template/rails/resources/css/panel.css +365 -0
  21. data/lib/rdoc/generator/template/rails/resources/css/reset.css +48 -0
  22. data/lib/rdoc/generator/template/rails/resources/favicon.ico +0 -0
  23. data/lib/rdoc/generator/template/rails/resources/i/arrow-down.svg +8 -0
  24. data/lib/rdoc/generator/template/rails/resources/i/arrow-right.svg +8 -0
  25. data/lib/rdoc/generator/template/rails/resources/i/search.svg +12 -0
  26. data/lib/rdoc/generator/template/rails/resources/i/tree_bg.svg +8 -0
  27. data/lib/rdoc/generator/template/rails/resources/js/highlight.pack.js +1 -0
  28. data/lib/rdoc/generator/template/rails/resources/js/jquery-3.5.1.min.js +2 -0
  29. data/lib/rdoc/generator/template/rails/resources/js/main.js +41 -0
  30. data/lib/rdoc/generator/template/rails/resources/js/searchdoc.js +493 -0
  31. data/lib/rdoc/generator/template/rails/resources/js/turbolinks.js +6 -0
  32. data/lib/rdoc/generator/template/rails/search_index.rhtml +8 -0
  33. data/lib/rdoc/generator/template/sdoc/_context.rhtml +5 -5
  34. data/lib/rdoc/generator/template/sdoc/_head.rhtml +0 -1
  35. data/lib/rdoc/generator/template/sdoc/class.rhtml +13 -0
  36. data/lib/rdoc/generator/template/sdoc/file.rhtml +0 -0
  37. data/lib/rdoc/generator/template/sdoc/index.rhtml +0 -0
  38. data/lib/rdoc/generator/template/sdoc/resources/css/main.css +11 -1
  39. data/lib/rdoc/generator/template/sdoc/resources/css/panel.css +0 -0
  40. data/lib/rdoc/generator/template/sdoc/resources/css/reset.css +0 -0
  41. data/lib/rdoc/generator/template/sdoc/resources/i/arrows.png +0 -0
  42. data/lib/rdoc/generator/template/sdoc/resources/i/results_bg.png +0 -0
  43. data/lib/rdoc/generator/template/sdoc/resources/i/tree_bg.png +0 -0
  44. data/lib/rdoc/generator/template/sdoc/resources/js/highlight.pack.js +0 -0
  45. data/lib/rdoc/generator/template/sdoc/resources/js/jquery-1.3.2.min.js +0 -0
  46. data/lib/rdoc/generator/template/sdoc/resources/js/main.js +7 -1
  47. data/lib/rdoc/generator/template/sdoc/resources/js/searchdoc.js +21 -2
  48. data/lib/rdoc/generator/template/sdoc/resources/panel/index.html +0 -0
  49. data/lib/sdoc.rb +0 -2
  50. data/lib/sdoc/generator.rb +19 -80
  51. data/lib/sdoc/github.rb +13 -14
  52. data/lib/sdoc/helpers.rb +22 -0
  53. data/lib/sdoc/templatable.rb +5 -1
  54. data/lib/sdoc/version.rb +1 -1
  55. data/sdoc.gemspec +2 -1
  56. data/spec/helpers_spec.rb +32 -0
  57. data/spec/rdoc_generator_spec.rb +8 -0
  58. metadata +27 -13
  59. data/lib/rdoc/generator/template/sdoc/resources/js/jquery-effect.js +0 -593
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fd8f108539b22e091aee84678e782138bb18aa53
4
- data.tar.gz: 6155efbb4da708d34160dd72c7b3d6cc961713fc
2
+ SHA256:
3
+ metadata.gz: 92be8c9ef112cad65ae175c43397ba7c74e5ce6a5dd487defe7391c519a7f4e0
4
+ data.tar.gz: 87fbba0f4724a4d61468db740892afc6b4cb3492427ea9fa41bf9c4f7bdb3d33
5
5
  SHA512:
6
- metadata.gz: 1f279d16a4661525a966e664a26572e787e53383c91dd050a8a24037b277fd005394c48cb0856d495a15b36928c035d50872c28909fce411440b540639c81572
7
- data.tar.gz: 5ed8e231e52ac56ba9f959780cb2307637e35d85d02b193de0d369b67af50bd512d0235bc800d1037e1b7f0c84489168d5c99eb5fa24f1dfacd873affcd686da
6
+ metadata.gz: a032a96408400f81bcb381c2aa68b6bbd79bf37dea20c7e9c2e70e5e8f470d277736b5bdc77ad1ea493077de89fe294cf8abe58ef9f946f661822758547a81b1
7
+ data.tar.gz: 707cc43e783acfab07306c54d760d57bbb9df21e6a1ed0295a406a5d4c05fe6dd0acdf977d9773527ebe3d3841fcfdf476b3a00b456f4c2f8fd1ce0b8e005cee
data/.gitignore CHANGED
@@ -6,4 +6,4 @@ doc
6
6
  Gemfile.lock
7
7
  /.rake_tasks~
8
8
  /*.gem
9
- rails/
9
+ /rails/
@@ -1,29 +1,30 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  before_install:
4
- - gem install bundler
4
+ - gem update --system || gem update --system 2.7.8
5
+ - gem install bundler || gem install bundler -v 1.17.3
5
6
  rvm:
6
7
  - 1.9.3
7
8
  - 2.0.0
8
9
  - 2.1.0
9
- - 2.2.0
10
- - 2.3.0
11
- - 2.4.0
10
+ - 2.2.10
11
+ - 2.3.7
12
+ - 2.4.4
13
+ - 2.5.1
14
+ - 2.6.0
12
15
  - ruby-head
13
- - jruby-19mode
14
16
  - jruby-head
15
17
  matrix:
16
18
  allow_failures:
17
19
  - env: rdoc=master
18
20
  - rvm: jruby-head
19
21
  include:
20
- - { rvm: 1.9.3, env: rdoc=master }
21
- - { rvm: 2.0.0, env: rdoc=master }
22
- - { rvm: 2.1.0, env: rdoc=master }
23
- - { rvm: 2.2.0, env: rdoc=master }
24
- - { rvm: 2.3.0, env: rdoc=master }
22
+ - { rvm: 2.2.10, env: rdoc=master }
23
+ - { rvm: 2.3.7, env: rdoc=master }
24
+ - { rvm: 2.4.4, env: rdoc=master }
25
+ - { rvm: 2.5.1, env: rdoc=master }
26
+ - { rvm: 2.6.0, env: rdoc=master }
25
27
  - { rvm: ruby-head, env: rdoc=master }
26
- - { rvm: jruby-19mode, env: rdoc=master }
27
28
  - { rvm: jruby-head, env: rdoc=master }
28
29
  notifications:
29
30
  email:
@@ -1,3 +1,34 @@
1
+ 2.0.1
2
+ =====
3
+
4
+ * #142 Fix arrow icons for selected panel items
5
+ * #141 Always use only one metatag for keywords
6
+ * #140 Use h2 instead of h1 for banner header
7
+
8
+ 2.0.0
9
+ =====
10
+
11
+ * #137 Replace frames based implementation with a css
12
+ * #132 Deprecate safe_level of ERB.new in Ruby 2.6
13
+
14
+ 1.1.0
15
+ =====
16
+
17
+ * #138 - Fix panel header overflow on Chrome
18
+ * 39e6cae9 - Display version using `-v` or `--version` flags
19
+
20
+ 1.0.0
21
+ =====
22
+
23
+ * #110 - Strip out HTML tags from search results description
24
+ * #109 - Add basic SEO tags
25
+ * #108 - Tiny refresh of the Rails theme
26
+ * e6f02b91 - Remove the jQuery effect library
27
+ * 73ace366 - Remove the `--without-search` option
28
+ * b1d429f2 - Produce HTML 5 output
29
+ * 38d06095 - Support only RDoc 5 and up
30
+ * #96 - Require at least Ruby 1.9.3
31
+
1
32
  0.4.2
2
33
  =====
3
34
 
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gem "minitest"
7
7
  gem "hoe"
8
8
 
9
9
  if ENV["rdoc"] == "master"
10
- gem "rdoc", :github => "rdoc/rdoc"
10
+ gem "rdoc", :github => "ruby/rdoc"
11
11
  end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SDoc
2
2
 
3
- [![Build Status](https://travis-ci.org/zzak/sdoc.png?branch=master)](https://travis-ci.org/zzak/sdoc)
3
+ [![Build Status](https://travis-ci.org/zzak/sdoc.svg?branch=master)](https://travis-ci.org/zzak/sdoc)
4
4
 
5
5
  **Powering http://api.rubyonrails.org/**
6
6
 
@@ -62,9 +62,9 @@ require 'sdoc' # and use your RDoc task the same way you used it before
62
62
  require 'rdoc/task' # ensure this file is also required in order to use `RDoc::Task`
63
63
 
64
64
  RDoc::Task.new do |rdoc|
65
- rdoc.rdoc_dir = 'doc/rdoc' # name of output directory
66
- rdoc.generator = 'sdoc' # explictly set the sdoc generator
67
- rdoc.template = 'rails' # template used on api.rubyonrails.org
65
+ rdoc.rdoc_dir = 'doc/rdoc' # name of output directory
66
+ rdoc.options << '--format=sdoc' # explictly set the sdoc generator
67
+ rdoc.template = 'rails' # template used on api.rubyonrails.org
68
68
  end
69
69
  ```
70
70
 
@@ -78,7 +78,7 @@ Alternatively you can pass this command a path to the project you wish to compil
78
78
 
79
79
  As mentioned before, SDoc is built on top of the RDoc project.
80
80
 
81
- If you notice any bugs in the output of your documentation, it may be RDoc's fault and should be [reported upstream](https://github.com/rdoc/rdoc/issues/new).
81
+ If you notice any bugs in the output of your documentation, it may be RDoc's fault and should be [reported upstream](https://github.com/ruby/rdoc/issues/new).
82
82
 
83
83
  An example of an SDoc bug would be:
84
84
 
@@ -90,6 +90,16 @@ Please feel free to still report issues here for both projects, especially if yo
90
90
 
91
91
  As maintainer of both projects, I'll see if I can identify the root of the cause :bow: :bow: :bow:
92
92
 
93
+ ## Contributing
94
+
95
+ If you'd like to contribute you can generate the Rails documentation by running:
96
+
97
+ ```bash
98
+ rake test:rails
99
+ ```
100
+
101
+ This task will generate documentation for the Rails master branch.
102
+ Since the task doesn't do any file filtering it contains a lot of extra pages.
93
103
 
94
104
  ### Who?
95
105
 
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- require 'rubygems'
2
-
3
1
  require 'bundler'
4
2
  Bundler::GemHelper.install_tasks
5
3
 
@@ -7,6 +5,7 @@ require 'rake/testtask'
7
5
 
8
6
  Rake::TestTask.new do |t|
9
7
  t.pattern = "spec/*_spec.rb"
8
+ t.libs << "spec"
10
9
  end
11
10
 
12
11
  task :default => :test
data/bin/sdoc CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby -KU
1
+ #!/usr/bin/env ruby
2
2
  require 'sdoc'
3
3
 
4
4
  begin
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ruby -KU
1
+ #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__) + '/../lib/sdoc' # add extensions
3
3
  require 'sdoc/merge'
4
4
 
@@ -1,5 +1,5 @@
1
1
  begin
2
- gem 'rdoc', '~> 5.0'
2
+ gem 'rdoc', '>= 5.0'
3
3
  require File.join(File.dirname(__FILE__), '/../sdoc')
4
4
  rescue Gem::LoadError
5
5
  end
@@ -0,0 +1,216 @@
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
+ <% constants.each 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;').gsub(/\n(.)/, '<br />\1') %></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.is_alias_for then %>
179
+ <div class="aka">
180
+ Alias for: <a href="<%= context.aref_to method.is_alias_for.path %>"><%= h method.is_alias_for.name %></a>
181
+ </div>
182
+ <% end %>
183
+
184
+ <% if method.token_stream %>
185
+ <% markup = method.markup_code %>
186
+ <div class="sourcecode">
187
+ <%
188
+ # generate github link
189
+ github = if options.github
190
+ if markup =~ /File\s(\S+), line (\d+)/
191
+ path = $1
192
+ line = $2.to_i
193
+ end
194
+ path && github_url(path)
195
+ else
196
+ false
197
+ end
198
+ %>
199
+ <p class="source-link">
200
+ Source:
201
+ <a href="javascript:toggleSource('<%= method.aref %>_source')" id="l_<%= method.aref %>_source">show</a>
202
+ <% if github %>
203
+ | <a href="<%= "#{github}#L#{line}" %>" target="_blank" class="github_url">on GitHub</a>
204
+ <% end %>
205
+ </p>
206
+ <div id="<%= method.aref %>_source" class="dyn-source">
207
+ <pre><%= markup %></pre>
208
+ </div>
209
+ </div>
210
+ <% end %>
211
+ </div>
212
+ <% end %><%# methods.each %>
213
+ <% end %><%# visibilities.each %>
214
+ <% end %><%# context.methods_by_type %>
215
+ <% end %><%# context.each_section %>
216
+ </div>
@@ -0,0 +1,39 @@
1
+ <%
2
+ # Turbolinks does not consider relative urls similar, resulting in page
3
+ # reloads and losing the context of the panel. Emptying the rel_prefix makes
4
+ # asset paths absolute. This breaks opening the docs locally. Maybe all
5
+ # generated docs should be in the same folder?
6
+ rel_prefix = ''
7
+ %>
8
+ <link rel="stylesheet" href="<%= "#{rel_prefix}/css/reset.css" %>" type="text/css" media="screen" data-turbolinks-track="reload" />
9
+ <link rel="stylesheet" href="<%= "#{rel_prefix}/css/panel.css" %>" type="text/css" media="screen" data-turbolinks-track="reload" />
10
+ <link rel="stylesheet" href="<%= "#{rel_prefix}/css/main.css" %>" type="text/css" media="screen" data-turbolinks-track="reload" />
11
+ <link rel="stylesheet" href="<%= "#{rel_prefix}/css/github.css" %>" type="text/css" media="screen" data-turbolinks-track="reload" />
12
+ <script src="<%= "#{rel_prefix}/js/jquery-3.5.1.min.js" %>" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
13
+ <script src="<%= "#{rel_prefix}/js/main.js" %>" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
14
+ <script src="<%= "#{rel_prefix}/js/highlight.pack.js" %>" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
15
+ <script src="<%= rel_prefix %>/js/turbolinks.js" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
16
+ <script src="<%= rel_prefix %>/js/search_index.js" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
17
+ <script src="<%= rel_prefix %>/js/searcher.js" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
18
+ <script src="<%= rel_prefix %>/panel/tree.js" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
19
+ <script src="<%= rel_prefix %>/js/searchdoc.js" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
20
+ <script type="text/javascript" charset="utf-8">
21
+ document.addEventListener("turbolinks:load", function() {
22
+ // Only initialize panel if not yet initialized
23
+ if(!$('#panel .tree ul li').length) {
24
+ $('#links').hide();
25
+ var panel = new Searchdoc.Panel($('#panel'), search_data, tree, '<%= rel_prefix %>/');
26
+ $('#search').focus();
27
+ var s = window.location.search.match(/\?q=([^&]+)/);
28
+ if (s) {
29
+ s = decodeURIComponent(s[1]).replace(/\+/g, ' ');
30
+ if (s.length > 0) {
31
+ $('#search').val(s);
32
+ panel.search(s, true);
33
+ }
34
+ }
35
+ panel.toggle(<%= tree_keys %>);
36
+ }
37
+ })
38
+ </script>
39
+
@@ -0,0 +1,14 @@
1
+ <div class="panel panel_tree" id="panel" data-turbolinks-permanent>
2
+ <div class="header">
3
+ <input type="text" placeholder="Search for a class, method, ..." autosave="searchdoc" results="10" id="search" autocomplete="off" />
4
+ </div>
5
+ <div class="tree">
6
+ <ul>
7
+ </ul>
8
+ </div>
9
+ <div class="result">
10
+ <ul>
11
+ </ul>
12
+ </div>
13
+ <a href="links.html" id="links">index</a>
14
+ </div>