diff --git a/README.md b/README.md index 2a796440..a4b65b3f 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,15 @@ DevDocs requires Ruby 2.3.0, libcurl, and a JavaScript runtime supported by [Exe git clone https://github.com/Thibaut/devdocs.git && cd devdocs gem install bundler bundle install -thor docs:download --all +thor docs:download --default rackup ``` Finally, point your browser at [localhost:9292](http://localhost:9292) (the first request will take a few seconds to compile the assets). You're all set. -The `thor docs:download` command is used to download/update individual documentations (e.g. `thor docs:download html css`), or all at the same time (using the `--all` option). You can see the list of available documentations by running `thor docs:list`. +The `thor docs:download` command is used to download pre-generated documentations from DevDocs's servers (e.g. `thor docs:download html css`). You can see the list of available documentations and versions by running `thor docs:list`. To update all downloaded documentations, run `thor docs:download --installed`. -**Note:** there is currently no update mechanism other than `git pull origin master` to update the code and `thor docs:download` to download the latest version of the docs. To stay informed about new releases, be sure to [watch](https://github.com/Thibaut/devdocs/subscription) this repository and/or subscribe to the [newsletter](http://eepurl.com/HnLUz). +**Note:** there is currently no update mechanism other than `git pull origin master` to update the code and `thor docs:download --installed` to download the latest version of the docs. To stay informed about new releases, be sure to [watch](https://github.com/Thibaut/devdocs/subscription) this repository. Alternatively, DevDocs may be started as a Docker container: diff --git a/assets/javascripts/templates/pages/root_tmpl.coffee.erb b/assets/javascripts/templates/pages/root_tmpl.coffee.erb index 9349b6dc..90708207 100644 --- a/assets/javascripts/templates/pages/root_tmpl.coffee.erb +++ b/assets/javascripts/templates/pages/root_tmpl.coffee.erb @@ -10,8 +10,9 @@ app.templates.intro = """
  • Your local version of DevDocs won't self-update. Unless you're modifying the code, I recommend using the hosted version at devdocs.io.
  • Run thor docs:list to see all available documentations. -
  • Run thor docs:download --all to download/update all documentations. -
  • To be notified about new versions, don't forget to watch the repository on GitHub. +
  • Run thor docs:download <name> to download documentations. +
  • Run thor docs:download --installed to update all downloaded documentations. +
  • To be notified about new versions, don't forget to watch the repository on GitHub.
  • The issue tracker is the preferred channel for bug reports and feature requests. For everything else, use the mailing list.
  • Contributions are welcome. See the guidelines. diff --git a/lib/docs.rb b/lib/docs.rb index 046d75a8..c3354ba5 100644 --- a/lib/docs.rb +++ b/lib/docs.rb @@ -39,7 +39,19 @@ module Docs all.flat_map(&:versions) end - def self.find(name, version) + def self.defaults + %w(css dom dom_events html http javascript).map(&method(:find)) + end + + def self.installed + Dir["#{store_path}/**/index.json"]. + map { |file| file[%r{/([^/]*)/index\.json\z}, 1] }. + sort!. + map { |path| all_versions.find { |doc| doc.path == path } }. + compact + end + + def self.find(name, version = nil) const = name.camelize doc = const_get(const) diff --git a/lib/tasks/docs.thor b/lib/tasks/docs.thor index 1191b748..e304b5f7 100644 --- a/lib/tasks/docs.thor +++ b/lib/tasks/docs.thor @@ -94,11 +94,21 @@ class DocsCLI < Thor puts 'Done' end - desc 'download ( ... | --all)', 'Download documentations' + desc 'download ( ... | --default | --installed)', 'Download documentations' + option :default, type: :boolean + option :installed, type: :boolean option :all, type: :boolean def download(*names) require 'unix_utils' - docs = options[:all] ? Docs.all : find_docs(names) + docs = if options[:default] + Docs.defaults + elsif options[:installed] + Docs.installed + elsif options[:all] + Docs.all_versions + else + find_docs(names) + end assert_docs(docs) download_docs(docs) generate_manifest @@ -136,7 +146,7 @@ class DocsCLI < Thor def assert_docs(docs) if docs.empty? puts 'ERROR: called with no arguments.' - puts 'Run "thor docs:list" for usage patterns.' + puts 'Run "thor list" for usage patterns.' exit end end @@ -154,6 +164,7 @@ class DocsCLI < Thor require 'thread' length = docs.length + mutex = Mutex.new i = 0 (1..4).map do @@ -165,7 +176,7 @@ class DocsCLI < Thor rescue => e "FAILED (#{e.class}: #{e.message})" end - puts "(#{i += 1}/#{length}) #{doc.name} #{status}" + mutex.synchronize { puts "(#{i += 1}/#{length}) #{doc.name}#{ " #{doc.version}" if doc.version} #{status}" } end end end.map(&:join)