Class: Jazzy::SourceHost::GitHub

Inherits:
Object
  • Object
show all
Includes:
Config::Mixin
Defined in:
lib/jazzy/source_host.rb

Overview

Use GitHub as the default behaviour.

Direct Known Subclasses

BitBucket, GitLab

Instance Method Summary collapse

Methods included from Config::Mixin

#config

Instance Method Details

#extensionObject

Jazzy extension with logo



27
28
29
# File 'lib/jazzy/source_host.rb', line 27

def extension
  name.downcase
end

#imageObject

Logo image filename within extension



32
33
34
# File 'lib/jazzy/source_host.rb', line 32

def image
  'gh.png'
end

#item_url(item) ⇒ Object

URL to link to from a SourceDeclaration. Compare using ‘realpath` because `item.file` comes out of SourceKit/etc.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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

#nameObject

Human readable name, appears in UI



22
23
24
# File 'lib/jazzy/source_host.rb', line 22

def name
  'GitHub'
end

#urlObject

URL to link to from logo



37
38
39
# File 'lib/jazzy/source_host.rb', line 37

def url
  config.source_host_url
end