Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Commit 16cd664

Browse files
committed
Add ability to display module descriptions pre-formatted
1 parent a19d812 commit 16cd664

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

lib/cli/module_info.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ def print_author
1313
def print_description
1414
print_std('Description:')
1515
indent_cursor do
16-
print_std(wrap_text(context.module.module_desc))
16+
if context.module.module_description_preformatted
17+
print_std(indent_without_wrap(context.module.module_desc))
18+
else
19+
print_std(wrap_text(context.module.module_desc))
20+
end
1721
end
1822
end
1923

lib/cli/output.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ def wrap_text(s, padding = 0, width = 78)
1212
.gsub(/\s+$/, '')
1313
end
1414

15+
def indent_without_wrap(s)
16+
s.gsub(/\n/, "\n#{@indent * @indent_level}")
17+
end
18+
1519
def print_std(msg)
1620
puts "#{@indent * @indent_level}#{msg}"
1721
end

lib/wpxf/core/module_info.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def update_info(info)
1717

1818
@info.merge!(info)
1919
@info[:date] = Date.parse(@info[:date].to_s)
20-
@info[:desc] = @info[:desc].split.join(' ')
20+
@info[:desc] = @info[:desc].gsub(/ +/, ' ')
2121
@info
2222
end
2323

@@ -45,5 +45,10 @@ def module_author
4545
def module_date
4646
@info[:date]
4747
end
48+
49+
# @return [Boolean] true if the description is preformatted.
50+
def module_description_preformatted
51+
@info[:desc_preformatted]
52+
end
4853
end
4954
end

0 commit comments

Comments
 (0)