Skip to content

Commit 3103102

Browse files
authored
Fix links to external stdlib repos in docs, fixes #43199. (#43225)
1 parent 7107ced commit 3103102

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
@@ -294,8 +294,9 @@ else
294294
)
295295
end
296296

297+
const output_path = joinpath(buildroot, "doc", "_build", (render_pdf ? "pdf" : "html"), "en")
297298
makedocs(
298-
build = joinpath(buildroot, "doc", "_build", (render_pdf ? "pdf" : "html"), "en"),
299+
build = output_path,
299300
modules = [Main, Base, Core, [Base.root_module(Base, stdlib.stdlib) for stdlib in STDLIB_DOCS]...],
300301
clean = true,
301302
doctest = ("doctest=fix" in ARGS) ? (:fix) : ("doctest=only" in ARGS) ? (:only) : ("doctest=true" in ARGS) ? true : false,
@@ -309,6 +310,31 @@ makedocs(
309310
pages = PAGES,
310311
)
311312

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

0 commit comments

Comments
 (0)