Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Templates] Added support for custom templates (addresses #20) #257

Merged
merged 2 commits into from
Jul 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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