Ref #25.
Unified · Split
| @@ -34,6 +34,7 @@ group :docs do · 33 unmodified lines | |||
| 34 | gem 'html-pipeline' | 34 | gem 'html-pipeline' |
| 35 | gem 'progress_bar', require: false | 35 | gem 'progress_bar', require: false |
| 36 | gem 'unix_utils', require: false | 36 | gem 'unix_utils', require: false |
| 37 | gem 'tty-pager', require: false | ||
| 37 | end | 38 | end |
| 38 | 39 | ||
| 39 | group :test do | 40 | group :test do |
| @@ -78,6 +78,12 @@ GEM · 77 unmodified lines | |||
| 78 | thor (0.19.1) | 78 | thor (0.19.1) |
| 79 | thread_safe (0.3.5) | 79 | thread_safe (0.3.5) |
| 80 | tilt (2.0.2) | 80 | tilt (2.0.2) |
| 81 | tty-pager (0.3.0) | ||
| 82 | tty-screen (~> 0.4.0) | ||
| 83 | tty-which (~> 0.1.0) | ||
| 84 | verse (~> 0.4.0) | ||
| 85 | tty-screen (0.4.3) | ||
| 86 | tty-which (0.1.0) | ||
| 81 | typhoeus (0.8.0) | 87 | typhoeus (0.8.0) |
| 82 | ethon (>= 0.8.0) | 88 | ethon (>= 0.8.0) |
| 83 | tzinfo (1.2.2) | 89 | tzinfo (1.2.2) |
| @@ -85,7 +91,10 @@ GEM · 1 unmodified line | |||
| 85 | uglifier (2.7.2) | 91 | uglifier (2.7.2) |
| 86 | execjs (>= 0.3.0) | 92 | execjs (>= 0.3.0) |
| 87 | json (>= 1.8.0) | 93 | json (>= 1.8.0) |
| 94 | unicode_utils (1.4.0) | ||
| 88 | unix_utils (0.0.15) | 95 | unix_utils (0.0.15) |
| 96 | verse (0.4.0) | ||
| 97 | unicode_utils (~> 1.4.0) | ||
| 89 | yajl-ruby (1.2.1) | 98 | yajl-ruby (1.2.1) |
| 90 | 99 | ||
| 91 | PLATFORMS | 100 | PLATFORMS |
| @@ -113,7 +122,11 @@ DEPENDENCIES · 21 unmodified lines | |||
| 113 | sprockets-helpers | 122 | sprockets-helpers |
| 114 | thin | 123 | thin |
| 115 | thor | 124 | thor |
| 125 | tty-pager | ||
| 116 | typhoeus | 126 | typhoeus |
| 117 | uglifier | 127 | uglifier |
| 118 | unix_utils | 128 | unix_utils |
| 119 | yajl-ruby | 129 | yajl-ruby |
| 130 | |||
| 131 | BUNDLED WITH | ||
| 132 | 1.11.2 | ||
| @@ -38,6 +38,10 @@ module Docs · 37 unmodified lines | |||
| 38 | version.present? | 38 | version.present? |
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | def versioned? | ||
| 42 | @versions.presence | ||
| 43 | end | ||
| 44 | |||
| 41 | def name | 45 | def name |
| 42 | @name || super.try(:demodulize) | 46 | @name || super.try(:demodulize) |
| 43 | end | 47 | end |
| @@ -13,12 +13,17 @@ class DocsCLI < Thor · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | desc 'list', 'List available documentations' | 14 | desc 'list', 'List available documentations' |
| 15 | def list | 15 | def list |
| 16 | max_length = 0 | 16 | output = Docs.all.flat_map do |doc| |
| 17 | Docs.all. | 17 | name = doc.to_s.demodulize.underscore |
| 18 | map { |doc| [doc.to_s.demodulize.underscore, doc] }. | 18 | if doc.versioned? |
| 19 | to_h. | 19 | doc.versions.map { |_doc| "#{name}@#{_doc.version}" } |
| 20 | each { |name, doc| max_length = name.length if name.length > max_length }. | 20 | else |
| 21 | each { |name, doc| puts "#{name.rjust max_length + 1}: #{doc.versions.map { |v| v.release || '-' }.join(', ')}" } | 21 | name |
| 22 | end | ||
| 23 | end.join("\n") | ||
| 24 | |||
| 25 | require 'tty-pager' | ||
| 26 | TTY::Pager.new.page(output) | ||
| 22 | end | 27 | end |
| 23 | 28 | ||
| 24 | desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)' | 29 | desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)' |