Class: Jekyll::GeneratorSingleSource::DocNavConfig
- Inherits:
-
Object
- Object
- Jekyll::GeneratorSingleSource::DocNavConfig
- Defined in:
- lib/jekyll/generator-single-source/doc_nav_config.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #assume_generated? ⇒ Boolean
- #config ⇒ Object
- #generate_pages ⇒ Object
-
#initialize(i18n_file:, site:) ⇒ DocNavConfig
constructor
A new instance of DocNavConfig.
- #items ⇒ Object
- #missing_translation? ⇒ Boolean
- #nav_items_in_locale(locale) ⇒ Object
- #product ⇒ Object
- #release ⇒ Object
- #skip_generation? ⇒ Boolean
- #versions ⇒ Object
Constructor Details
#initialize(i18n_file:, site:) ⇒ DocNavConfig
Returns a new instance of DocNavConfig.
8 9 10 11 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 8 def initialize(i18n_file:, site:) @i18n_file = i18n_file @site = site end |
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
6 7 8 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 6 def site @site end |
Instance Method Details
#assume_generated? ⇒ Boolean
23 24 25 26 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 23 def assume_generated? # Assume that the whole file should be treated as generated config['assume_generated'].nil? || config['assume_generated'] end |
#config ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 54 def config @config ||= begin config = NavConfig::Base.process(@i18n_file.full_file_path_in_default_locale) Jekyll.logger.debug("generated config: #{config.to_json}") config end end |
#generate_pages ⇒ Object
48 49 50 51 52 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 48 def generate_pages return if skip_generation? items.map(&:generate_pages) end |
#items ⇒ Object
28 29 30 31 32 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 28 def items @items ||= (config.fetch('items', []) + ([config['unlisted']])) .flatten.compact .map { |i| DocNavItem::Base.make_for(i, self) } end |
#missing_translation? ⇒ Boolean
13 14 15 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 13 def missing_translation? @i18n_file.missing_translation? end |
#nav_items_in_locale(locale) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 62 def nav_items_in_locale(locale) @nav_items_in_locale ||= Hash.new do |h, key| h[key] = if key == I18n.default_locale.to_s config else NavConfig::Base.process(@i18n_file.full_file_path_in_locale) end end @nav_items_in_locale[locale] end |
#product ⇒ Object
34 35 36 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 34 def product @product ||= config['product'] end |
#release ⇒ Object
38 39 40 41 42 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 38 def release @release ||= edition.releases.detect do |r| r.value == config['release'] end end |
#skip_generation? ⇒ Boolean
17 18 19 20 21 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 17 def skip_generation? # skip if release is not available because it # was skipped using an ENV variable !(config.is_a?(Hash) && config['generate']) || release.nil? end |
#versions ⇒ Object
44 45 46 |
# File 'lib/jekyll/generator-single-source/doc_nav_config.rb', line 44 def versions @versions ||= release.versions end |