@@ -239,20 +239,20 @@ def drop_uninteresting_tags(tags)
239
239
ret
240
240
end
241
241
242
- def expand_content ( content , path , get_f_content , generated )
243
- content . gsub ( /include::(?:{build_dir}\/ )?(\S +)\. txt \[ \] / ) do |_line |
242
+ def expand_content ( content , path , get_f_content , generated , ext )
243
+ content . gsub ( /include::(?:{build_dir}\/ )?(\S +)\. #{ ext } \[ \] / ) do |_line |
244
244
if File . dirname ( path ) == "."
245
- new_fname = "#{ $1} .txt "
245
+ new_fname = "#{ $1} .#{ ext } "
246
246
else
247
- new_fname = ( Pathname . new ( path ) . dirname + Pathname . new ( "#{ $1} .txt " ) ) . cleanpath . to_s
247
+ new_fname = ( Pathname . new ( path ) . dirname + Pathname . new ( "#{ $1} .#{ ext } " ) ) . cleanpath . to_s
248
248
end
249
249
if generated [ new_fname ]
250
250
new_content = generated [ new_fname ]
251
251
else
252
252
new_content = get_f_content . call ( new_fname )
253
253
if new_content
254
254
new_content = expand_content ( new_content . force_encoding ( "UTF-8" ) ,
255
- new_fname , get_f_content , generated )
255
+ new_fname , get_f_content , generated , ext )
256
256
else
257
257
puts "#{ new_fname } could not be resolved for expansion"
258
258
end
@@ -303,13 +303,14 @@ def index_doc(filter_tags, doc_list, get_content)
303
303
version_data [ "committed" ] = ts
304
304
version_data [ "date" ] = ts . strftime ( "%m/%d/%y" )
305
305
306
+ ext = Version . version_to_num ( version ) < 2_490_000 ? 'txt' : 'adoc'
306
307
tag_files = doc_list . call ( tree_sha )
307
308
doc_files = tag_files . select do |ent |
308
309
ent . first =~
309
310
/^Documentation\/ (
310
311
SubmittingPatches |
311
- MyFirstContribution.txt |
312
- MyFirstObjectWalk.txt |
312
+ MyFirstContribution.#{ ext } |
313
+ MyFirstObjectWalk.#{ ext } |
313
314
(
314
315
git.* |
315
316
everyday |
@@ -323,7 +324,7 @@ def index_doc(filter_tags, doc_list, get_content)
323
324
pull.* |
324
325
scalar |
325
326
technical\/ .*
326
- )\. txt )$/x
327
+ )\. #{ ext } )$/x
327
328
end
328
329
329
330
puts "Found #{ doc_files . size } entries"
@@ -384,10 +385,11 @@ def index_doc(filter_tags, doc_list, get_content)
384
385
385
386
doc_files . each do |entry |
386
387
path , sha = entry
388
+ txt_path = path . sub ( /\. adoc$/ , '.txt' )
387
389
ids = Set . new ( [ ] )
388
- docname = File . basename ( path , ".txt" )
390
+ docname = File . basename ( txt_path , ".txt" )
389
391
# TEMPORARY: skip the scalar technical doc until it has a non-overlapping name
390
- next if path == "Documentation/technical/scalar.txt"
392
+ next if txt_path == "Documentation/technical/scalar.txt"
391
393
next if doc_limit && path !~ /#{ doc_limit } /
392
394
393
395
doc_path = "#{ SITE_ROOT } external/docs/content/docs/#{ docname } "
@@ -399,19 +401,19 @@ def index_doc(filter_tags, doc_list, get_content)
399
401
} unless data [ "pages" ] [ docname ]
400
402
page_data = data [ "pages" ] [ docname ]
401
403
402
- content = expand_content ( ( get_content . call sha ) . force_encoding ( "UTF-8" ) , path , get_content_f , generated )
404
+ content = expand_content ( ( get_content . call sha ) . force_encoding ( "UTF-8" ) , path , get_content_f , generated , ext )
403
405
# Handle `link:../howto/maintain-git.txt`, which should point to
404
406
# a `.html` target instead
405
- content . gsub! ( /link:\. \. \/ howto\/ maintain-git\. txt / , 'link:../howto/maintain-git.html' )
407
+ content . gsub! ( /link:\. \. \/ howto\/ maintain-git\. #{ ext } / , 'link:../howto/maintain-git.html' )
406
408
# Handle `gitlink:` mistakes (the last of which was fixed in
407
409
# dbf47215e32b (rebase docs: fix "gitlink" typo, 2019-02-27))
408
410
content . gsub! ( /gitlink:/ , "linkgit:" )
409
411
# Handle erroneous `link:api-trace2.txt`, see 4945f046c7f5 (api docs:
410
412
# link to html version of api-trace2, 2022-09-16)
411
- content . gsub! ( /link:api-trace2.txt / , 'link:api-trace2.html' )
413
+ content . gsub! ( /link:api-trace2.#{ ext } / , 'link:api-trace2.html' )
412
414
# Handle `linkgit:git-config.txt` mistake, fixed in ad52148a7d0
413
415
# (Documentation: fix broken linkgit to git-config, 2016-03-21)
414
- content . gsub! ( /linkgit:git-config.txt / , 'linkgit:git-config' )
416
+ content . gsub! ( /linkgit:git-config.#{ ext } / , 'linkgit:git-config' )
415
417
content . gsub! ( /link:(?:technical\/ )?(\S *?)\. html(\# \S *?)?\[ (.*?)\] /m , "link:/docs/\\ 1\\ 2[\\ 3]" )
416
418
417
419
asciidoc = make_asciidoc ( content )
@@ -443,7 +445,9 @@ def index_doc(filter_tags, doc_list, get_content)
443
445
# HTML anchor on hdlist1 (i.e. command options)
444
446
html . gsub! ( /<dt class="hdlist1">(.*?)<\/ dt>/ ) do |_m |
445
447
text = $1. tr ( "^A-Za-z0-9-" , "" )
446
- anchor = "#{ path } -#{ text } "
448
+ # use txt_path for backward compatibility of already-existing
449
+ # deep links shared across the interwebs.
450
+ anchor = "#{ txt_path } -#{ text } "
447
451
# handle anchor collisions by appending -1
448
452
anchor += "-1" while ids . include? ( anchor )
449
453
ids . add ( anchor )
0 commit comments