@@ -254,20 +254,20 @@ def drop_uninteresting_tags(tags)
254
254
ret
255
255
end
256
256
257
- def expand_content ( content , path , get_f_content , generated )
258
- content . gsub ( /include::(?:{build_dir}\/ )?(\S +)\. txt \[ \] / ) do |_line |
257
+ def expand_content ( content , path , get_f_content , generated , ext )
258
+ content . gsub ( /include::(?:{build_dir}\/ )?(\S +)\. #{ ext } \[ \] / ) do |_line |
259
259
if File . dirname ( path ) == "."
260
- new_fname = "#{ $1} .txt "
260
+ new_fname = "#{ $1} .#{ ext } "
261
261
else
262
- new_fname = ( Pathname . new ( path ) . dirname + Pathname . new ( "#{ $1} .txt " ) ) . cleanpath . to_s
262
+ new_fname = ( Pathname . new ( path ) . dirname + Pathname . new ( "#{ $1} .#{ ext } " ) ) . cleanpath . to_s
263
263
end
264
264
if generated [ new_fname ]
265
265
new_content = generated [ new_fname ]
266
266
else
267
267
new_content = get_f_content . call ( new_fname )
268
268
if new_content
269
269
new_content = expand_content ( new_content . force_encoding ( "UTF-8" ) ,
270
- new_fname , get_f_content , generated )
270
+ new_fname , get_f_content , generated , ext )
271
271
else
272
272
puts "#{ new_fname } could not be resolved for expansion"
273
273
end
@@ -319,6 +319,7 @@ def index_doc(filter_tags, doc_list, get_content)
319
319
version_data [ "committed" ] = ts
320
320
version_data [ "date" ] = ts . strftime ( "%m/%d/%y" )
321
321
322
+ ext = Version . version_to_num ( version ) < 2_490_000 ? 'txt' : 'adoc'
322
323
tag_files = doc_list . call ( tree_sha )
323
324
doc_files = tag_files . select do |ent |
324
325
ent . first =~
@@ -336,8 +337,8 @@ def index_doc(filter_tags, doc_list, get_content)
336
337
pull.* |
337
338
scalar |
338
339
technical\/ .*
339
- )\. txt )$/x or
340
- docs_extra [ "git_project_specific" ] . include? ( ent . first . sub ( /^Documentation\/ (.*?)(\. txt| \. adoc )?$/ , '\1' ) )
340
+ )\. #{ ext } )$/x or
341
+ docs_extra [ "git_project_specific" ] . include? ( ent . first . sub ( /^Documentation\/ (.*?)(\. #{ ext } )?$/ , '\1' ) )
341
342
end
342
343
343
344
puts "Found #{ doc_files . size } entries"
@@ -398,10 +399,11 @@ def index_doc(filter_tags, doc_list, get_content)
398
399
399
400
doc_files . each do |entry |
400
401
path , sha = entry
402
+ txt_path = path . sub ( /\. adoc$/ , '.txt' )
401
403
ids = Set . new ( [ ] )
402
- docname = File . basename ( path , ".txt" )
404
+ docname = File . basename ( txt_path , ".txt" )
403
405
# TEMPORARY: skip the scalar technical doc until it has a non-overlapping name
404
- next if path == "Documentation/technical/scalar.txt"
406
+ next if txt_path == "Documentation/technical/scalar.txt"
405
407
next if doc_limit && path !~ /#{ doc_limit } /
406
408
407
409
doc_path = "#{ SITE_ROOT } external/docs/content/docs/#{ docname } "
@@ -413,19 +415,19 @@ def index_doc(filter_tags, doc_list, get_content)
413
415
} unless data [ "pages" ] [ docname ]
414
416
page_data = data [ "pages" ] [ docname ]
415
417
416
- content = expand_content ( ( get_content . call sha ) . force_encoding ( "UTF-8" ) , path , get_content_f , generated )
418
+ content = expand_content ( ( get_content . call sha ) . force_encoding ( "UTF-8" ) , path , get_content_f , generated , ext )
417
419
# Handle `link:../howto/maintain-git.txt`, which should point to
418
420
# a `.html` target instead
419
- content . gsub! ( /link:\. \. \/ howto\/ maintain-git\. txt / , 'link:../howto/maintain-git.html' )
421
+ content . gsub! ( /link:\. \. \/ howto\/ maintain-git\. #{ ext } / , 'link:../howto/maintain-git.html' )
420
422
# Handle `gitlink:` mistakes (the last of which was fixed in
421
423
# dbf47215e32b (rebase docs: fix "gitlink" typo, 2019-02-27))
422
424
content . gsub! ( /gitlink:/ , "linkgit:" )
423
425
# Handle erroneous `link:api-trace2.txt`, see 4945f046c7f5 (api docs:
424
426
# link to html version of api-trace2, 2022-09-16)
425
- content . gsub! ( /link:api-trace2.txt / , 'link:api-trace2.html' )
427
+ content . gsub! ( /link:api-trace2.#{ ext } / , 'link:api-trace2.html' )
426
428
# Handle `linkgit:git-config.txt` mistake, fixed in ad52148a7d0
427
429
# (Documentation: fix broken linkgit to git-config, 2016-03-21)
428
- content . gsub! ( /linkgit:git-config.txt / , 'linkgit:git-config' )
430
+ content . gsub! ( /linkgit:git-config.#{ ext } / , 'linkgit:git-config' )
429
431
content . gsub! ( /link:(?:technical\/ )?(\S *?)\. html(\# \S *?)?\[ (.*?)\] /m , "link:/docs/\\ 1\\ 2[\\ 3]" )
430
432
431
433
asciidoc = make_asciidoc ( content )
@@ -457,7 +459,9 @@ def index_doc(filter_tags, doc_list, get_content)
457
459
# HTML anchor on hdlist1 (i.e. command options)
458
460
html . gsub! ( /<dt class="hdlist1">(.*?)<\/ dt>/ ) do |_m |
459
461
text = $1. tr ( "^A-Za-z0-9-" , "" )
460
- anchor = "#{ path } -#{ text } "
462
+ # use txt_path for backward compatibility of already-existing
463
+ # deep links shared across the interwebs.
464
+ anchor = "#{ txt_path } -#{ text } "
461
465
# handle anchor collisions by appending -1
462
466
anchor += "-1" while ids . include? ( anchor )
463
467
ids . add ( anchor )
0 commit comments