Sha256: edea23a6b94ae71bee086ff362e222d914280f3e847b7cebabb34bd9d915ae26

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'date'
require 'pathname'
require 'mustache'

require 'jazzy/config'
require 'jazzy/gem_version'
require 'jazzy/jazzy_markdown'

module Jazzy
  class Doc < Mustache
    include Config::Mixin

    self.template_name = 'doc'

    def copyright
      copyright = config.copyright || (
        # Fake date is used to keep integration tests consistent
        date = ENV['JAZZY_FAKE_DATE'] || DateTime.now.strftime('%Y-%m-%d')
        year = date[0..3]
        "&copy; #{year} [#{config.author_name}](#{config.author_url}). " \
          "All rights reserved. (Last updated: #{date})"
      )
      Markdown.render_copyright(copyright).chomp
    end

    def jazzy_version
      # Fake version is used to keep integration tests consistent
      ENV['JAZZY_FAKE_VERSION'] || Jazzy::VERSION
    end

    def objc_first?
      config.objc_mode && config.hide_declarations != 'objc'
    end

    def language_stub
      objc_first? ? 'objc' : 'swift'
    end

    def module_version
      config.version_configured ? config.version : nil
    end

    def docs_title
      if config.title_configured
        config.title
      elsif config.version_configured
        # Fake version for integration tests
        version = ENV['JAZZY_FAKE_MODULE_VERSION'] || config.version
        "#{config.module_name} #{version} Docs"
      else
        "#{config.module_name} Docs"
      end
    end

    def enable_katex
      Markdown.has_math
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jazzy-0.14.4 lib/jazzy/doc.rb
jazzy-0.14.3 lib/jazzy/doc.rb
jazzy-0.14.2 lib/jazzy/doc.rb
jazzy-0.14.1 lib/jazzy/doc.rb
jazzy-0.14.0 lib/jazzy/doc.rb