Module: YARD::Server::DocServerHelper
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/yard/server/doc_server_helper.rb |
Overview
A module that is mixed into ::YARD::Templates::Template
in order to customize
certain template methods.
Instance Method Summary
- #abs_url(*path_components) ⇒ String
- #base_path(path) ⇒ String
- #mtime(file) ⇒ String
- #mtime_url(file) ⇒ String
- #router ⇒ 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.
-
#url_for_frameset ⇒ String
Returns the frames URL for the page.
-
#url_for_index ⇒ String
Returns the URL for the alphabetic index page.
-
#url_for_list(type) ⇒ String
Modifies Templates::Helpers::HtmlHelper#url_for_list to return a URL based on the list prefix instead of a HTML filename.
-
#url_for_main ⇒ String
Returns the main URL, first checking a readme and then linking to the index.
Instance Method Details
#abs_url(*path_components) ⇒ String
#base_path(path) ⇒ String
# File 'lib/yard/server/doc_server_helper.rb', line 69
def base_path(path) libname = router.request.version_supplied ? @library.to_s : @library.name path + (@single_library ? '' : "/#{libname}") end
#mtime(file) ⇒ String
#mtime_url(file) ⇒ String
#router ⇒ Router
# File 'lib/yard/server/doc_server_helper.rb', line 75
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.
# File 'lib/yard/server/doc_server_helper.rb', line 11
def url_for(obj, anchor = nil, relative = false) # rubocop:disable Lint/UnusedMethodArgument return '' if obj.nil? return url_for_index if obj == '_index.html' return abs_url(base_path(router.static_prefix), obj) if String === obj url = super(obj, anchor, false) return unless url abs_url(base_path(router.docs_prefix), url) end
#url_for_file(filename, anchor = nil) ⇒ String
Modifies Templates::Helpers::HtmlHelper#url_for_file to return a URL instead of a disk location.
# File 'lib/yard/server/doc_server_helper.rb', line 24
def url_for_file(filename, anchor = nil) if filename.is_a?(CodeObjects::ExtraFileObject) filename = filename.filename end fname = filename.sub(%r{^#{@library.source_path.to_s}/}, '') fname += "##{anchor}" if anchor && !anchor.empty? abs_url(base_path(router.docs_prefix), 'file', fname) end
#url_for_frameset ⇒ String
Returns the frames URL for the page
# File 'lib/yard/server/doc_server_helper.rb', line 43
def url_for_frameset .file ? url_for_file( .file) : url_for(object) end
#url_for_index ⇒ String
Returns the URL for the alphabetic index page
#url_for_list(type) ⇒ String
Modifies Templates::Helpers::HtmlHelper#url_for_list to return a URL based on the list prefix instead of a HTML filename.
#url_for_main ⇒ String
Returns the main URL, first checking a readme and then linking to the index
# File 'lib/yard/server/doc_server_helper.rb', line 49
def url_for_main .readme ? url_for_file( .readme) : url_for_index end