Skip to content

Commit

Permalink
Merge pull request #257 from realm/jp-custom-templates
Browse files Browse the repository at this point in the history
[Templates] Added support for custom templates (addresses #20)
  • Loading branch information
jpsim committed Jul 7, 2015
2 parents 06ae1cd + f68bbe3 commit 4864cf8
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 8 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions lib/jazzy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'pathname'
require 'uri'

require 'jazzy/doc'
require 'jazzy/podspec_documenter'
require 'jazzy/source_declaration/access_control_level'

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/jazzy/doc.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions lib/jazzy/doc.mustache → lib/jazzy/templates/doc.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<a name="//apple_ref/swift/{{dash_type}}/{{name}}" class="dashAnchor"></a>
{{/dash_type}}
<a title="{{name}} {{kind}} Reference"></a>
{{> jazzy/partials/header}}
{{> header}}
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="{{path_to_root}}index.html">{{module_name}} Reference</a>
Expand All @@ -22,16 +22,16 @@
</p>
</div>
<div class="content-wrapper">
{{> jazzy/partials/nav}}
{{> nav}}
<article class="main-content">
<section>
<section class="section">
{{^hide_name}}<h1>{{name}}</h1>{{/hide_name}}
{{{overview}}}
</section>
{{> jazzy/partials/tasks}}
{{> tasks}}
</section>
{{> jazzy/partials/footer}}
{{> footer}}
</article>
</div>
</body>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<table class="graybox">
<tbody>
{{#parameters}}
{{> jazzy/partials/parameter}}
{{> parameter}}
{{/parameters}}
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#tasks.count}}
<section class="section task-group-section">
{{#tasks}}
{{> jazzy/partials/task}}
{{> task}}
{{/tasks}}
</section>
{{/tasks.count}}
2 changes: 1 addition & 1 deletion spec/integration_specs

0 comments on commit 4864cf8

Please sign in to comment.