Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f374d4
commit d2f5a70
Showing
8 changed files
with
158 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
module Pod | ||
class DocsGenerator | ||
attr_reader :pod, :specification, :target_path, :options | ||
|
||
def initialize(pod) | ||
@pod = pod | ||
@specification = pod.specification | ||
@target_path = pod.sandbox.root + "Documentation" + pod.name | ||
@options = pod.specification.documentation || {} | ||
end | ||
|
||
def appledoc (options) | ||
bin = `which appledoc`.strip | ||
if bin.empty? | ||
return | ||
end | ||
arguments = [] | ||
arguments += options | ||
arguments << '--print-settings' if Config.instance.verbose? | ||
arguments += self.files | ||
Open3.popen3('appledoc', *arguments) do |i, o, e| | ||
if Config.instance.verbose? | ||
puts o.read.chomp | ||
puts e.read.chomp | ||
else | ||
# TODO: This is needed otherwise appledoc will not install the doc set | ||
# This is a work around related to poor understanding of the IO class. | ||
o.read | ||
e.read | ||
end | ||
end | ||
end | ||
|
||
def generate_appledoc_options | ||
project_company = @specification.authors ? @specification.authors.keys.join(', ') : 'no-company' | ||
options = ['--project-name', @specification.to_s, | ||
'--project-company', project_company, | ||
'--docset-copyright', project_company, | ||
'--company-id', 'org.cocoapods', | ||
'--ignore', '.m'] | ||
options += ['--docset-desc', @specification.description] if @specification.description | ||
['README.md', 'README.mdown', 'README.markdown','README'].each do |f| | ||
if File.file?(@pod.root + f) | ||
options += ['--index-desc', f] | ||
break | ||
end | ||
end | ||
options += @options[:appledoc] if @options[:appledoc] | ||
options | ||
|
||
end | ||
|
||
def files | ||
@pod.absolute_source_files | ||
end | ||
|
||
def generate(install = false) | ||
options = generate_appledoc_options | ||
options += ['--output', @target_path] | ||
options << '--keep-intermediate-files' | ||
options << '--no-create-docset' unless install | ||
@target_path.mkpath | ||
@pod.chdir do | ||
appledoc(options) | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
require File.expand_path('../../spec_helper', __FILE__) | ||
|
||
|
||
describe Pod::DocsGenerator do | ||
|
||
before do | ||
@sandbox = temporary_sandbox | ||
@pod = Pod::LocalPod.new(fixture_spec('banana-lib/BananaLib.podspec'), @sandbox) | ||
copy_fixture_to_pod('banana-lib', @pod) | ||
@doc_installer = Pod::DocsGenerator.new(@pod) | ||
@doc_installer.generate | ||
end | ||
|
||
it 'returns reads correctly the Pod documentation' do | ||
@doc_installer.options.should == { | ||
:html => 'http://banana-corp.local/banana-lib/docs.html', | ||
:appledoc => [ | ||
'--project-company', 'Banana Corp', | ||
'--company-id', 'com.banana', | ||
] | ||
} | ||
end | ||
|
||
it 'returns the Pod documentation documentation files' do | ||
@doc_installer.files.sort.should == [ | ||
@pod.root + "Classes/Banana.m", | ||
@pod.root + "Classes/Banana.h", | ||
].sort | ||
end | ||
|
||
it 'returns the Pod documentation options' do | ||
@doc_installer.generate_appledoc_options.should == [ | ||
"--project-name", "BananaLib (1.0)", | ||
"--project-company", "Monkey Boy, Banana Corp", | ||
"--docset-copyright", "Monkey Boy, Banana Corp", | ||
"--company-id", "org.cocoapods", | ||
"--ignore", ".m", | ||
"--docset-desc", "Full of chunky bananas.", | ||
"--index-desc", "README", | ||
"--project-company", "Banana Corp", | ||
"--company-id", "com.banana" | ||
] | ||
end | ||
|
||
it 'it creates the documenation directory' do | ||
File.directory?(@sandbox.root + "Documentation").should.be.true | ||
end | ||
|
||
it 'it creates the html' do | ||
File.directory?(@sandbox.root + "Documentation/BananaLib/html").should.be.true | ||
end | ||
end | ||
|