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
6868 2. 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.
6969 3. 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.
7070 4. If `self.links` is defined, check if the urls are still correct.
71−5. Generate the docs using `thor docs:generate <doc>`.
71+5. Generate the docs using `thor docs:generate <doc@version>`.
7272 6. 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.
73−7. Repeat steps 5 and 6 for all versions that you updated. `thor docs:generate` accepts a `--version` argument to specify which version to scrape.
73+7. Repeat steps 5 and 6 for all versions that you updated.
7474 8. Create a PR and make sure to fill the checklist in section B of the PR template (remove the other sections).
7575
7676 ## Coding conventions
lib/tasks/docs.thor+17−16
@@ -40,8 +40,7 @@ class DocsCLI < Thor · 39 unmodified lines
4040 TTY::Pager.new.page(output)
4141 end
4242
43− desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)'
44− option :version, type: :string
43+ desc 'page (<doc> | <doc@version>) [path] [--verbose] [--debug]', 'Generate a page (no indexing)'
4544 option :verbose, type: :boolean
4645 option :debug, type: :boolean
4746 def page(name, path = '')
@@ -56,7 +55,8 @@ class DocsCLI < Thor · 8 unmodified lines
5655 Docs.install_report :filter, :request, :doc
5756 end
5857
59− if Docs.generate_page(name, options[:version], path)
58+ name, version = name.split(/@|~/)
59+ if Docs.generate_page(name, version, path)
6060 puts 'Done'
6161 else
6262 puts "Failed!#{' (try running with --debug for more information)' unless options[:debug]}"
@@ -65,8 +65,7 @@ class DocsCLI < Thor · 2 unmodified lines
6565 handle_doc_not_found_error(error)
6666 end
6767
68− desc 'generate <doc> [--version] [--verbose] [--debug] [--force] [--package]', 'Generate a documentation'
69− option :version, type: :string
68+ desc 'generate (<doc> | <doc@version>) [--verbose] [--debug] [--force] [--package]', 'Generate a documentation'
7069 option :all, type: :boolean
7170 option :verbose, type: :boolean
7271 option :debug, type: :boolean
@@ -80,7 +79,7 @@ class DocsCLI < Thor · 7 unmodified lines
8079
8180 require 'unix_utils' if options[:package]
8281
83− doc = Docs.find(name, options[:version])
82+ doc = find_doc(name)
8483
8584 if doc < Docs::UrlScraper && !options[:force]
8685 puts <<-TEXT.strip_heredoc
@@ -119,7 +118,7 @@ class DocsCLI < Thor · 32 unmodified lines
119118 puts 'Done'
120119 end
121120
122− desc 'download (<doc> <doc@version>... | --default | --installed | --all)', 'Download documentations'
121+ desc 'download (<doc> <doc@version>... | --default | --installed | --all)', 'Download documentation packages'
123122 option :default, type: :boolean
124123 option :installed, type: :boolean
125124 option :all, type: :boolean
@@ -142,7 +141,7 @@ class DocsCLI < Thor · 16 unmodified lines
142141 handle_doc_not_found_error(error)
143142 end
144143
145− desc 'package <doc> <doc@version>...', 'Package documentations'
144+ desc 'package <doc> <doc@version>...', 'Create documentation packages'
146145 def package(*names)
147146 require 'unix_utils'
148147 docs = find_docs(names)
@@ -267,17 +266,19 @@ class DocsCLI < Thor · 118 unmodified lines
267266
268267 private
269268
270− def find_docs(names)
271− names.flat_map do |name|
272− name, version = name.split(/@|~/)
273− if version == 'all'
274− Docs.find(name, false).versions
275− else
276− Docs.find(name, version)
277− end
269+ def find_doc(name)
270+ name, version = name.split(/@|~/)
271+ if version == 'all'
272+ Docs.find(name, false).versions
273+ else
274+ Docs.find(name, version)
278275 end
279276 end
280277
278+ def find_docs(names)
279+ names.flat_map {|name| find_doc(name)}
280+ end
281+
281282 def find_docs_by_slugs(slugs)
282283 slugs.flat_map do |slug|
283284 slug, version = slug.split(/~/)