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