Add --all option to docs:generate command

For generating all versions of a doc.
pull/382/head
Thibaut Courouble 9 years ago
parent fbbf9d5d09
commit caa2592e4b

@ -75,8 +75,9 @@ module Docs
find(name, version).store_page(store, page_id) find(name, version).store_page(store, page_id)
end end
def self.generate(name, version) def self.generate(doc, version = nil)
find(name, version).store_pages(store) doc = find(doc, version) unless doc.respond_to?(:store_pages)
doc.store_pages(store)
end end
def self.generate_manifest def self.generate_manifest

@ -52,6 +52,7 @@ class DocsCLI < Thor
desc 'generate <doc> [--version] [--verbose] [--debug] [--force] [--package]', 'Generate a documentation' desc 'generate <doc> [--version] [--verbose] [--debug] [--force] [--package]', 'Generate a documentation'
option :version, type: :string option :version, type: :string
option :all, type: :boolean
option :verbose, type: :boolean option :verbose, type: :boolean
option :debug, type: :boolean option :debug, type: :boolean
option :force, type: :boolean option :force, type: :boolean
@ -74,16 +75,20 @@ class DocsCLI < Thor
return unless yes? 'Proceed? (y/n)' return unless yes? 'Proceed? (y/n)'
end end
if Docs.generate(name, options[:version]) require 'unix_utils' if options[:package]
generate_manifest
if options[:package] doc = Docs.find(name, options[:version])
require 'unix_utils'
package_doc(Docs.find(name, options[:version])) result = if doc.version && options[:all]
doc.superclass.versions.all? do |_doc|
puts "==> #{_doc.version}"
generate_doc(_doc, package: options[:package]).tap { puts "\n" }
end end
puts 'Done'
else else
puts "Failed!#{' (try running with --debug for more information)' unless options[:debug]}" generate_doc(doc, package: options[:package])
end end
generate_manifest if result
rescue Docs::DocNotFound => error rescue Docs::DocNotFound => error
handle_doc_not_found_error(error) handle_doc_not_found_error(error)
end end
@ -169,6 +174,17 @@ class DocsCLI < Thor
puts 'Run "thor docs:list" to see the list of docs and versions.' puts 'Run "thor docs:list" to see the list of docs and versions.'
end end
def generate_doc(doc, package: nil)
if Docs.generate(doc)
package_doc(doc) if package
puts 'Done'
true
else
puts "Failed!#{' (try running with --debug for more information)' unless options[:debug]}"
false
end
end
def download_docs(docs) def download_docs(docs)
# Don't allow downloaded files to be created as StringIO # Don't allow downloaded files to be created as StringIO
require 'open-uri' require 'open-uri'

Loading…
Cancel
Save