class Jazzy::SourceHost::GitHub
Use GitHub
as the default behaviour.
Public Instance Methods
extension()
click to toggle source
Jazzy
extension with logo
# File lib/jazzy/source_host.rb, line 27 def extension name.downcase end
image()
click to toggle source
Logo image filename within extension
# File lib/jazzy/source_host.rb, line 32 def image 'gh.png' end
item_url(item)
click to toggle source
URL to link to from a SourceDeclaration
. Compare using ‘realpath` because `item.file` comes out of SourceKit/etc.
# File lib/jazzy/source_host.rb, line 44 def item_url(item) return unless files_url && item.file realpath = item.file.realpath return unless realpath.to_path.start_with?(local_root_realpath) path = realpath.relative_path_from(local_root_realpath) fragment = if item.start_line && (item.start_line != item.end_line) item_url_multiline_fragment(item.start_line, item.end_line) else item_url_line_fragment(item.line) end "#{files_url}/#{path}##{fragment}" end
name()
click to toggle source
Human readable name, appears in UI
# File lib/jazzy/source_host.rb, line 22 def name 'GitHub' end
url()
click to toggle source
URL to link to from logo
# File lib/jazzy/source_host.rb, line 37 def url config.source_host_url end
Private Instance Methods
files_url()
click to toggle source
# File lib/jazzy/source_host.rb, line 63 def files_url config.source_host_files_url end
item_url_line_fragment(line)
click to toggle source
Source host’s line numbering link scheme
# File lib/jazzy/source_host.rb, line 72 def item_url_line_fragment(line) "L#{line}" end
item_url_multiline_fragment(start_line, end_line)
click to toggle source
# File lib/jazzy/source_host.rb, line 76 def item_url_multiline_fragment(start_line, end_line) "L#{start_line}-L#{end_line}" end
local_root_realpath()
click to toggle source
# File lib/jazzy/source_host.rb, line 67 def local_root_realpath @local_root_realpath ||= config.source_directory.realpath.to_path end