Permalink
Browse files

force appledoc to show undocumented classes and other updates

  • Loading branch information...
1 parent d2f5a70 commit ce731f92f2ff4a81ad56ed4592deff7e29e84305 @fabiopelosin fabiopelosin committed Mar 17, 2012
View
2 Rakefile
@@ -144,7 +144,7 @@ namespace :examples do
command = "xcodebuild -workspace '#{example.basename}.xcworkspace' -scheme '#{example.basename}'"
if (example + 'Podfile').read.include?('platform :ios')
# Specifically build against the simulator SDK so we don't have to deal with code signing.
- command << " -sdk /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk"
+ command << " -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk"
end
sh command
end
View
107 lib/cocoapods/docs_generator.rb
@@ -10,62 +10,97 @@ def initialize(pod)
@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
+ def name
+ @specification.to_s
+ end
+
+ def company
+ if @specification.authors
+ @specification.authors.keys.join(', ')
+ else
+ 'no-company'
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|
+ def copyright
+ company
+ end
+
+ def description
+ @specification.description || "Generated by CocoaPods."
+ end
+
+ def docs_id
+ 'org.cocoapods'
+ end
+
+ def files
+ @pod.absolute_source_files
+ end
+
+ def index_file
+ candidates = ['README.md', 'README.mdown', 'README.markdown','README']
+ candidates.each do |f|
if File.file?(@pod.root + f)
- options += ['--index-desc', f]
- break
+ return f
end
end
- options += @options[:appledoc] if @options[:appledoc]
- options
+ nil
+ end
+ def spec_appledoc_options
+ @options[:appledoc] || []
end
- def files
- @pod.absolute_source_files
+ def generate_appledoc_options
+ options = ['--project-name', name,
+ '--docset-desc', description,
+ '--project-company', company,
+ '--docset-copyright', copyright,
+ '--company-id', docs_id,
+ '--ignore', '.m',
+ '--keep-undocumented-objects',
+ '--keep-undocumented-members']
+
+ index = index_file
+ options += ['--index-desc', index] if index
+ options += spec_appledoc_options
end
def generate(install = false)
options = generate_appledoc_options
options += ['--output', @target_path]
- options << '--keep-intermediate-files'
- options << '--no-create-docset' unless install
+ options += ['--keep-intermediate-files']
+ options += ['--no-create-docset'] unless install
@target_path.mkpath
@pod.chdir do
appledoc(options)
end
end
+ def appledoc (options)
+ bin = `which appledoc`.strip
+ if bin.empty?
+ puts "\n[!] Skipping documenation generation because appledoc can't be found." if Config.instance.verbose?
+ return
+ end
+ arguments = []
+ arguments += options
+ arguments += ['--print-settings'] if Config.instance.verbose?
+ arguments += 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 may 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
+
end
end
View
BIN spec/fixtures/banana-lib.tar.gz
Binary file not shown.
View
6 spec/integration_spec.rb
@@ -139,11 +139,11 @@ def should_successfully_perform(command)
installer = SpecHelper::Installer.new(podfile)
installer.install!
- doc = (config.project_pods_root + 'Documentation/JSONKit/html/index.html').read
- doc.should.include?('JSONKit (1.4)')
-
+ File.directory?(config.project_pods_root + 'Documentation/JSONKit/html/')
doc = (config.project_pods_root + 'Documentation/SSToolkit/html/index.html').read
doc.should.include?('SSToolkit')
+
+
end
end
View
24 spec/unit/docs_generator_spec.rb
@@ -30,15 +30,17 @@
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"
+ '--project-name', 'BananaLib (1.0)',
+ '--docset-desc', 'Full of chunky bananas.',
+ '--project-company', 'Monkey Boy, Banana Corp',
+ '--docset-copyright', 'Monkey Boy, Banana Corp',
+ '--company-id', 'org.cocoapods',
+ '--ignore', '.m',
+ '--keep-undocumented-objects',
+ '--keep-undocumented-members',
+ '--index-desc', 'README',
+ '--project-company', 'Banana Corp',
+ '--company-id', 'com.banana'
]
end
@@ -48,6 +50,10 @@
it 'it creates the html' do
File.directory?(@sandbox.root + "Documentation/BananaLib/html").should.be.true
+ index = (@sandbox.root + 'Documentation/BananaLib/html/index.html').read
+ index.should.include?('BananaObj')
+ index = (@sandbox.root + 'Documentation/BananaLib/html/Classes/BananaObj.html').read
+ index.should.include?('Bananas are cool')
end
end

0 comments on commit ce731f9

Please sign in to comment.