diff options
author | Jeff King <peff@peff.net> | 2022-10-05 16:59:18 +0300 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2022-10-05 16:59:18 +0300 |
commit | 86b8c74e749c10802d2d9507ea40a49da0847dd8 (patch) | |
tree | 3f304b52b33cde486b05b83f4ad8dec6f4018a81 | |
parent | 4509a5ae61f6f48baa494b406af2bc56985065a9 (diff) |
index_doc(): replace custom reject with grep_v
Suggested by rubocop, but this lets us avoid the double-block chaining,
which lets us avoid the extra intermediate variable added by 360faca8
(index: break up huge cmd_list construction, 2022-10-05).
-rw-r--r-- | lib/tasks/index.rake | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/tasks/index.rake b/lib/tasks/index.rake index 39bfb3b4..020f157a 100644 --- a/lib/tasks/index.rake +++ b/lib/tasks/index.rake @@ -208,19 +208,17 @@ def index_doc(filter_tags, doc_list, get_content) generated = {} cmd = tag_files.detect { |f| f.first =~ /command-list\.txt/ } if cmd - raw_list = + cmd_list = get_content .call(cmd.second) .match(/(### command list.*|# command name.*)/m)[0] .split("\n") - .reject do |l| - l =~ /^#/ + .grep_v(/^#/) + .each_with_object({}) do |cmd, list| + name, kind, attr = cmd.split(/\s+/) + list[kind] ||= [] + list[kind] << [name, attr] end - cmd_list = raw_list.each_with_object({}) do |cmd, list| - name, kind, attr = cmd.split(/\s+/) - list[kind] ||= [] - list[kind] << [name, attr] - end generated = cmd_list.keys.inject({}) do |list, category| links = cmd_list[category].map do |cmd, attr| cmd_file = tag_files.detect { |ent| ent.first == "Documentation/#{cmd}.txt" } |