Commit a9d33c21 authored by Fabio Pelosin's avatar Fabio Pelosin

[#149] Install or generate documentation

- introduced '--generate_documentation' '--install_documentation' command
  line options
- only doc installation/generation only if pod does not exists
parent fd976893
...@@ -69,6 +69,8 @@ module Pod ...@@ -69,6 +69,8 @@ module Pod
show_help = argv.option('--help') show_help = argv.option('--help')
Config.instance.silent = argv.option('--silent') Config.instance.silent = argv.option('--silent')
Config.instance.verbose = argv.option('--verbose') Config.instance.verbose = argv.option('--verbose')
Config.instance.generate_documentation = argv.option('--generate_documentation')
Config.instance.install_documentation = argv.option('--install_documentation')
command_class = case argv.shift_argument command_class = case argv.shift_argument
when 'install' then Install when 'install' then Install
......
...@@ -10,16 +10,20 @@ module Pod ...@@ -10,16 +10,20 @@ module Pod
@instance = instance @instance = instance
end end
attr_accessor :repos_dir, :project_root, :project_pods_root, :rootspec, :clean, :verbose, :silent attr_accessor :repos_dir, :project_root, :project_pods_root, :rootspec, :clean, :verbose, :silent, :install_documentation, :generate_documentation
alias_method :clean?, :clean alias_method :clean?, :clean
alias_method :verbose?, :verbose alias_method :verbose?, :verbose
alias_method :silent?, :silent alias_method :silent?, :silent
alias_method :install_documentation?, :install_documentation
alias_method :generate_documentation?, :generate_documentation
def initialize def initialize
@repos_dir = Pathname.new(File.expand_path("~/.cocoapods")) @repos_dir = Pathname.new(File.expand_path("~/.cocoapods"))
@clean = true @clean = true
@verbose = false @verbose = false
@silent = false @silent = false
@install_documentation = false
@generate_documentation = false
end end
def project_root def project_root
......
...@@ -51,7 +51,13 @@ module Pod ...@@ -51,7 +51,13 @@ module Pod
downloader = Downloader.for_pod(pod) downloader = Downloader.for_pod(pod)
downloader.download downloader.download
if config.generate_documentation && pod.can_generated_documentation
puts "Generating documentation for #{spec}" unless config.silent?
pods.each { |pod| pod.generate_documentation }
elsif config.install_documentation && pod.can_install_documentation
puts "Installing documentation for #{spec}" unless config.silent?
pods.each { |pod| pod.install_documentation }
end
if config.clean if config.clean
downloader.clean downloader.clean
pod.clean pod.clean
...@@ -82,9 +88,6 @@ module Pod ...@@ -82,9 +88,6 @@ module Pod
puts "* Writing Xcode project file to `#{@sandbox.project_path}'" if config.verbose? puts "* Writing Xcode project file to `#{@sandbox.project_path}'" if config.verbose?
project.save_as(@sandbox.project_path) project.save_as(@sandbox.project_path)
puts "Installing documentation" unless config.silent?
pods.each { |pod| pod.install_documentation }
end end
def run_post_install_hooks def run_post_install_hooks
......
...@@ -75,6 +75,28 @@ module Pod ...@@ -75,6 +75,28 @@ module Pod
end end
end end
def can_generated_documentation
specification.documentation && specification.documentation[:appledoc]
end
def can_install_documentation
specification.documentation && specification.documentation[:appledoc]
end
def generate_documentation
if specification.documentation
appledoc_options = specification.documentation[:appledoc]
if appledoc_options
appledoc_options += ['--output', "#{@sandbox.root}/doc", '--no-create-docset']
appledoc_options += source_files
Open3.popen3('appledoc', *appledoc_options ) { |stdin, stdout, stderr|
puts stdout.read.chomp
puts stderr.read.chomp
}
end
end
end
def install_documentation def install_documentation
if specification.documentation if specification.documentation
appledoc_options = specification.documentation[:appledoc] appledoc_options = specification.documentation[:appledoc]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment