Class: Jekyll::GeneratorSingleSource::GeneratorConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/generator-single-source/generator_config.rb

Constant Summary collapse

CONFIG_KEY =
'jekyll-generator-single-source'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ GeneratorConfig

Returns a new instance of GeneratorConfig.



10
11
12
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 10

def initialize(site)
  @site = site
end

Instance Attribute Details

#siteObject (readonly)

Returns the value of attribute site.



8
9
10
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 8

def site
  @site
end

Instance Method Details

#base_dest_pathObject



36
37
38
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 36

def base_dest_path
  config['base_dest_path']
end

#build_docs_nav(edition:, release: nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 40

def build_docs_nav(edition:, release: nil)
  file = release.nil? ? "docs_nav_#{edition}.yml" :"docs_nav_#{edition}_#{release}.yml"
  i18n_file = I18nFile.new(
    file: file,
    src_path: config.fetch('docs_nav_folder'),
    locale: @site.config['locale'],
    site:
  )

  DocNavConfig.new(i18n_file: i18n_file, site: @site)
end

#docs_nav_folderObject



28
29
30
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 28

def docs_nav_folder
  File.expand_path(config.fetch('docs_nav_folder'), @site.source)
end

#editionsObject



14
15
16
17
18
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 14

def editions
  @editions ||= SafeYAML.load(File.read(
    File.expand_path(versions_file, @site.source)
  )).group_by { |e| e['edition'] }
end

#layoutObject



20
21
22
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 20

def layout
  config['layout'] || 'docs-v2'
end

#multiple_products?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 32

def multiple_products?
  !!config.fetch('multiple_products', true)
end

#versions_fileObject



24
25
26
# File 'lib/jekyll/generator-single-source/generator_config.rb', line 24

def versions_file
  config['versions_file']
end