Skip to content

Commit 8c6e4ad

Browse files
authored
doc: Get stdlib dir from make system rather than executable (#58530)
The `make.jl` docsystem driver was using `Sys.STDLIB` as the canonical list and location of stdlibs. When `make.jl` is invoked as part of the make system (e.g. `make -C doc`), I think it makes more sense to use make's idea of where the stdlibs are. Of course, if you're using a just-built julia to create the docs, these two notions are identical. However, the docsystem build supports (explicitly via the `JULIA_EXECUTABLE` option), being built with an external julia executable. In this case, we should still use the stdlib source from in tree (as we do with the ordinary base sources). A primary motivation is to let AI agents run the doctests before they submit PRs without having to do a whole julia build.
1 parent 0a970d8 commit 8c6e4ad

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

doc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ help:
2121
@echo "To fix outdated doctests, use 'make <target> doctest=fix'"
2222
@echo "To run doctests using Revise (to test changes without rebuilding the sysimage), use 'make <target> doctest=true revise=true'"
2323

24-
24+
VERSDIR := v`cut -d. -f1-2 < $(JULIAHOME)/VERSION`
2525
DOCUMENTER_OPTIONS := linkcheck=$(linkcheck) doctest=$(doctest) buildroot=$(call cygpath_w,$(BUILDROOT)) \
26-
texplatform=$(texplatform) revise=$(revise)
26+
texplatform=$(texplatform) revise=$(revise) stdlibdir=$(call cygpath_w,$(build_datarootdir)/julia/stdlib/$(VERSDIR)/)
2727

2828
UNICODE_DATA_VERSION=13.0.0
2929
$(SRCCACHE)/UnicodeData-$(UNICODE_DATA_VERSION).txt:

doc/make.jl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1+
# Get the buildroot and stdlibdir from the make environment to make sure we're
2+
# generating docs for the current julia source tree, regardless of what julia
3+
# executable we're using. If these arguments are not passed, fall back to
4+
# assuming that we're running a just-built version of julia and generating docs
5+
# in tree.
16
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")
7+
if i === nothing
8+
global const buildrootdoc = @__DIR__
9+
global const buildroot = abspath(joinpath(buildrootdoc, ".."))
10+
else
11+
global const buildroot = first(match(r, ARGS[i]).captures)
12+
global const buildrootdoc = joinpath(buildroot, "doc")
13+
end
14+
end
15+
16+
let r = r"stdlibdir=(.+)", i = findfirst(x -> occursin(r, x), ARGS)
17+
if i === nothing
18+
global const STDLIB_DIR = Sys.STDLIB
19+
else
20+
global const STDLIB_DIR = first(match(r, ARGS[i]).captures)
21+
end
322
end
423

524
# Install dependencies needed to build the documentation.
@@ -28,7 +47,6 @@ cp_q(src, dest) = isfile(dest) || cp(src, dest)
2847

2948
# make links for stdlib package docs, this is needed until #552 in Documenter.jl is finished
3049
const STDLIB_DOCS = []
31-
const STDLIB_DIR = Sys.STDLIB
3250
const EXT_STDLIB_DOCS = ["Pkg"]
3351
cd(joinpath(buildrootdoc, "src")) do
3452
Base.rm("stdlib"; recursive=true, force=true)

0 commit comments

Comments
 (0)