Skip to content

Commit 4a6a4f2

Browse files
committed
blaat
1 parent 47960c2 commit 4a6a4f2

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

script/update-docs.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
DATA_FILE = "#{SITE_ROOT}external/docs/data/docs.yml"
1616
DOCS_EXTRA_FILE = "#{SITE_ROOT}data/docs_extra.yml"
1717

18+
def doc_ext(version)
19+
Version.version_to_num(version) < 2_490_000 ? 'txt' : 'adoc'
20+
end
21+
1822
def read_data
1923
if File.exist?(DATA_FILE)
2024
# `permitted_classes` required to allow running with Ruby v3.1
@@ -97,8 +101,7 @@ def index_l10n_doc(filter_tags, doc_list, get_content)
97101
l10n["tree_sha"] = tree_sha
98102
l10n["committed"] = ts
99103

100-
ext = ts < Time.parse('2025-03-03 18:00:56 +0100') ? 'txt' : 'adoc'
101-
104+
ext = doc_ext(name)
102105
tag_files = doc_list.call(tree_sha)
103106
doc_files = tag_files.select do |ent|
104107
ent.first =~
@@ -324,7 +327,7 @@ def index_doc(filter_tags, doc_list, get_content)
324327
version_data["committed"] = ts
325328
version_data["date"] = ts.strftime("%Y-%m-%d")
326329

327-
ext = Version.version_to_num(version) < 2_490_000 ? 'txt' : 'adoc'
330+
ext = doc_ext(version)
328331
tag_files = doc_list.call(tree_sha)
329332
doc_files = tag_files.select do |ent|
330333
ent.first =~
@@ -366,7 +369,7 @@ def index_doc(filter_tags, doc_list, get_content)
366369
end
367370
generated = cmd_list.keys.inject({}) do |list, category|
368371
links = cmd_list[category].map do |cmd, attr|
369-
cmd_file = tag_files.detect { |ent| ent.first == "Documentation/#{cmd}.txt" }
372+
cmd_file = tag_files.detect { |ent| ent.first == "Documentation/#{cmd}.#{ext}" }
370373
next unless cmd_file
371374

372375
content = get_content.call(cmd_file[1])
@@ -376,7 +379,7 @@ def index_doc(filter_tags, doc_list, get_content)
376379
"linkgit:#{cmd}[#{section}]::\n\t#{attr == 'deprecated' ? '(deprecated) ' : ''}#{match[1]}\n"
377380
end
378381
end
379-
list.merge!("Documentation/cmds-#{category}.txt" => links.compact.join("\n"))
382+
list.merge!("Documentation/cmds-#{category}.#{ext}" => links.compact.join("\n"))
380383
end
381384

382385
tools = tag_files.select { |ent| ent.first =~ /^mergetools\// }.map do |entry|
@@ -389,8 +392,8 @@ def index_doc(filter_tags, doc_list, get_content)
389392
end
390393

391394
can_merge, can_diff = tools.transpose.map(&:join)
392-
generated["Documentation/mergetools-diff.txt"] = can_diff
393-
generated["Documentation/mergetools-merge.txt"] = can_merge
395+
generated["Documentation/mergetools-diff.#{ext}"] = can_diff
396+
generated["Documentation/mergetools-merge.#{ext}"] = can_merge
394397

395398
get_content_f = proc do |name|
396399
content_file = tag_files.detect { |ent| ent.first == name }

0 commit comments

Comments
 (0)