History

Merge pull request #1536 from richardkmichael/harmonized-version

Harmonized CLI command version notation

Simon Legner committed 5 years ago

Commit 1c3ceca2 parents f2b6607 64bf56e2 files · +19 −18Browse files

Unified · Split

2 files
  1. .github/CONTRIBUTING.md +2 −2
  2. lib/tasks/docs.thor +17 −16
.github/CONTRIBUTING.md+2−2
@@ -68,9 +68,9 @@ Follow the following steps to update documentations to their latest version: · 67 unmodified lines
682. Check if the license is still correct. If you update `options[:attribution]`, also update the documentation's entry in the array in [`assets/javascripts/templates/pages/about_tmpl.coffee`](../assets/javascripts/templates/pages/about_tmpl.coffee) to match.682. Check if the license is still correct. If you update `options[:attribution]`, also update the documentation's entry in the array in [`assets/javascripts/templates/pages/about_tmpl.coffee`](../assets/javascripts/templates/pages/about_tmpl.coffee) to match.
693. If the documentation has a custom icon, ensure the icons in <code>public/icons/*your_scraper_name*/</code> are up-to-date. If you pull the updated icon from a place different than the one specified in the `SOURCE` file, make sure to replace the old link with the new one.693. If the documentation has a custom icon, ensure the icons in <code>public/icons/*your_scraper_name*/</code> are up-to-date. If you pull the updated icon from a place different than the one specified in the `SOURCE` file, make sure to replace the old link with the new one.
704. If `self.links` is defined, check if the urls are still correct.704. If `self.links` is defined, check if the urls are still correct.
715. Generate the docs using `thor docs:generate <doc>`.715. Generate the docs using `thor docs:generate <doc@version>`.
726. Make sure `thor docs:generate` doesn't show errors and that the documentation still works well. Verify locally that everything works and that the categorization of entries is still good. Often, updates will require code changes in the scraper or its filters to tweak some new markup in the source website or to categorize new entries.726. Make sure `thor docs:generate` doesn't show errors and that the documentation still works well. Verify locally that everything works and that the categorization of entries is still good. Often, updates will require code changes in the scraper or its filters to tweak some new markup in the source website or to categorize new entries.
737. Repeat steps 5 and 6 for all versions that you updated. `thor docs:generate` accepts a `--version` argument to specify which version to scrape.737. Repeat steps 5 and 6 for all versions that you updated.
748. Create a PR and make sure to fill the checklist in section B of the PR template (remove the other sections).748. Create a PR and make sure to fill the checklist in section B of the PR template (remove the other sections).
75 75
76## Coding conventions76## Coding conventions
lib/tasks/docs.thor+17−16
@@ -40,8 +40,7 @@ class DocsCLI < Thor · 39 unmodified lines
40 TTY::Pager.new.page(output)40 TTY::Pager.new.page(output)
41 end41 end
42 42
43 desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)'43 desc 'page (<doc> | <doc@version>) [path] [--verbose] [--debug]', 'Generate a page (no indexing)'
44 option :version, type: :string
45 option :verbose, type: :boolean44 option :verbose, type: :boolean
46 option :debug, type: :boolean45 option :debug, type: :boolean
47 def page(name, path = '')46 def page(name, path = '')
@@ -56,7 +55,8 @@ class DocsCLI < Thor · 8 unmodified lines
56 Docs.install_report :filter, :request, :doc55 Docs.install_report :filter, :request, :doc
57 end56 end
58 57
59 if Docs.generate_page(name, options[:version], path)58 name, version = name.split(/@|~/)
59 if Docs.generate_page(name, version, path)
60 puts 'Done'60 puts 'Done'
61 else61 else
62 puts "Failed!#{' (try running with --debug for more information)' unless options[:debug]}"62 puts "Failed!#{' (try running with --debug for more information)' unless options[:debug]}"
@@ -65,8 +65,7 @@ class DocsCLI < Thor · 2 unmodified lines
65 handle_doc_not_found_error(error)65 handle_doc_not_found_error(error)
66 end66 end
67 67
68 desc 'generate <doc> [--version] [--verbose] [--debug] [--force] [--package]', 'Generate a documentation'68 desc 'generate (<doc> | <doc@version>) [--verbose] [--debug] [--force] [--package]', 'Generate a documentation'
69 option :version, type: :string
70 option :all, type: :boolean69 option :all, type: :boolean
71 option :verbose, type: :boolean70 option :verbose, type: :boolean
72 option :debug, type: :boolean71 option :debug, type: :boolean
@@ -80,7 +79,7 @@ class DocsCLI < Thor · 7 unmodified lines
80 79
81 require 'unix_utils' if options[:package]80 require 'unix_utils' if options[:package]
82 81
83 doc = Docs.find(name, options[:version])82 doc = find_doc(name)
84 83
85 if doc < Docs::UrlScraper && !options[:force]84 if doc < Docs::UrlScraper && !options[:force]
86 puts <<-TEXT.strip_heredoc85 puts <<-TEXT.strip_heredoc
@@ -119,7 +118,7 @@ class DocsCLI < Thor · 32 unmodified lines
119 puts 'Done'118 puts 'Done'
120 end119 end
121 120
122 desc 'download (<doc> <doc@version>... | --default | --installed | --all)', 'Download documentations'121 desc 'download (<doc> <doc@version>... | --default | --installed | --all)', 'Download documentation packages'
123 option :default, type: :boolean122 option :default, type: :boolean
124 option :installed, type: :boolean123 option :installed, type: :boolean
125 option :all, type: :boolean124 option :all, type: :boolean
@@ -142,7 +141,7 @@ class DocsCLI < Thor · 16 unmodified lines
142 handle_doc_not_found_error(error)141 handle_doc_not_found_error(error)
143 end142 end
144 143
145 desc 'package <doc> <doc@version>...', 'Package documentations'144 desc 'package <doc> <doc@version>...', 'Create documentation packages'
146 def package(*names)145 def package(*names)
147 require 'unix_utils'146 require 'unix_utils'
148 docs = find_docs(names)147 docs = find_docs(names)
@@ -267,17 +266,19 @@ class DocsCLI < Thor · 118 unmodified lines
267 266
268 private267 private
269 268
270 def find_docs(names)269 def find_doc(name)
271 names.flat_map do |name|270 name, version = name.split(/@|~/)
272 name, version = name.split(/@|~/)271 if version == 'all'
273 if version == 'all'272 Docs.find(name, false).versions
274 Docs.find(name, false).versions273 else
275 else274 Docs.find(name, version)
276 Docs.find(name, version)
277 end
278 end275 end
279 end276 end
280 277
278 def find_docs(names)
279 names.flat_map {|name| find_doc(name)}
280 end
281
281 def find_docs_by_slugs(slugs)282 def find_docs_by_slugs(slugs)
282 slugs.flat_map do |slug|283 slugs.flat_map do |slug|
283 slug, version = slug.split(/~/)284 slug, version = slug.split(/~/)