1+ let r = r" buildroot=(.+)" , i = findfirst (x -> occursin (r, x), ARGS )
2+ global const buildrootdoc = i === nothing ? (@__DIR__ ) : joinpath (first (match (r, ARGS [i]). captures), " doc" )
3+ end
4+
15# Install dependencies needed to build the documentation.
26Base. ACTIVE_PROJECT[] = nothing
37empty! (LOAD_PATH )
48push! (LOAD_PATH , @__DIR__ , " @stdlib" )
59empty! (DEPOT_PATH )
6- push! (DEPOT_PATH , joinpath (@__DIR__ , " deps" ))
10+ push! (DEPOT_PATH , joinpath (buildrootdoc , " deps" ))
711push! (DEPOT_PATH , abspath (Sys. BINDIR, " .." , " share" , " julia" ))
812using Pkg
913Pkg. instantiate ()
@@ -26,7 +30,7 @@ cp_q(src, dest) = isfile(dest) || cp(src, dest)
2630const STDLIB_DOCS = []
2731const STDLIB_DIR = Sys. STDLIB
2832const EXT_STDLIB_DOCS = [" Pkg" ]
29- cd (joinpath (@__DIR__ , " src" )) do
33+ cd (joinpath (buildrootdoc , " src" )) do
3034 Base. rm (" stdlib" ; recursive= true , force= true )
3135 mkdir (" stdlib" )
3236 for dir in readdir (STDLIB_DIR)
@@ -70,7 +74,8 @@ function parse_stdlib_version_file(path)
7074end
7175# This generates the value that will be passed to the `remotes` argument of makedocs(),
7276# by looking through all *.version files in stdlib/.
73- documenter_stdlib_remotes = let stdlib_dir = realpath (joinpath (@__DIR__ , " .." , " stdlib" ))
77+ documenter_stdlib_remotes = let stdlib_dir = realpath (joinpath (@__DIR__ , " .." , " stdlib" )),
78+ stdlib_build_dir = joinpath (buildrootdoc, " .." , " stdlib" )
7479 # Get a list of all *.version files in stdlib/..
7580 version_files = filter (readdir (stdlib_dir)) do fname
7681 isfile (joinpath (stdlib_dir, fname)) && endswith (fname, " .version" )
@@ -97,7 +102,7 @@ documenter_stdlib_remotes = let stdlib_dir = realpath(joinpath(@__DIR__, "..", "
97102 versionfile[sha_key]
98103 end
99104 # Construct the absolute (local) path to the stdlib package's root directory
100- package_root_dir = joinpath (stdlib_dir , " $(package) -$(package_sha) " )
105+ package_root_dir = joinpath (stdlib_build_dir , " $(package) -$(package_sha) " )
101106 # Documenter needs package_root_dir to exist --- it's just a sanity check it does on the remotes= keyword.
102107 # In normal (local) builds, this will be the case, since the Makefiles will have unpacked the standard
103108 # libraries. However, on CI we do this thing where we actually build docs in a clean worktree, just
@@ -127,7 +132,7 @@ function generate_markdown(basename)
127132 @assert length (splitted) == 2
128133 replaced_links = replace (splitted[1 ], r" \[\# ([0-9]*?)\] " => s " [#\g <1>](https://github.com/JuliaLang/julia/issues/\g <1>)" )
129134 write (
130- joinpath (@__DIR__ , " src" , " $basename .md" ),
135+ joinpath (buildrootdoc , " src" , " $basename .md" ),
131136 """
132137 ```@meta
133138 EditURL = "https://github.com/JuliaLang/julia/blob/master/$basename .md"
281286
282287const use_revise = " revise=true" in ARGS
283288if use_revise
284- let revise_env = joinpath (@__DIR__ , " deps" , " revise" )
289+ let revise_env = joinpath (buildrootdoc , " deps" , " revise" )
285290 Pkg. activate (revise_env)
286291 Pkg. add (" Revise" ; preserve= Pkg. PRESERVE_NONE)
287292 Base. ACTIVE_PROJECT[] = nothing
@@ -351,10 +356,6 @@ DocMeta.setdocmeta!(
351356 recursive= true , warn= false ,
352357)
353358
354- let r = r" buildroot=(.+)" , i = findfirst (x -> occursin (r, x), ARGS )
355- global const buildroot = i === nothing ? (@__DIR__ ) : first (match (r, ARGS [i]). captures)
356- end
357-
358359const format = if render_pdf
359360 Documenter. LaTeX (
360361 platform = " texplatform=docker" in ARGS ? " docker" : " native"
377378 )
378379end
379380
380- const output_path = joinpath (buildroot, " doc " , " _build" , (render_pdf ? " pdf" : " html" ), " en" )
381+ const output_path = joinpath (buildrootdoc , " _build" , (render_pdf ? " pdf" : " html" ), " en" )
381382makedocs (
383+ source = joinpath (buildrootdoc, " src" ),
382384 build = output_path,
383385 modules = [Main, Base, Core, [Base. root_module (Base, stdlib. stdlib) for stdlib in STDLIB_DOCS]. .. ],
384386 clean = true ,
@@ -479,7 +481,7 @@ if "deploy" in ARGS
479481 deploydocs (
480482 repo = " github.com/JuliaLang/docs.julialang.org.git" ,
481483 deploy_config = BuildBotConfig (),
482- target = joinpath (buildroot, " doc " , " _build" , " html" , " en" ),
484+ target = joinpath (buildrootdoc , " _build" , " html" , " en" ),
483485 dirname = " en" ,
484486 devurl = devurl,
485487 versions = Versions ([" v#.#" , devurl => devurl]),
0 commit comments