Module: YARD::Server::DocServerHelper
- Included in:
- Commands::FramesCommand
- Defined in:
- lib/yard/server/doc_server_helper.rb
Overview
A module that is mixed into Templates::Template in order to customize certain template methods.
Instance Method Summary collapse
-
#base_path(path) ⇒ String
The base URI for a library with an extra
path
prefix. -
#router ⇒ Router
Convenience method for accessing the router.
-
#url_for(obj, anchor = nil, relative = false) ⇒ String
Modifies Templates::Helpers::HtmlHelper#url_for to return a URL instead of a disk location.
-
#url_for_file(filename, anchor = nil) ⇒ String
Modifies Templates::Helpers::HtmlHelper#url_for_file to return a URL instead of a disk location.
Instance Method Details
#base_path(path) ⇒ String
Returns the base URI for a library with an extra path
prefix.
32 33 34 |
# File 'lib/yard/server/doc_server_helper.rb', line 32 def base_path(path) path + (@single_library ? '' : "/#{@library}") end |
#router ⇒ Router
Returns convenience method for accessing the router.
37 |
# File 'lib/yard/server/doc_server_helper.rb', line 37 def router; @adapter.router end |
#url_for(obj, anchor = nil, relative = false) ⇒ String
Modifies Templates::Helpers::HtmlHelper#url_for to return a URL instead of a disk location.
10 11 12 13 14 |
# File 'lib/yard/server/doc_server_helper.rb', line 10 def url_for(obj, anchor = nil, relative = false) return '' if obj.nil? return "/#{obj}" if String === obj super(obj, anchor, false) end |
#url_for_file(filename, anchor = nil) ⇒ String
Modifies Templates::Helpers::HtmlHelper#url_for_file to return a URL instead of a disk location.
20 21 22 23 24 25 26 |
# File 'lib/yard/server/doc_server_helper.rb', line 20 def url_for_file(filename, anchor = nil) if filename.is_a?(CodeObjects::ExtraFileObject) filename = filename.filename end "/#{base_path(router.docs_prefix)}/file/" + filename.sub(%r{^#{@library.source_path.to_s}/}, '') + (anchor ? "##{anchor}" : "") end |