sdoc 2.0.1 → 2.2.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +37 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +42 -5
  5. data/README.md +22 -4
  6. data/Rakefile +54 -2
  7. data/config.ru +30 -0
  8. data/lib/rdoc/generator/template/rails/_context.rhtml +5 -5
  9. data/lib/rdoc/generator/template/rails/_head.rhtml +2 -19
  10. data/lib/rdoc/generator/template/rails/_panel.rhtml +6 -3
  11. data/lib/rdoc/generator/template/rails/class.rhtml +7 -4
  12. data/lib/rdoc/generator/template/rails/file.rhtml +7 -4
  13. data/lib/rdoc/generator/template/rails/index.rhtml +10 -10
  14. data/lib/rdoc/generator/template/rails/resources/css/main.css +37 -10
  15. data/lib/rdoc/generator/template/rails/resources/css/panel.css +125 -8
  16. data/lib/rdoc/generator/template/rails/resources/css/reset.css +0 -1
  17. data/lib/rdoc/generator/template/rails/resources/i/arrow-down-current.svg +8 -0
  18. data/lib/rdoc/generator/template/rails/resources/i/arrow-right-current.svg +8 -0
  19. data/lib/rdoc/generator/template/rails/resources/js/main.js +17 -0
  20. data/lib/rdoc/generator/template/rails/resources/js/searchdoc.js +9 -21
  21. data/lib/rdoc/generator/template/rails/search_index.rhtml +6 -2
  22. data/lib/rdoc/generator/template/sdoc/class.rhtml +5 -6
  23. data/lib/rdoc/generator/template/sdoc/file.rhtml +5 -6
  24. data/lib/rdoc/generator/template/sdoc/index.rhtml +3 -4
  25. data/lib/rdoc/generator/template/sdoc/resources/css/reset.css +0 -1
  26. data/lib/rdoc/generator/template/sdoc/resources/js/searchdoc.js +0 -10
  27. data/lib/rdoc/generator/template/sdoc/resources/panel/index.html +2 -1
  28. data/lib/rdoc/generator/template/sdoc/search_index.rhtml +6 -2
  29. data/lib/sdoc/merge.rb +5 -28
  30. data/lib/sdoc/version.rb +1 -1
  31. data/netlify.toml +39 -0
  32. data/sdoc.gemspec +2 -1
  33. data/spec/helpers_spec.rb +2 -2
  34. data/spec/rdoc_generator_spec.rb +9 -9
  35. metadata +8 -5
  36. data/.travis.yml +0 -31
  37. data/lib/rdoc/generator/template/merge/index.rhtml +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92be8c9ef112cad65ae175c43397ba7c74e5ce6a5dd487defe7391c519a7f4e0
4
- data.tar.gz: 87fbba0f4724a4d61468db740892afc6b4cb3492427ea9fa41bf9c4f7bdb3d33
3
+ metadata.gz: 002ca37375a4f9d51c68f2c7ac421cec8c4baf74171615627e828fbf8947bc48
4
+ data.tar.gz: 06f44cb76f359c63d97a0b9e5c0eb5c5b06277c700928006e2e390c05955eb17
5
5
  SHA512:
6
- metadata.gz: a032a96408400f81bcb381c2aa68b6bbd79bf37dea20c7e9c2e70e5e8f470d277736b5bdc77ad1ea493077de89fe294cf8abe58ef9f946f661822758547a81b1
7
- data.tar.gz: 707cc43e783acfab07306c54d760d57bbb9df21e6a1ed0295a406a5d4c05fe6dd0acdf977d9773527ebe3d3841fcfdf476b3a00b456f4c2f8fd1ce0b8e005cee
6
+ metadata.gz: b48d64b1e6c87db2088e56c692ed31c8f85fef24e640b18a5c4f609966f7d0b912d78a2e2a973bfffc2bbbecf1ffb3bfb5f16adeecc69780f3e7286850a8f92a
7
+ data.tar.gz: 9e59249e7ea77c4057c1a741e9d4dd6c6fe058ba63fe976d88e20806520d7ce8b219aa5b04acc0943b8f91b0abfb11d97e9fb2d28360381cf893a5c7f8ec3b7f
@@ -0,0 +1,37 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ schedule:
6
+ - cron: '0 0 * * *'
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-20.04
11
+ strategy:
12
+ matrix:
13
+ ruby:
14
+ - '2.1'
15
+ - '2.2'
16
+ - '2.3'
17
+ - '2.4'
18
+ - '2.5'
19
+ - '2.6'
20
+ - '2.7'
21
+ - '3.0'
22
+ - 'ruby-head'
23
+ - 'jruby-head'
24
+ - 'truffleruby-head'
25
+
26
+ steps:
27
+ - uses: actions/checkout@v1
28
+
29
+ - name: Set up Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: ${{ matrix.ruby }}
33
+ bundler-cache: true
34
+
35
+ - name: Test
36
+ run: |
37
+ bundle exec rake
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ Gemfile.lock
7
7
  /.rake_tasks~
8
8
  /*.gem
9
9
  /rails/
10
+ /ruby/
data/CHANGELOG.md CHANGED
@@ -1,14 +1,52 @@
1
+ Master
2
+ ======
3
+
4
+ 2.2.0
5
+ =====
6
+
7
+ * #161 Add 'skip to content' link and improve shortcut keys [@MikeRogers0](https://github.com/MikeRogers0)
8
+ * #170 Fix link hovers in headings [@tlatsas](https://github.com/tlatsas)
9
+ * #169 Fix clearing search results [@mikdiet](https://github.com/mikdiet)
10
+ * #167 Update Merge script to work with sdoc v2 [@mikdiet](https://github.com/mikdiet)
11
+ * #160 Remove outline from reset stylesheet [@p8](https://github.com/p8)
12
+ * #159 Remove TAB override in panel [@p8](https://github.com/p8)
13
+ * #157 Move to GitHub action for tests [@MikeRogers0](https://github.com/MikeRogers0)
14
+ * #155 Fix Ctrl+C copying [Jan Schär](https://github.com/jscissr)
15
+
16
+ 2.1.0
17
+ =====
18
+
19
+ * #154 Make panel responsive for mobile [@MikeRogers0](https://github.com/MikeRogers0) and [@p8](https://github.com/p8)
20
+ * #153 Add viewport metatag to views for improved Lighthouse score. [@MikeRogers0](https://github.com/MikeRogers0)
21
+ * #150 Use semantic headers for better SEO [@p8](https://github.com/p8)
22
+
23
+ 2.0.4
24
+ =====
25
+
26
+ * #149 Using HTML5 doctype accross all HTML files. [@MikeRogers0](https://github.com/MikeRogers0)
27
+ * #148 Fix overflow CSS property of panel elements. [@cveneziani](https://github.com/cveneziani)
28
+
29
+ 2.0.3
30
+ =====
31
+
32
+ * #147 Use @options.title for the index [@p8](https://github.com/p8)
33
+
34
+ 2.0.2
35
+ =====
36
+
37
+ * Remove accidental rack inclusion in gemspec
38
+
1
39
  2.0.1
2
40
  =====
3
41
 
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
42
+ * #142 Fix arrow icons for selected panel items [@p8](https://github.com/p8)
43
+ * #141 Always use only one metatag for keywords [@p8](https://github.com/p8)
44
+ * #140 Use h2 instead of h1 for banner header [@p8](https://github.com/p8)
7
45
 
8
46
  2.0.0
9
47
  =====
10
48
 
11
- * #137 Replace frames based implementation with a css
49
+ * #137 Replace frames based implementation with a css [@p8](https://github.com/p8)
12
50
  * #132 Deprecate safe_level of ERB.new in Ruby 2.6
13
51
 
14
52
  1.1.0
@@ -68,4 +106,3 @@ Bug Fixes
68
106
  [Compare v0.3.20...v0.4.0](https://github.com/voloko/sdoc/compare/v0.3.20...v0.4.0)
69
107
 
70
108
  No friendly log for this version yet, but PRs are welcome!
71
-
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SDoc
2
2
 
3
- [![Build Status](https://travis-ci.org/zzak/sdoc.svg?branch=master)](https://travis-ci.org/zzak/sdoc)
3
+ [![Tests](https://github.com/zzak/sdoc/actions/workflows/test.yml/badge.svg)](https://github.com/zzak/sdoc/actions/workflows/test.yml)
4
4
 
5
5
  **Powering http://api.rubyonrails.org/**
6
6
 
@@ -92,14 +92,32 @@ As maintainer of both projects, I'll see if I can identify the root of the cause
92
92
 
93
93
  ## Contributing
94
94
 
95
- If you'd like to contribute you can generate the Rails documentation by running:
95
+ If you'd like to contribute you can generate the Rails main branch documentation by running:
96
96
 
97
97
  ```bash
98
98
  rake test:rails
99
99
  ```
100
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.
101
+ You can generate the Ruby default branch documentation by running:
102
+
103
+ ```bash
104
+ rake test:ruby
105
+ ```
106
+
107
+ You can generate merged Rails and Ruby documentation by running:
108
+
109
+ ```bash
110
+ rake test:merged
111
+ ```
112
+
113
+ The generated documentation will be put into `doc/public` directory.
114
+ To view the just generated documentation start up a rack application by running:
115
+
116
+ ```bash
117
+ rackup config.ru
118
+ ```
119
+
120
+ Then open http://localhost:9292 in the browser to view the documentation.
103
121
 
104
122
  ### Who?
105
123
 
data/Rakefile CHANGED
@@ -12,22 +12,74 @@ task :default => :test
12
12
  task :spec => :test
13
13
 
14
14
  require 'sdoc'
15
+ require 'sdoc/merge'
15
16
  require 'rdoc/task'
16
17
 
17
18
  rails = File.expand_path "rails"
19
+ ruby = File.expand_path "ruby"
18
20
 
19
21
  directory rails do
20
22
  sh "git clone --depth=1 https://github.com/rails/rails"
21
23
  end
22
24
 
25
+ directory ruby do
26
+ sh "git clone --depth=1 https://github.com/ruby/ruby"
27
+ end
28
+
23
29
  namespace :test do
24
- task :rails => rails
30
+ desc 'Deletes all generated test documentation'
31
+ task :reset_docs do
32
+ FileUtils.remove_dir(File.expand_path('doc'), force: true)
33
+ end
34
+
35
+ desc 'Generates test rails documentation'
36
+ task :rails => [rails, :generate_rails] do
37
+ FileUtils.mv(
38
+ File.expand_path('doc/rails'),
39
+ File.expand_path('doc/public')
40
+ )
41
+ end
25
42
 
26
- RDoc::Task.new(:rails) do |rdoc|
43
+ RDoc::Task.new(:generate_rails) do |rdoc|
27
44
  rdoc.rdoc_dir = 'doc/rails'
28
45
  rdoc.generator = 'sdoc'
29
46
  rdoc.template = 'rails'
47
+ rdoc.title = 'Ruby on Rails'
48
+ rdoc.main = 'rails/README.md'
49
+ rdoc.options << '--exclude=test'
30
50
 
31
51
  rdoc.rdoc_files.include("rails/")
32
52
  end
53
+
54
+ desc 'Generates test ruby documentation'
55
+ task :ruby => [ruby, :generate_ruby] do
56
+ FileUtils.mv(
57
+ File.expand_path('doc/ruby'),
58
+ File.expand_path('doc/public')
59
+ )
60
+ end
61
+
62
+ RDoc::Task.new(:generate_ruby) do |rdoc|
63
+ rdoc.rdoc_dir = 'doc/ruby'
64
+ rdoc.generator = 'sdoc'
65
+ rdoc.template = 'rails'
66
+ rdoc.title = 'Ruby'
67
+ rdoc.main = 'ruby/README.md'
68
+
69
+ rdoc.rdoc_files.include("ruby/")
70
+ end
71
+
72
+ desc 'Generates merged test documentation'
73
+ task :merged => [rails, :generate_rails, ruby, :generate_ruby, :merge]
74
+
75
+ task :merge do
76
+ SDoc::Merge.new.merge(
77
+ [
78
+ '--title', 'Rails + Ruby',
79
+ '--op', 'doc/public',
80
+ '--names', 'rails, ruby',
81
+ 'doc/rails', 'doc/ruby'
82
+ ]
83
+ )
84
+ end
33
85
  end
data/config.ru ADDED
@@ -0,0 +1,30 @@
1
+ # Rack application for serving the documentation locally.
2
+ # After generating the documentation run:
3
+ #
4
+ # bundle exec rackup config.ru
5
+ #
6
+ require 'bundler/setup'
7
+
8
+ root = "doc/public"
9
+ unless Dir.exists?(root)
10
+ puts <<~MESSAGE
11
+ Could not find any docs in #{root}.
12
+ Run the following command to generate sample documentation:
13
+ bundle exec rake test:rails
14
+ MESSAGE
15
+ exit
16
+ end
17
+
18
+ use Rack::Static,
19
+ :urls => ["/files", "/images", "/js", "/css", "/panel", "/i", "/classes", "/ruby", "/rails"],
20
+ :root => root
21
+ run lambda { |env|
22
+ [
23
+ 200,
24
+ {
25
+ 'Content-Type' => 'text/html',
26
+ 'Cache-Control' => 'public, max-age=86400'
27
+ },
28
+ File.open("#{root}/index.html", File::RDONLY)
29
+ ]
30
+ }
@@ -101,7 +101,7 @@
101
101
 
102
102
  <% unless constants.empty? %>
103
103
  <!-- Section constants -->
104
- <div class="sectiontitle">Constants</div>
104
+ <h2 class="sectiontitle">Constants</h2>
105
105
  <table border='0' cellpadding='5'>
106
106
  <% constants.each do |const| %>
107
107
  <tr valign='top'>
@@ -122,7 +122,7 @@
122
122
 
123
123
  <% unless attributes.empty? %>
124
124
  <!-- Section attributes -->
125
- <div class="sectiontitle">Attributes</div>
125
+ <h2 class="sectiontitle">Attributes</h2>
126
126
  <table border='0' cellpadding='5'>
127
127
  <% attributes.each do |attrib| %>
128
128
  <tr valign='top'>
@@ -145,17 +145,17 @@
145
145
  visibilities.each do |visibility, methods|
146
146
  next if methods.empty?
147
147
  %>
148
- <div class="sectiontitle"><%= type.capitalize %> <%= visibility.to_s.capitalize %> methods</div>
148
+ <h2 class="sectiontitle"><%= type.capitalize %> <%= visibility.to_s.capitalize %> methods</h2>
149
149
  <% methods.each do |method| %>
150
150
  <div class="method">
151
- <div class="title method-title" id="<%= method.aref %>">
151
+ <h3 class="title method-title" id="<%= method.aref %>">
152
152
  <% if method.call_seq %>
153
153
  <b><%= method.call_seq.gsub(/->/, '&rarr;').gsub(/\n(.)/, '<br />\1') %></b>
154
154
  <% else %>
155
155
  <b><%= h method.name %></b><%= h method.params %>
156
156
  <% end %>
157
157
  <a href="<%= "#{rel_prefix}/#{context.path}##{method.aref}"%>" name="<%= method.aref %>" class="permalink">Link</a>
158
- </div>
158
+ </h3>
159
159
 
160
160
  <% if method.comment %>
161
161
  <div class="description">
@@ -17,23 +17,6 @@
17
17
  <script src="<%= rel_prefix %>/js/searcher.js" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
18
18
  <script src="<%= rel_prefix %>/panel/tree.js" type="text/javascript" charset="utf-8" data-turbolinks-track="reload"></script>
19
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
20
 
21
+ <meta name="data-rel-prefix" content="<%= rel_prefix %>/">
22
+ <meta name="data-tree-keys" content='<%= tree_keys %>'>
@@ -1,6 +1,9 @@
1
- <div class="panel panel_tree" id="panel" data-turbolinks-permanent>
1
+ <input type="checkbox" id="hamburger" class="panel_checkbox">
2
+ <label class="panel_mobile_button" for="hamburger"><span></span> Menu</label>
3
+ <nav class="panel panel_tree" id="panel" data-turbolinks-permanent>
2
4
  <div class="header">
3
- <input type="text" placeholder="Search for a class, method, ..." autosave="searchdoc" results="10" id="search" autocomplete="off" />
5
+ <input type="text" placeholder="Search (/) for a class, method, ..." autosave="searchdoc" results="10" id="search" autocomplete="off" tabindex="-1" />
6
+ <label class="panel_mobile_button_close" for="hamburger"><span></span> Close</label>
4
7
  </div>
5
8
  <div class="tree">
6
9
  <ul>
@@ -11,4 +14,4 @@
11
14
  </ul>
12
15
  </div>
13
16
  <a href="links.html" id="links">index</a>
14
- </div>
17
+ </nav>
@@ -3,6 +3,7 @@
3
3
  <head>
4
4
  <title><%= h klass.full_name %></title>
5
5
  <meta charset="<%= @options.charset %>" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
7
  <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix, :tree_keys => klass.full_name.split('::') } %>
7
8
 
8
9
  <meta property="og:title" value="<%= klass.full_name %>">
@@ -17,6 +18,8 @@
17
18
  </head>
18
19
 
19
20
  <body>
21
+ <a class="sr-only sr-only-focusable" href="#content" data-turbolinks="false">Skip to Content</a>
22
+ <a class="sr-only sr-only-focusable" href="#search" data-turbolinks="false">Skip to Search</a>
20
23
 
21
24
  <%= include_template '_panel.rhtml' %>
22
25
 
@@ -24,7 +27,7 @@
24
27
  <% if ENV['HORO_PROJECT_NAME'] %>
25
28
  <span><%= ERB::Util.html_escape(ENV['HORO_PROJECT_NAME']) %> <%= ERB::Util.html_escape(ENV['HORO_PROJECT_VERSION']) %></span><br />
26
29
  <% end %>
27
- <h1>
30
+ <h2>
28
31
  <span class="type"><%= klass.module? ? 'Module' : 'Class' %></span>
29
32
  <%= h klass.full_name %>
30
33
  <% if klass.type == 'class' %>
@@ -36,7 +39,7 @@
36
39
  <% end %>
37
40
  </span>
38
41
  <% end %>
39
- </h1>
42
+ </h2>
40
43
  <ul class="files">
41
44
  <% klass.in_files.each do |file| %>
42
45
  <li><a href="<%= "#{rel_prefix}/#{h file.path}" %>"><%= h file.absolute_name %></a></li>
@@ -44,8 +47,8 @@
44
47
  </ul>
45
48
  </div>
46
49
 
47
- <div id="bodyContent">
50
+ <main id="bodyContent">
48
51
  <%= include_template '_context.rhtml', {:context => klass, :rel_prefix => rel_prefix} %>
49
- </div>
52
+ </main>
50
53
  </body>
51
54
  </html>
@@ -3,10 +3,13 @@
3
3
  <head>
4
4
  <title><%= h file.name %></title>
5
5
  <meta charset="<%= @options.charset %>" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
7
  <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix, :tree_keys => [] } %>
7
8
  </head>
8
9
 
9
10
  <body>
11
+ <a class="sr-only sr-only-focusable" href="#content" data-turbolinks="false">Skip to Content</a>
12
+ <a class="sr-only sr-only-focusable" href="#search" data-turbolinks="false">Skip to Search</a>
10
13
 
11
14
  <%= include_template '_panel.rhtml' %>
12
15
 
@@ -14,9 +17,9 @@
14
17
  <% if ENV['HORO_PROJECT_NAME'] %>
15
18
  <span><%= ERB::Util.html_escape(ENV['HORO_PROJECT_NAME']) %> <%= ERB::Util.html_escape(ENV['HORO_PROJECT_VERSION']) %></span><br />
16
19
  <% end %>
17
- <h1>
20
+ <h2>
18
21
  <%= h file.name %>
19
- </h1>
22
+ </h2>
20
23
  <ul class="files">
21
24
  <%
22
25
  github = github_url(file.relative_name) if options.github
@@ -31,8 +34,8 @@
31
34
  </ul>
32
35
  </div>
33
36
 
34
- <div id="bodyContent">
37
+ <main id="bodyContent">
35
38
  <%= include_template '_context.rhtml', {:context => file, :rel_prefix => rel_prefix} %>
36
- </div>
39
+ </main>
37
40
  </body>
38
41
  </html>
@@ -1,14 +1,15 @@
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">
1
+ <!DOCTYPE html>
2
+ <html lang="en">
5
3
  <head>
6
- <title><%= h index.name %></title>
4
+ <title><%= @options.title %></title>
7
5
  <meta http-equiv="Content-Type" content="text/html; charset=<%= @options.charset %>" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1">
8
7
  <%= include_template '_head.rhtml', {:rel_prefix => rel_prefix, tree_keys: []} %>
9
8
  </head>
10
9
 
11
10
  <body>
11
+ <a class="sr-only sr-only-focusable" href="#content" data-turbolinks="false">Skip to Content</a>
12
+ <a class="sr-only sr-only-focusable" href="#search" data-turbolinks="false">Skip to Search</a>
12
13
 
13
14
  <%= include_template '_panel.rhtml' %>
14
15
 
@@ -16,18 +17,17 @@
16
17
  <% if ENV['HORO_PROJECT_NAME'] %>
17
18
  <span><%= ERB::Util.html_escape(ENV['HORO_PROJECT_NAME']) %> <%= ERB::Util.html_escape(ENV['HORO_PROJECT_VERSION']) %></span><br />
18
19
  <% end %>
19
- <h1>
20
+ <h2>
20
21
  <%= h index.name %>
21
- </h1>
22
+ </h2>
22
23
  <ul class="files">
23
24
  <li><%= h index.relative_name %></li>
24
25
  <li>Last modified: <%= index.last_modified %></li>
25
26
  </ul>
26
27
  </div>
27
28
 
28
- <div id="bodyContent">
29
+ <main id="bodyContent">
29
30
  <%= include_template '_context.rhtml', {:context => index } %>
30
- </div>
31
+ </main>
31
32
  </body>
32
33
  </html>
33
-