@@ -245,13 +245,10 @@ function deploydocs(;
245
245
if deploy_decision. all_ok
246
246
deploy_branch = deploy_decision. branch
247
247
deploy_repo = deploy_decision. repo
248
- deploy_subfolder = deploy_decision. subfolder
249
248
deploy_is_preview = deploy_decision. is_preview
250
249
251
- # Non-versioned docs: deploy to root
252
- if versions === nothing && ! deploy_is_preview
253
- deploy_subfolder = nothing
254
- end
250
+ # this dispatches on `versions` for a non-public API for DocumenterVitepress
251
+ deploy_subfolder = determine_deploy_subfolder (deploy_decision, versions)
255
252
256
253
# Install dependencies when applicable.
257
254
if deps != = nothing
@@ -317,7 +314,6 @@ function deploydocs(;
317
314
return
318
315
end
319
316
320
-
321
317
function _get_inventory_version (objects_inv)
322
318
return open (objects_inv) do input
323
319
for line in eachline (input)
@@ -428,46 +424,8 @@ function git_push(
428
424
write (joinpath (dirname, " CNAME" ), cname)
429
425
end
430
426
431
- if versions === nothing
432
- # If the documentation is unversioned and deployed to root, we generate a
433
- # siteinfo.js file that would disable the version selector in the docs
434
- HTMLWriter. generate_siteinfo_file (deploy_dir, nothing )
435
- else
436
- # Generate siteinfo-file with DOCUMENTER_CURRENT_VERSION
437
- # Determine if this is a development version (e.g., "dev" or "latest")
438
- is_dev_version = (subfolder == devurl || subfolder == " latest" )
439
- HTMLWriter. generate_siteinfo_file (deploy_dir, subfolder, is_dev_version)
440
-
441
- # Expand the users `versions` vector
442
- entries, symlinks = HTMLWriter. expand_versions (dirname, versions)
443
-
444
- # Create the versions.js file containing a list of `entries`.
445
- # This must always happen after the folder copying.
446
- HTMLWriter. generate_version_file (joinpath (dirname, " versions.js" ), entries, symlinks)
447
-
448
- # Create the index.html file to redirect ./stable or ./dev.
449
- # This must always happen after the folder copying.
450
- HTMLWriter. generate_redirect_file (joinpath (dirname, " index.html" ), entries)
451
-
452
- # generate the symlinks, make sure we don't overwrite devurl
453
- cd (dirname) do
454
- for kv in symlinks
455
- i = findfirst (x -> x. first == devurl, symlinks)
456
- if i === nothing
457
- rm_and_add_symlink (kv. second, kv. first)
458
- else
459
- throw (
460
- ArgumentError (
461
- string (
462
- " link `$(kv) ` cannot overwrite " ,
463
- " `devurl = $(devurl) ` with the same name."
464
- )
465
- )
466
- )
467
- end
468
- end
469
- end
470
- end
427
+ # this dispatches on `versions` for a non-public API for DocumenterVitepress
428
+ postprocess_before_push (versions; subfolder, devurl, deploy_dir, dirname)
471
429
472
430
# Add, commit, and push the docs to the remote.
473
431
run (` $(git ()) add -A -- ':!.documenter-identity-file.tmp' ':!**/.documenter-identity-file.tmp'` )
@@ -559,6 +517,68 @@ function git_push(
559
517
return
560
518
end
561
519
520
+ # Run arbitrary logic (for example, creating siteinfo and version files)
521
+ # on the documentation with the new additions before the changes are pushed to the remote.
522
+ # The logic depends on the versioning scheme defined via `versions`.
523
+ # This function was factored out as part of a non-public API via dispatch on the `versions` keyword arg
524
+ # to `deploydocs`, for use in DocumenterVitepress because it cannot use the default versioning.
525
+ function postprocess_before_push (versions:: Nothing ; subfolder, devurl, deploy_dir, dirname)
526
+ # If the documentation is unversioned and deployed to root, we generate a
527
+ # siteinfo.js file that would disable the version selector in the docs
528
+ HTMLWriter. generate_siteinfo_file (deploy_dir, nothing )
529
+ return
530
+ end
531
+
532
+ function postprocess_before_push (versions:: AbstractVector ; subfolder, devurl, deploy_dir, dirname)
533
+ # Generate siteinfo-file with DOCUMENTER_CURRENT_VERSION
534
+ # Determine if this is a development version (e.g., "dev" or "latest")
535
+ is_dev_version = (subfolder == devurl || subfolder == " latest" )
536
+ HTMLWriter. generate_siteinfo_file (deploy_dir, subfolder, is_dev_version)
537
+
538
+ # Expand the users `versions` vector
539
+ entries, symlinks = HTMLWriter. expand_versions (dirname, versions)
540
+
541
+ # Create the versions.js file containing a list of `entries`.
542
+ # This must always happen after the folder copying.
543
+ HTMLWriter. generate_version_file (joinpath (dirname, " versions.js" ), entries, symlinks)
544
+
545
+ # Create the index.html file to redirect ./stable or ./dev.
546
+ # This must always happen after the folder copying.
547
+ HTMLWriter. generate_redirect_file (joinpath (dirname, " index.html" ), entries)
548
+
549
+ # generate the symlinks, make sure we don't overwrite devurl
550
+ return cd (dirname) do
551
+ for kv in symlinks
552
+ i = findfirst (x -> x. first == devurl, symlinks)
553
+ if i === nothing
554
+ rm_and_add_symlink (kv. second, kv. first)
555
+ else
556
+ throw (
557
+ ArgumentError (
558
+ string (
559
+ " link `$(kv) ` cannot overwrite " ,
560
+ " `devurl = $(devurl) ` with the same name."
561
+ )
562
+ )
563
+ )
564
+ end
565
+ end
566
+ end
567
+ end
568
+
569
+ # Determine the subfolder to deploy to given the `deploy_decision` and the `versions`.
570
+ # Either return a `String` or `nothing` to deploy to the root folder.
571
+ # This function was factored out as part of a non-public API via dispatch on the `versions` keyword arg
572
+ # to `deploydocs`, for use in DocumenterVitepress because it cannot use the default versioning.
573
+ function determine_deploy_subfolder (deploy_decision, versions:: Nothing )
574
+ # Non-versioned docs: deploy to root unless it's a preview
575
+ return deploy_decision. is_preview ? deploy_decision. subfolder : nothing
576
+ end
577
+
578
+ function determine_deploy_subfolder (deploy_decision, versions:: AbstractVector )
579
+ return deploy_decision. subfolder
580
+ end
581
+
562
582
function rm_and_add_symlink (target, link)
563
583
if ispath (link) || islink (link)
564
584
@warn " removing `$(link) ` and linking `$(link) ` to `$(target) `."
0 commit comments