yard 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Rakefile +15 -0
- data/lib/yard/autoload.rb +1 -0
- data/lib/yard/server/commands/base.rb +9 -5
- data/lib/yard/server/commands/display_object_command.rb +1 -1
- data/lib/yard/server/commands/library_index_command.rb +11 -8
- data/lib/yard/server/commands/root_request_command.rb +3 -16
- data/lib/yard/server/commands/search_command.rb +2 -2
- data/lib/yard/server/commands/static_file_command.rb +2 -24
- data/lib/yard/server/commands/static_file_helpers.rb +53 -0
- data/lib/yard/server/doc_server_helper.rb +13 -6
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -3
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +3 -3
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +1 -1
- data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +2 -20
- data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +4 -2
- data/lib/yard/server/templates/doc_server/library_list/html/{contents.erb → listing.erb} +2 -2
- data/lib/yard/server/templates/doc_server/library_list/html/setup.rb +3 -1
- data/lib/yard/server/templates/doc_server/library_list/html/title.erb +1 -1
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +6 -6
- data/lib/yard/version.rb +1 -1
- data/spec/server/commands/base_spec.rb +3 -3
- data/spec/server/commands/library_command_spec.rb +2 -2
- data/spec/server/doc_server_helper_spec.rb +19 -1
- data/spec/server/router_spec.rb +4 -4
- data/spec/server/spec_helper.rb +7 -2
- data/spec/server/static_caching_spec.rb +12 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81c76130fea5d80195cc0e8f500a672346c85400
|
4
|
+
data.tar.gz: 5afb557723706f69a06218b483b834bb86f9eb1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cc7185c859e475c3460c7f7f0e9a8f7f3fa5617f64cbbcf93c7255e897a9e1304a8d5cfe4e8038c29ea6a746cca81f977b306e45f38e08e868d85b0142a12fb
|
7
|
+
data.tar.gz: 75eff8b37ee76c18d952cfa2de40c797addac6b4f5cec97871d633970b182e6fbb964cf1e59f11cd6851156f3b85034c1f68bd70977c5395a92d2633de521a35
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 0.9.3 - July 20th, 2016
|
2
|
+
|
3
|
+
- Added support for {YARD::Server::RackAdapter} to be mounted under prefix URIs.
|
4
|
+
- Fixed regression in `yard server -g` that caused static file assets on index
|
5
|
+
page to return 404 errors.
|
6
|
+
- Fixed regression in `yard server -g` index page that disabled scrolling and
|
7
|
+
caused other HTML rendering glitches.
|
8
|
+
|
1
9
|
# 0.9.2 - July 19th, 2016
|
2
10
|
|
3
11
|
- Added `yard config --gem-install-[yri|yard]` commands which auto-configure
|
data/Rakefile
CHANGED
@@ -6,6 +6,21 @@ YARD::VERSION.replace(ENV['YARD_VERSION']) if ENV['YARD_VERSION']
|
|
6
6
|
|
7
7
|
task :default => :travis_ci
|
8
8
|
|
9
|
+
desc "Publish gem"
|
10
|
+
task :publish do
|
11
|
+
ver = ENV['VERSION']
|
12
|
+
|
13
|
+
if ver.nil? || ver.empty?
|
14
|
+
fail "missing VERSION=x.y.z"
|
15
|
+
elsif ver < YARD::VERSION
|
16
|
+
fail "invalid version `#{ver}' (must be >= `#{YARD::VERSION}')"
|
17
|
+
end
|
18
|
+
|
19
|
+
file = "release-v#{ver}.tar.gz"
|
20
|
+
cmd = "bundle exec samus"
|
21
|
+
sh "#{cmd} build #{ver} && #{cmd} publish #{file} && rm #{file}"
|
22
|
+
end
|
23
|
+
|
9
24
|
desc "Builds the gem"
|
10
25
|
task :gem do
|
11
26
|
sh "gem build yard.gemspec"
|
data/lib/yard/autoload.rb
CHANGED
@@ -220,6 +220,7 @@ module YARD
|
|
220
220
|
autoload :RootRequestCommand, __p('server/commands/root_request_command')
|
221
221
|
autoload :SearchCommand, __p('server/commands/search_command')
|
222
222
|
autoload :StaticFileCommand, __p('server/commands/static_file_command')
|
223
|
+
autoload :StaticFileHelpers, __p('server/commands/static_file_helpers')
|
223
224
|
end
|
224
225
|
|
225
226
|
autoload :Adapter, __p('server/adapter')
|
@@ -87,7 +87,7 @@ module YARD
|
|
87
87
|
# of status, headers, and body wrapped in an array.
|
88
88
|
def call(request)
|
89
89
|
self.request = request
|
90
|
-
self.path ||= request.
|
90
|
+
self.path ||= request.path_info[1..-1]
|
91
91
|
self.headers = {'Content-Type' => 'text/html'}
|
92
92
|
self.body = ''
|
93
93
|
self.status = 200
|
@@ -96,9 +96,12 @@ module YARD
|
|
96
96
|
rescue FinishRequest
|
97
97
|
rescue NotFoundError => e
|
98
98
|
self.body = e.message if e.message != e.class.to_s
|
99
|
-
|
99
|
+
not_found
|
100
100
|
end
|
101
|
+
|
102
|
+
# keep this to support commands setting status manually.
|
101
103
|
not_found if status == 404
|
104
|
+
|
102
105
|
[status, headers, body.is_a?(Array) ? body : [body]]
|
103
106
|
end
|
104
107
|
|
@@ -158,7 +161,7 @@ module YARD
|
|
158
161
|
# @see StaticCaching
|
159
162
|
def cache(data)
|
160
163
|
if caching && adapter.document_root
|
161
|
-
path = File.join(adapter.document_root, request.
|
164
|
+
path = File.join(adapter.document_root, request.path_info.sub(/\.html$/, '') + '.html')
|
162
165
|
path = path.sub(%r{/\.html$}, '.html')
|
163
166
|
FileUtils.mkdir_p(File.dirname(path))
|
164
167
|
log.debug "Caching data to #{path}"
|
@@ -167,11 +170,12 @@ module YARD
|
|
167
170
|
self.body = data
|
168
171
|
end
|
169
172
|
|
170
|
-
# Sets the body and headers
|
171
|
-
#
|
173
|
+
# Sets the body and headers for a 404 response. Does not modify the
|
174
|
+
# body if already set.
|
172
175
|
#
|
173
176
|
# @return [void]
|
174
177
|
def not_found
|
178
|
+
self.status = 404
|
175
179
|
return unless body.empty?
|
176
180
|
self.body = "Not found: #{request.path}"
|
177
181
|
self.headers['Content-Type'] = 'text/plain'
|
@@ -1,6 +1,13 @@
|
|
1
1
|
module YARD
|
2
2
|
module Server
|
3
3
|
module Commands
|
4
|
+
class LibraryIndexOptions < CLI::YardocOptions
|
5
|
+
attr_accessor :adapter, :libraries
|
6
|
+
default_attr :template, :doc_server
|
7
|
+
default_attr :type, :library_list
|
8
|
+
default_attr :serialize, false
|
9
|
+
end
|
10
|
+
|
4
11
|
# Returns the index of libraries served by the server.
|
5
12
|
class LibraryIndexCommand < Base
|
6
13
|
attr_accessor :options
|
@@ -8,14 +15,10 @@ module YARD
|
|
8
15
|
def run
|
9
16
|
return unless path.empty?
|
10
17
|
|
11
|
-
self.options =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
:adapter => adapter,
|
16
|
-
:template => :doc_server,
|
17
|
-
:type => :library_list
|
18
|
-
)
|
18
|
+
self.options = LibraryIndexOptions.new
|
19
|
+
self.options.adapter = adapter
|
20
|
+
self.options.libraries = adapter.libraries
|
21
|
+
self.options.reset_defaults
|
19
22
|
render
|
20
23
|
end
|
21
24
|
end
|
@@ -3,23 +3,10 @@ module YARD
|
|
3
3
|
module Commands
|
4
4
|
# Serves requests from the root of the server
|
5
5
|
class RootRequestCommand < Base
|
6
|
-
|
7
|
-
favicon?
|
8
|
-
|
9
|
-
self.body = "Could not find: #{request.path}"
|
10
|
-
self.status = 404
|
11
|
-
end
|
6
|
+
include StaticFileHelpers
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
# Return an empty favicon.ico if it does not exist so that
|
16
|
-
# browsers don't complain.
|
17
|
-
def favicon?
|
18
|
-
return unless request.path == '/favicon.ico'
|
19
|
-
self.headers['Content-Type'] = 'image/png'
|
20
|
-
self.status = 200
|
21
|
-
self.body = ''
|
22
|
-
raise FinishRequest
|
8
|
+
def run
|
9
|
+
static_template_file? || favicon? || not_found
|
23
10
|
end
|
24
11
|
end
|
25
12
|
end
|
@@ -13,7 +13,7 @@ module YARD
|
|
13
13
|
def run
|
14
14
|
Registry.load_all
|
15
15
|
self.query = request.query['q']
|
16
|
-
redirect(
|
16
|
+
redirect(abs_url(adapter.router.docs_prefix, single_library ? library : '')) if query.nil? || query =~ /\A\s*\Z/
|
17
17
|
if found = Registry.at(query)
|
18
18
|
redirect(url_for(found))
|
19
19
|
end
|
@@ -28,7 +28,7 @@ module YARD
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def url_for(object)
|
31
|
-
|
31
|
+
abs_url(base_path(router.docs_prefix),
|
32
32
|
serializer.serialized_path(object))
|
33
33
|
end
|
34
34
|
|
@@ -1,11 +1,9 @@
|
|
1
|
-
require 'webrick/httputils'
|
2
|
-
|
3
1
|
module YARD
|
4
2
|
module Server
|
5
3
|
module Commands
|
6
4
|
# Serves static content when no other router matches a request
|
7
5
|
class StaticFileCommand < LibraryCommand
|
8
|
-
include
|
6
|
+
include StaticFileHelpers
|
9
7
|
|
10
8
|
DefaultMimeTypes['js'] = 'text/javascript'
|
11
9
|
|
@@ -16,27 +14,7 @@ module YARD
|
|
16
14
|
STATIC_PATHS = []
|
17
15
|
|
18
16
|
def run
|
19
|
-
|
20
|
-
|
21
|
-
file = nil
|
22
|
-
([adapter.document_root] + STATIC_PATHS.reverse).compact.each do |path_prefix|
|
23
|
-
file = File.join(path_prefix, path)
|
24
|
-
break if File.exist?(file)
|
25
|
-
file = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
# Search in default/fulldoc/html template if nothing in static asset paths
|
29
|
-
file ||= assets_template.find_file(path)
|
30
|
-
|
31
|
-
if file
|
32
|
-
ext = "." + (path[/\.(\w+)$/, 1] || "html")
|
33
|
-
headers['Content-Type'] = mime_type(ext, DefaultMimeTypes)
|
34
|
-
self.body = File.read(file)
|
35
|
-
return
|
36
|
-
end
|
37
|
-
|
38
|
-
self.body = "Could not find: #{request.path}"
|
39
|
-
self.status = 404
|
17
|
+
static_template_file? || not_found
|
40
18
|
end
|
41
19
|
end
|
42
20
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'webrick/httputils'
|
2
|
+
|
3
|
+
module YARD
|
4
|
+
module Server
|
5
|
+
module Commands
|
6
|
+
# Include this module to get access to {#static_template_file?}
|
7
|
+
# and {favicon?} helpers.
|
8
|
+
module StaticFileHelpers
|
9
|
+
include WEBrick::HTTPUtils
|
10
|
+
|
11
|
+
# Serves an empty favicon.
|
12
|
+
# @raise [FinishRequest] finalizes an empty body if the path matches
|
13
|
+
# /favicon.ico so browsers don't complain.
|
14
|
+
def favicon?
|
15
|
+
return unless request.path == '/favicon.ico'
|
16
|
+
self.headers['Content-Type'] = 'image/png'
|
17
|
+
self.status = 200
|
18
|
+
self.body = ''
|
19
|
+
raise FinishRequest
|
20
|
+
end
|
21
|
+
|
22
|
+
# Attempts to route a path to a static template file.
|
23
|
+
#
|
24
|
+
# @raise [FinishRequest] if a file was found and served
|
25
|
+
# @return [void]
|
26
|
+
def static_template_file?
|
27
|
+
# these consts were defined in StaticFileCommand originally
|
28
|
+
static_paths = StaticFileCommand::STATIC_PATHS
|
29
|
+
default_mime_types = StaticFileCommand::DefaultMimeTypes
|
30
|
+
|
31
|
+
assets_template = Templates::Engine.template(:default, :fulldoc, :html)
|
32
|
+
|
33
|
+
file = nil
|
34
|
+
([adapter.document_root] + static_paths.reverse).compact.each do |path_prefix|
|
35
|
+
file = File.join(path_prefix, path)
|
36
|
+
break if File.exist?(file)
|
37
|
+
file = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
# Search in default/fulldoc/html template if nothing in static asset paths
|
41
|
+
file ||= assets_template.find_file(path)
|
42
|
+
|
43
|
+
if file
|
44
|
+
ext = "." + (path[/\.(\w+)$/, 1] || "html")
|
45
|
+
headers['Content-Type'] = mime_type(ext, default_mime_types)
|
46
|
+
self.body = File.read(file)
|
47
|
+
raise FinishRequest
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -10,10 +10,10 @@ module YARD
|
|
10
10
|
def url_for(obj, anchor = nil, relative = false)
|
11
11
|
return '' if obj.nil?
|
12
12
|
return url_for_index if obj == '_index.html'
|
13
|
-
return
|
13
|
+
return abs_url(base_path(router.static_prefix), obj) if String === obj
|
14
14
|
url = super(obj, anchor, false)
|
15
15
|
return unless url
|
16
|
-
|
16
|
+
abs_url(base_path(router.docs_prefix), url)
|
17
17
|
end
|
18
18
|
|
19
19
|
# Modifies {Templates::Helpers::HtmlHelper#url_for_file} to return a URL instead
|
@@ -24,8 +24,9 @@ module YARD
|
|
24
24
|
if filename.is_a?(CodeObjects::ExtraFileObject)
|
25
25
|
filename = filename.filename
|
26
26
|
end
|
27
|
-
|
28
|
-
|
27
|
+
fname = filename.sub(%r{^#{@library.source_path.to_s}/}, '')
|
28
|
+
fname += "##{anchor}" if anchor && !anchor.empty?
|
29
|
+
abs_url(base_path(router.docs_prefix), 'file', fname)
|
29
30
|
end
|
30
31
|
|
31
32
|
# Modifies {Templates::Helpers::HtmlHelper#url_for_list} to return a URL
|
@@ -33,7 +34,7 @@ module YARD
|
|
33
34
|
# @param (see Templates::Helpers::HtmlHelper#url_for_list)
|
34
35
|
# @return (see Templates::Helpers::HtmlHelper#url_for_list)
|
35
36
|
def url_for_list(type)
|
36
|
-
|
37
|
+
abs_url(base_path(router.list_prefix), type.to_s)
|
37
38
|
end
|
38
39
|
|
39
40
|
# Returns the frames URL for the page
|
@@ -51,7 +52,13 @@ module YARD
|
|
51
52
|
# Returns the URL for the alphabetic index page
|
52
53
|
# @return (see Templates::Helpers::HtmlHelper#url_for_index)
|
53
54
|
def url_for_index
|
54
|
-
|
55
|
+
abs_url(base_path(router.docs_prefix), 'index')
|
56
|
+
end
|
57
|
+
|
58
|
+
# @param path_components [Array<String>] components of a URL
|
59
|
+
# @return [String] the absolute path from any mounted base URI.
|
60
|
+
def abs_url(*path_components)
|
61
|
+
File.join(router.request.script_name, *path_components)
|
55
62
|
end
|
56
63
|
|
57
64
|
# @example The base path for a library 'foo'
|
data/lib/yard/server/router.rb
CHANGED
@@ -101,7 +101,7 @@ module YARD
|
|
101
101
|
#
|
102
102
|
# @return [Array(Numeric,Hash,Array<String>)] the Rack-style response
|
103
103
|
# @return [nil] if no route is matched
|
104
|
-
def route(path = request.
|
104
|
+
def route(path = request.path_info)
|
105
105
|
path = path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '')
|
106
106
|
return route_index if path.empty? || path == docs_prefix
|
107
107
|
case path
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<form class="search" method="get" action="
|
1
|
+
<form class="search" method="get" action="<%= abs_url base_path(router.search_prefix) %>">
|
2
2
|
<input name="q" type="search" placeholder="Search" id="search_box" size="30" value="<%= h @query %>" />
|
3
3
|
</form>
|
4
4
|
<script type="text/javascript" charset="utf-8">
|
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
<div id="menu">
|
22
22
|
<% unless @single_library %>
|
23
|
-
<a href="
|
23
|
+
<a href="<%= abs_url router.docs_prefix %>" target="_top">Libraries</a> »
|
24
24
|
<span class="title"><%= @library.name %> <% if @library.version %><small>(<%= @library.version %>)</small><% end %></span>
|
25
25
|
<% end %>
|
26
26
|
<% if object.is_a?(CodeObjects::Base) && @file.nil? %>
|
@@ -35,4 +35,3 @@
|
|
35
35
|
<span class='title'><%= @breadcrumb_title %></span>
|
36
36
|
<% end %>
|
37
37
|
</div>
|
38
|
-
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<script type="text/javascript" charset="utf-8">
|
2
2
|
pathId = <%= @path ? @path.inspect : 'null' %>
|
3
3
|
relpath = '/';
|
4
|
-
docsPrefix = '<%= base_path(router.docs_prefix) %>';
|
5
|
-
listPrefix = '<%= base_path(router.list_prefix) %>';
|
6
|
-
searchPrefix = '<%= base_path(router.search_prefix) %>';
|
4
|
+
docsPrefix = '<%= abs_url base_path(router.docs_prefix) %>';
|
5
|
+
listPrefix = '<%= abs_url base_path(router.list_prefix) %>';
|
6
|
+
searchPrefix = '<%= abs_url base_path(router.search_prefix) %>';
|
7
7
|
</script>
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<script>
|
2
2
|
$(document.getElementById("<%= anchor_for(object) %>")).prepend(
|
3
|
-
'<a class="permalink" href="
|
3
|
+
'<a class="permalink" href="<%= abs_url base_path(router.docs_prefix) %>/<%= urlencode serializer.serialized_path(object) %>">permalink</a>');
|
4
4
|
</script>
|
@@ -1,25 +1,7 @@
|
|
1
1
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
2
2
|
<title>YARD Documentation Server <%= YARD::VERSION %> - Library Listing</title>
|
3
|
-
<link rel="stylesheet" href="
|
4
|
-
<link rel="stylesheet" href="
|
5
|
-
<script type="text/javascript" charset="utf-8" src="/js/jquery.js"></script>
|
6
|
-
<script type="text/javascript">
|
7
|
-
function framesLinks() {
|
8
|
-
$('#framelink').toggle(function() {
|
9
|
-
$(this).text('links with frames');
|
10
|
-
$('ul li a').each(function() {
|
11
|
-
$(this).attr('href', $(this).attr('href').replace(/\/frames$/, ''));
|
12
|
-
});
|
13
|
-
}, function() {
|
14
|
-
$(this).text('links without frames');
|
15
|
-
$('ul li a').each(function() {
|
16
|
-
$(this).attr('href', $(this).attr('href') + '/frames');
|
17
|
-
});
|
18
|
-
})
|
19
|
-
}
|
20
|
-
|
21
|
-
$(framesLinks);
|
22
|
-
</script>
|
3
|
+
<link rel="stylesheet" href="<%= abs_url('css', 'style.css') %>" type="text/css" media="screen" charset="utf-8" />
|
4
|
+
<link rel="stylesheet" href="<%= abs_url('css', 'custom.css') %>" type="text/css" media="screen" charset="utf-8" />
|
23
5
|
<style type="text/css" media="screen">
|
24
6
|
ul { list-style: circle inside none; padding: 0; }
|
25
7
|
li { font-size: 1.2em; line-height: 1.4em; padding: 3px 5px; }
|
@@ -3,10 +3,10 @@
|
|
3
3
|
<li class="r<%= @row = @row == 1 ? 2 : 1 %>">
|
4
4
|
<% library_versions = library_versions.dup %>
|
5
5
|
<% first_lib = library_versions.pop %>
|
6
|
-
<a href="
|
6
|
+
<a href="<%= abs_url(router.docs_prefix, first_lib.name) %>"><%= name %></a>
|
7
7
|
<% if first_lib.version %>
|
8
8
|
<small>(<%= first_lib.version %><% if library_versions.size > 0 %>,
|
9
|
-
<%= library_versions.reverse.map {|lib| "<a href=\"
|
9
|
+
<%= library_versions.reverse.map {|lib| "<a href=\"#{abs_url(router.docs_prefix, lib.to_s)}\">#{lib.version}</a>" }.join(', ') %><% end %>)</small>
|
10
10
|
<% end %>
|
11
11
|
</li>
|
12
12
|
<% end %>
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<h1>YARD Documentation Server <%= YARD::VERSION %></h1>
|
2
|
-
<h2>Library Listing
|
2
|
+
<h2>Library Listing</h2>
|
@@ -2,9 +2,9 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
|
-
<link rel="stylesheet" href="
|
6
|
-
<link rel="stylesheet" href="
|
7
|
-
<script type="text/javascript" charset="utf-8" src="
|
5
|
+
<link rel="stylesheet" href="<%= abs_url('css', 'style.css') %>" type="text/css" media="screen" charset="utf-8" />
|
6
|
+
<link rel="stylesheet" href="<%= abs_url('css', 'custom.css') %>" type="text/css" media="screen" charset="utf-8" />
|
7
|
+
<script type="text/javascript" charset="utf-8" src="<%= abs_url('js', 'jquery.js') %>"></script>
|
8
8
|
<script type="text/javascript" charset="utf-8">
|
9
9
|
function checkPage(process) {
|
10
10
|
$.ajax({cache: false, url: "<%= router.request.path %>" + (process ? "?process=true" : ""),
|
@@ -35,7 +35,7 @@
|
|
35
35
|
<body>
|
36
36
|
<div id="menu">
|
37
37
|
<% unless @single_library %>
|
38
|
-
<a href="
|
38
|
+
<a href="<%= abs_url(router.docs_prefix) %>" target="_top">Libraries</a> »
|
39
39
|
<span class="title"><%= @library.name %> <% if @library.version %><small>(<%= @library.version %>)</small><% end %></span>
|
40
40
|
<% end %>
|
41
41
|
</div>
|
@@ -46,7 +46,7 @@
|
|
46
46
|
<strong><%= @library.name %></strong> <% if @library.version %>(<%= @library.version %>)<% end %> is being processed.
|
47
47
|
You'll be redirected when the pages are built, it shouldn't take much longer.
|
48
48
|
</p>
|
49
|
-
<img src="
|
49
|
+
<img src="<%= abs_url('images', 'processing.gif') %>" align="center" />
|
50
50
|
</div>
|
51
51
|
</body>
|
52
|
-
</html>
|
52
|
+
</html>
|
data/lib/yard/version.rb
CHANGED
@@ -12,7 +12,7 @@ describe YARD::Server::Commands::Base do
|
|
12
12
|
describe "#cache" do
|
13
13
|
before do
|
14
14
|
@command = MyCacheCommand.new(:adapter => mock_adapter, :caching => true)
|
15
|
-
@command.request =
|
15
|
+
@command.request = mock_request(nil)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "does not cache if caching == false" do
|
@@ -30,7 +30,7 @@ describe YARD::Server::Commands::Base do
|
|
30
30
|
it "caches to path/to/file.html and create directories" do
|
31
31
|
expect(FileUtils).to receive(:mkdir_p).with('/public/path/to')
|
32
32
|
expect(File).to receive(:open).with('/public/path/to/file.html', anything)
|
33
|
-
@command.request.
|
33
|
+
@command.request.path_info = '/path/to/file.html'
|
34
34
|
@command.run
|
35
35
|
end
|
36
36
|
end
|
@@ -84,4 +84,4 @@ describe YARD::Server::Commands::Base do
|
|
84
84
|
expect(h['Foo']).to eq 'BAR'
|
85
85
|
end
|
86
86
|
end
|
87
|
-
end
|
87
|
+
end
|
@@ -10,7 +10,7 @@ describe YARD::Server::Commands::LibraryCommand do
|
|
10
10
|
allow(Registry).to receive(:save)
|
11
11
|
|
12
12
|
@cmd = LibraryCommand.new(:adapter => mock_adapter)
|
13
|
-
@request =
|
13
|
+
@request = mock_request("/foo", :xhr? => false)
|
14
14
|
@library = OpenStruct.new(:source_path => '.')
|
15
15
|
@cmd.library = @library
|
16
16
|
allow(@cmd).to receive(:load_yardoc).and_return(nil)
|
@@ -36,4 +36,4 @@ describe YARD::Server::Commands::LibraryCommand do
|
|
36
36
|
expect(@cmd.options[:markup]).to eq :rdoc
|
37
37
|
end
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
@@ -42,6 +42,13 @@ describe YARD::Server::DocServerHelper do
|
|
42
42
|
@helper.adapter.router.request.version_supplied = true
|
43
43
|
expect(@helper.url_for(P('A'))).to eq '/PREFIX/foo/bar/A'
|
44
44
|
end
|
45
|
+
|
46
|
+
it "uses script name prefix if set" do
|
47
|
+
@helper.adapter.router.request.script_name = '/mount/point'
|
48
|
+
@helper.library = LibraryVersion.new('foo', 'bar')
|
49
|
+
@helper.adapter.router.request.version_supplied = true
|
50
|
+
expect(@helper.url_for(P('A'))).to eq '/mount/point/PREFIX/foo/bar/A'
|
51
|
+
end
|
45
52
|
end
|
46
53
|
|
47
54
|
describe "#url_for_file" do
|
@@ -49,5 +56,16 @@ describe YARD::Server::DocServerHelper do
|
|
49
56
|
file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
|
50
57
|
expect(@helper.url_for_file(file)).to eq '/PREFIX/foo/file/a/b/FooBar.md'
|
51
58
|
end
|
59
|
+
|
60
|
+
it "properly links anchor portion" do
|
61
|
+
file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
|
62
|
+
expect(@helper.url_for_file(file, 'anchor')).to eq '/PREFIX/foo/file/a/b/FooBar.md#anchor'
|
63
|
+
end
|
64
|
+
|
65
|
+
it "uses script name prefix if set" do
|
66
|
+
@helper.adapter.router.request.script_name = '/mount/point'
|
67
|
+
file = CodeObjects::ExtraFileObject.new('a/b/FooBar.md', '')
|
68
|
+
expect(@helper.url_for_file(file)).to eq '/mount/point/PREFIX/foo/file/a/b/FooBar.md'
|
69
|
+
end
|
52
70
|
end
|
53
|
-
end
|
71
|
+
end
|
data/spec/server/router_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe YARD::Server::Router do
|
|
17
17
|
|
18
18
|
describe "#parse_library_from_path" do
|
19
19
|
def parse(*args)
|
20
|
-
@request.
|
20
|
+
@request.path_info = '/' + args.join('/')
|
21
21
|
@router = MyRouterSpecRouter.new(@adapter)
|
22
22
|
@router.request = @request
|
23
23
|
@router.parse_library_from_path(args.flatten)
|
@@ -49,8 +49,8 @@ describe YARD::Server::Router do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe "#route" do
|
52
|
-
def route_to(route, command,
|
53
|
-
req = mock_request(route)
|
52
|
+
def route_to(route, command, script_name = '')
|
53
|
+
req = mock_request(route, script_name)
|
54
54
|
router = MyRouterSpecRouter.new(@adapter)
|
55
55
|
expect(command).to receive(:new) do |*args|
|
56
56
|
@command = command.allocate
|
@@ -119,4 +119,4 @@ describe YARD::Server::Router do
|
|
119
119
|
route_to('/mydocs/foo/notproject', RootRequestCommand)
|
120
120
|
end
|
121
121
|
end
|
122
|
-
end
|
122
|
+
end
|
data/spec/server/spec_helper.rb
CHANGED
@@ -12,6 +12,11 @@ def mock_adapter(opts = {})
|
|
12
12
|
OpenStruct.new(opts)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
class MockRequest < OpenStruct
|
16
|
+
def path; "#{script_name}#{path_info}" end
|
17
|
+
end
|
18
|
+
|
19
|
+
def mock_request(path_info = '/', script_name = '', extra_env = {})
|
20
|
+
opts = { :path_info => path_info, :script_name => script_name }
|
21
|
+
MockRequest.new(extra_env.merge(opts))
|
17
22
|
end
|
@@ -5,7 +5,7 @@ describe YARD::Server::StaticCaching do
|
|
5
5
|
|
6
6
|
describe "#check_static_cache" do
|
7
7
|
def adapter; @adapter ||= mock_adapter end
|
8
|
-
def request; @request ||=
|
8
|
+
def request; @request ||= MockRequest.new end
|
9
9
|
|
10
10
|
it "returns nil if document root is not set" do
|
11
11
|
adapter.document_root = nil
|
@@ -13,7 +13,7 @@ describe YARD::Server::StaticCaching do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "reads a file from document root if path matches file on system" do
|
16
|
-
request.
|
16
|
+
request.path_info = '/hello/world.html'
|
17
17
|
expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true)
|
18
18
|
expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body')
|
19
19
|
s, h, b = *check_static_cache
|
@@ -22,7 +22,7 @@ describe YARD::Server::StaticCaching do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "reads a file if path matches file on system + .html" do
|
25
|
-
request.
|
25
|
+
request.path_info = '/hello/world'
|
26
26
|
expect(File).to receive(:file?).with('/public/hello/world.html').and_return(true)
|
27
27
|
expect(File).to receive(:open).with('/public/hello/world.html', anything).and_return('body')
|
28
28
|
s, h, b = *check_static_cache
|
@@ -31,9 +31,16 @@ describe YARD::Server::StaticCaching do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns nil if no matching file is found" do
|
34
|
-
request.
|
34
|
+
request.path_info = '/hello/foo'
|
35
35
|
expect(File).to receive(:file?).with('/public/hello/foo.html').and_return(false)
|
36
36
|
expect(check_static_cache).to eq nil
|
37
37
|
end
|
38
|
+
|
39
|
+
it "adds mount point to cache location" do
|
40
|
+
request.path_info = '/hello/world.html'
|
41
|
+
request.script_name = '/mount/point'
|
42
|
+
expect(File).to receive(:file?).with('/public/mount/point/hello/world.html').and_return(false)
|
43
|
+
expect(check_static_cache).to eq nil
|
44
|
+
end
|
38
45
|
end
|
39
|
-
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loren Segal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
YARD is a documentation generation tool for the Ruby programming language.
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- lib/yard/server/commands/root_request_command.rb
|
222
222
|
- lib/yard/server/commands/search_command.rb
|
223
223
|
- lib/yard/server/commands/static_file_command.rb
|
224
|
+
- lib/yard/server/commands/static_file_helpers.rb
|
224
225
|
- lib/yard/server/doc_server_helper.rb
|
225
226
|
- lib/yard/server/doc_server_serializer.rb
|
226
227
|
- lib/yard/server/library_version.rb
|
@@ -235,9 +236,9 @@ files:
|
|
235
236
|
- lib/yard/server/templates/default/layout/html/setup.rb
|
236
237
|
- lib/yard/server/templates/default/method_details/html/permalink.erb
|
237
238
|
- lib/yard/server/templates/default/method_details/html/setup.rb
|
238
|
-
- lib/yard/server/templates/doc_server/library_list/html/contents.erb
|
239
239
|
- lib/yard/server/templates/doc_server/library_list/html/headers.erb
|
240
240
|
- lib/yard/server/templates/doc_server/library_list/html/library_list.erb
|
241
|
+
- lib/yard/server/templates/doc_server/library_list/html/listing.erb
|
241
242
|
- lib/yard/server/templates/doc_server/library_list/html/setup.rb
|
242
243
|
- lib/yard/server/templates/doc_server/library_list/html/title.erb
|
243
244
|
- lib/yard/server/templates/doc_server/processing/html/processing.erb
|