diff --git a/CHANGELOG.md b/CHANGELOG.md index cf4f32e03..dbaab35e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## Master + +##### Breaking + +* None. + +##### Enhancements + +* Added support for custom templates: use the `-t`/`--template-directory` + argument to jazzy. + [JP Simard](https://github.com/jpsim) + [#20](https://github.com/realm/jazzy/issues/20) + +##### Bug Fixes + +* None. + + ## 0.2.1 ##### Breaking diff --git a/lib/jazzy/config.rb b/lib/jazzy/config.rb index 575f8710e..75102a751 100644 --- a/lib/jazzy/config.rb +++ b/lib/jazzy/config.rb @@ -2,6 +2,7 @@ require 'pathname' require 'uri' +require 'jazzy/doc' require 'jazzy/podspec_documenter' require 'jazzy/source_declaration/access_control_level' @@ -29,6 +30,7 @@ class Config attr_accessor :docset_path attr_accessor :source_directory attr_accessor :excluded_files + attr_accessor :template_directory def initialize PodspecDocumenter.configure(self, Dir['*.podspec{,.json}'].first) @@ -44,12 +46,18 @@ def initialize self.skip_undocumented = false self.source_directory = Pathname.pwd self.excluded_files = [] + self.template_directory = Pathname(__FILE__).parent + 'templates' end def podspec=(podspec) @podspec = PodspecDocumenter.configure(self, podspec) end + def template_directory=(template_directory) + @template_directory = template_directory + Doc.template_path = template_directory + end + # rubocop:disable Metrics/MethodLength def self.parse! config = new @@ -161,6 +169,11 @@ def self.parse! config.source_directory = Pathname(source_directory) end + opt.on('t', '--template-directory DIRPATH', 'The directory that ' \ + 'contains the mustache templates to use') do |template_directory| + config.template_directory = Pathname(template_directory) + end + opt.on('--readme FILEPATH', 'The path to a markdown README file') do |readme| config.readme_path = Pathname(readme) diff --git a/lib/jazzy/doc.rb b/lib/jazzy/doc.rb index 45fcbb892..3288ba33a 100755 --- a/lib/jazzy/doc.rb +++ b/lib/jazzy/doc.rb @@ -1,11 +1,12 @@ require 'date' require 'pathname' +require 'mustache' require 'jazzy/gem_version' module Jazzy class Doc < Mustache - self.template_path = Pathname(__FILE__).parent.parent + self.template_name = 'doc' def date # Fake date is used to keep integration tests consistent diff --git a/lib/jazzy/doc.mustache b/lib/jazzy/templates/doc.mustache similarity index 89% rename from lib/jazzy/doc.mustache rename to lib/jazzy/templates/doc.mustache index 336e5629d..454c91b90 100755 --- a/lib/jazzy/doc.mustache +++ b/lib/jazzy/templates/doc.mustache @@ -13,7 +13,7 @@ {{/dash_type}} - {{> jazzy/partials/header}} + {{> header}}