Skip to content

Commit 083b8e0

Browse files
committed
Improve "thor docs:list --packaged"
1 parent 3b39fa7 commit 083b8e0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/tasks/docs.thor

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ class DocsCLI < Thor
1515
option :packaged, type: :boolean
1616
def list
1717
if options[:packaged]
18-
names = Dir[File.join(Docs.store_path, '*.tar.gz')].map { |f| File.basename(f, '.tar.gz') }
19-
puts names
18+
slugs = Dir[File.join(Docs.store_path, '*.tar.gz')].map { |f| File.basename(f, '.tar.gz') }
19+
names = find_docs_by_slugs(slugs).map do |doc|
20+
name = if doc.version?
21+
"#{doc.superclass.to_s.demodulize.underscore}@#{doc.version}"
22+
else
23+
doc.to_s.demodulize.underscore
24+
end
25+
end
2026
else
2127
names = Docs.all.flat_map do |doc|
2228
name = doc.to_s.demodulize.underscore
@@ -26,12 +32,12 @@ class DocsCLI < Thor
2632
name
2733
end
2834
end
35+
end
2936

30-
output = names.join("\n")
37+
output = names.join("\n")
3138

32-
require 'tty-pager'
33-
TTY::Pager.new.page(output)
34-
end
39+
require 'tty-pager'
40+
TTY::Pager.new.page(output)
3541
end
3642

3743
desc 'page <doc> [path] [--version] [--verbose] [--debug]', 'Generate a page (no indexing)'

0 commit comments

Comments
 (0)