@@ -239,20 +239,20 @@ def drop_uninteresting_tags(tags)
239239 ret
240240end
241241
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 |
244244 if File . dirname ( path ) == "."
245- new_fname = "#{ $1} .txt "
245+ new_fname = "#{ $1} .#{ ext } "
246246 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
248248 end
249249 if generated [ new_fname ]
250250 new_content = generated [ new_fname ]
251251 else
252252 new_content = get_f_content . call ( new_fname )
253253 if new_content
254254 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 )
256256 else
257257 puts "#{ new_fname } could not be resolved for expansion"
258258 end
@@ -303,13 +303,14 @@ def index_doc(filter_tags, doc_list, get_content)
303303 version_data [ "committed" ] = ts
304304 version_data [ "date" ] = ts . strftime ( "%m/%d/%y" )
305305
306+ ext = Version . version_to_num ( version ) < 2_490_000 ? 'txt' : 'adoc'
306307 tag_files = doc_list . call ( tree_sha )
307308 doc_files = tag_files . select do |ent |
308309 ent . first =~
309310 /^Documentation\/ (
310311 SubmittingPatches |
311- MyFirstContribution.txt |
312- MyFirstObjectWalk.txt |
312+ MyFirstContribution.#{ ext } |
313+ MyFirstObjectWalk.#{ ext } |
313314 (
314315 git.* |
315316 everyday |
@@ -323,7 +324,7 @@ def index_doc(filter_tags, doc_list, get_content)
323324 pull.* |
324325 scalar |
325326 technical\/ .*
326- )\. txt )$/x
327+ )\. #{ ext } )$/x
327328 end
328329
329330 puts "Found #{ doc_files . size } entries"
@@ -384,10 +385,11 @@ def index_doc(filter_tags, doc_list, get_content)
384385
385386 doc_files . each do |entry |
386387 path , sha = entry
388+ txt_path = path . sub ( /\. adoc$/ , '.txt' )
387389 ids = Set . new ( [ ] )
388- docname = File . basename ( path , ".txt" )
390+ docname = File . basename ( txt_path , ".txt" )
389391 # 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"
391393 next if doc_limit && path !~ /#{ doc_limit } /
392394
393395 doc_path = "#{ SITE_ROOT } external/docs/content/docs/#{ docname } "
@@ -399,19 +401,19 @@ def index_doc(filter_tags, doc_list, get_content)
399401 } unless data [ "pages" ] [ docname ]
400402 page_data = data [ "pages" ] [ docname ]
401403
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 )
403405 # Handle `link:../howto/maintain-git.txt`, which should point to
404406 # 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' )
406408 # Handle `gitlink:` mistakes (the last of which was fixed in
407409 # dbf47215e32b (rebase docs: fix "gitlink" typo, 2019-02-27))
408410 content . gsub! ( /gitlink:/ , "linkgit:" )
409411 # Handle erroneous `link:api-trace2.txt`, see 4945f046c7f5 (api docs:
410412 # 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' )
412414 # Handle `linkgit:git-config.txt` mistake, fixed in ad52148a7d0
413415 # (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' )
415417 content . gsub! ( /link:(?:technical\/ )?(\S *?)\. html(\# \S *?)?\[ (.*?)\] /m , "link:/docs/\\ 1\\ 2[\\ 3]" )
416418
417419 asciidoc = make_asciidoc ( content )
@@ -443,7 +445,9 @@ def index_doc(filter_tags, doc_list, get_content)
443445 # HTML anchor on hdlist1 (i.e. command options)
444446 html . gsub! ( /<dt class="hdlist1">(.*?)<\/ dt>/ ) do |_m |
445447 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 } "
447451 # handle anchor collisions by appending -1
448452 anchor += "-1" while ids . include? ( anchor )
449453 ids . add ( anchor )
0 commit comments