Skip to content

Commit 72d6569

Browse files
fredrikekreKristofferC
authored andcommitted
Fix links to external stdlib repos in docs, fixes #43199. (#43225)
(cherry picked from commit 3103102)
1 parent 06516f6 commit 72d6569

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

doc/make.jl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ else
284284
)
285285
end
286286

287+
const output_path = joinpath(buildroot, "doc", "_build", (render_pdf ? "pdf" : "html"), "en")
287288
makedocs(
288-
build = joinpath(buildroot, "doc", "_build", (render_pdf ? "pdf" : "html"), "en"),
289+
build = output_path,
289290
modules = [Main, Base, Core, [Base.root_module(Base, stdlib.stdlib) for stdlib in STDLIB_DOCS]...],
290291
clean = true,
291292
doctest = ("doctest=fix" in ARGS) ? (:fix) : ("doctest=only" in ARGS) ? (:only) : ("doctest=true" in ARGS) ? true : false,
@@ -299,6 +300,31 @@ makedocs(
299300
pages = PAGES,
300301
)
301302

303+
# Update URLs to external stdlibs (JuliaLang/julia#43199)
304+
for (root, _, files) in walkdir(output_path), file in joinpath.(root, files)
305+
endswith(file, ".html") || continue
306+
str = read(file, String)
307+
# Index page links, update
308+
# https://github.com/JuliaLang/julia/blob/master/stdlib/${STDLIB_NAME}-${STDLIB_COMMIT}/path/to.md
309+
# to
310+
# https://github.com/JuliaLang/${STDLIB_NAME}.jl/blob/master/docs/src/index.md
311+
str = replace(str, r"https://github.com/JuliaLang/julia/blob/master/stdlib/(.*)-\w{40}/(.*\.md)" =>
312+
s"https://github.com/JuliaLang/\1.jl/blob/master/\2")
313+
# Link to source links, update
314+
# https://github.com/JuliaLang/julia/blob/${JULIA_COMMIT}/stdlib/${STDLIB_NAME}-${STDLIB_COMMIT}/path/to.jl#${LINES}
315+
# to
316+
# https://github.com/JuliaLang/${STDLIB_NAME}.jl/blob/${STDLIB_COMMIT}/path/to.jl#${LINES}
317+
str = replace(str, r"https://github\.com/JuliaLang/julia/blob/\w{40}/stdlib/(.*)-(\w{40})/(.*\.jl#L\d+(?:-L\d+)?)" =>
318+
s"https://github.com/JuliaLang/\1.jl/blob/\2/\3")
319+
# Some stdlibs are not hosted by JuliaLang
320+
str = replace(str, r"(https://github\.com)/JuliaLang/(ArgTools\.jl/blob)" => s"\1/JuliaIO/\2")
321+
str = replace(str, r"(https://github\.com)/JuliaLang/(LibCURL\.jl/blob)" => s"\1/JuliaWeb/\2")
322+
str = replace(str, r"(https://github\.com)/JuliaLang/(SHA\.jl/blob)" => s"\1/JuliaCrypto/\2")
323+
str = replace(str, r"(https://github\.com)/JuliaLang/(Tar\.jl/blob)" => s"\1/JuliaIO/\2")
324+
# Write back to the file
325+
write(file, str)
326+
end
327+
302328
# Define our own DeployConfig
303329
struct BuildBotConfig <: Documenter.DeployConfig end
304330
function Documenter.deploy_folder(::BuildBotConfig; devurl, repo, branch, kwargs...)

0 commit comments

Comments
 (0)