Skip to content

Commit d3bc2cc

Browse files
committed
Merge pull request rspec#20 from rspec/documentation-spike
Documentation spike
2 parents a255459 + b792065 commit d3bc2cc

File tree

601 files changed

+324934
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

601 files changed

+324934
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
# Ignore bundler artifacts
2020
bin
2121
bundle
22+
23+
source/documentation/**/**/css
24+
source/documentation/**/**/js

config.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
activate :syntax
1313
activate :directory_indexes
1414

15+
page "documentation/**/*.html", directory_index: false
16+
1517
set :css_dir, 'stylesheets'
1618
set :js_dir, 'javascripts'
1719
set :images_dir, 'images'
@@ -68,4 +70,13 @@ def asciinema_video(id, speed: 1)
6870
|</div>
6971
HTML
7072
end
73+
74+
def rspec_documentation
75+
hash = Hash.new { |h,k| h[k] = [] }
76+
Dir["#{root}/source/documentation/*/*"].each do |dir|
77+
version, gem = dir.scan(%r{/source/documentation/([^/]+)/([^/]+)}).first.flatten
78+
hash[gem] << version
79+
end
80+
hash
81+
end
7182
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<meta http-equiv="Content-Type" content="text/html; charset=<%= charset %>" />
2+
<title>
3+
<%= h @page_title %>
4+
<% if options.title && @page_title != options.title %>
5+
&mdash; <%= h options.title %>
6+
<% end %>
7+
</title>
8+
<% stylesheets.each do |stylesheet| %>
9+
<link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" charset="utf-8" />
10+
<% end %>
11+
<%= erb :script_setup %>
12+
<% javascripts.each do |javascript| %>
13+
<script type="text/javascript" charset="utf-8" src="<%= url_for(javascript)%>"></script>
14+
<% end %>

docs-template/plugin.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module TagsTemplateHelper
2+
3+
def url_for(*args)
4+
super
5+
.gsub(/^[\.\/]*/,'/') # Makes paths absolute
6+
.gsub(/^[\.\/]*css/, '/stylesheets/docs') # Links to our css
7+
.gsub(/^[\.\/]*js/, '/javascripts/docs') # Links to our js
8+
end
9+
10+
def url_for_file(*args)
11+
super.gsub(/^[\.\/]*/,'/')
12+
end
13+
14+
end
15+
16+
module YARD
17+
module Templates::Helpers
18+
19+
module HtmlHelper
20+
21+
def url_for_list(*args)
22+
super.gsub(/^[\.\/]*/,'/')
23+
end
24+
25+
end
26+
end
27+
end

lib/yard-rspec-docs-template.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
YARD::Templates::Engine.register_template_path Pathname.new(File.dirname(__FILE__)).join('..', 'docs-template')

source/documentation.html.slim

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ section
1717
h2 API Documentation
1818

1919
p
20-
| You can find detailed API documentation on the Rubydoc.info site:
20+
| You can find detailed API documentation for versions below
2121

2222
ul
23-
li= link_to 'http://rubydoc.info/gems/rspec-core', 'http://rubydoc.info/gems/rspec-core'
24-
li= link_to 'http://rubydoc.info/gems/rspec-expectations', 'http://rubydoc.info/gems/rspec-expectations'
25-
li= link_to 'http://rubydoc.info/gems/rspec-mocks', 'http://rubydoc.info/gems/rspec-mocks'
26-
li= link_to 'http://rubydoc.info/gems/rspec-rails', 'http://rubydoc.info/gems/rspec-rails'
23+
- rspec_documentation.each do |gem, versions|
24+
li
25+
b
26+
| #{gem}:&nbsp;
27+
- versions.sort.reverse.each do |version|
28+
= link_to version, "/documentation/#{version}/#{gem}/"
29+
| &nbsp;

0 commit comments

Comments
 (0)