Skip to content

Commit 2bd37fb

Browse files
Docs: Update doctest info, enhance stdlib script (#58503)
- Revise `doc/README.md` to mention `JULIA_EXECUTABLE` usage with doctests, adding a warning regarding built-in stdlibs - Enhance `contrib/print_sorted_stdlibs.jl` script to add `--only-sysimg` option to accurately list standard libraries built into the system image. These modifications aim to provide clearer documentation and more effective tooling for contributors and AI agents wanting to run the doctests without building julia from scratch. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent e24c30a commit 2bd37fb

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

contrib/print_sorted_stdlibs.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ function check_flag(flag)
1212
end
1313

1414
if check_flag("--help") || check_flag("-h")
15-
println("Usage: julia print_sorted_stdlibs.jl [stdlib_dir] [--exclude-jlls] [--exclude-sysimage]")
15+
println("Usage: julia print_sorted_stdlibs.jl [stdlib_dir] [--exclude-jlls] [--exclude-sysimage] [--only-sysimg]")
1616
end
1717

1818
# Allow users to ask for JLL or no JLLs
1919
exclude_jlls = check_flag("--exclude-jlls")
2020
exclude_sysimage = check_flag("--exclude-sysimage")
21+
only_sysimage = check_flag("--only-sysimg")
2122

2223
# Default to the `stdlib/vX.Y` directory
2324
STDLIB_DIR = get(ARGS, 1, joinpath(@__DIR__, "..", "usr", "share", "julia", "stdlib"))
@@ -81,9 +82,19 @@ if exclude_jlls
8182
filter!(p -> !endswith(p, "_jll"), sorted_projects)
8283
end
8384

84-
if exclude_sysimage
85-
loaded_modules = Set(map(k->k.name, collect(keys(Base.loaded_modules))))
86-
filter!(p->!in(p, loaded_modules), sorted_projects)
85+
if only_sysimage && exclude_sysimage
86+
println(stderr, "Warning: --only-sysimg and --exclude-sysimage are mutually exclusive. Prioritizing --only-sysimg.")
87+
exclude_sysimage = false
88+
end
89+
90+
if only_sysimage || exclude_sysimage
91+
loaded_modules_set = Set(map(k->k.name, collect(keys(Base.loaded_modules))))
92+
93+
if only_sysimage
94+
filter!(p -> in(p, loaded_modules_set), sorted_projects)
95+
else
96+
filter!(p -> !in(p, loaded_modules_set), sorted_projects)
97+
end
8798
end
8899

89100
# Print out sorted projects, ready to be pasted into `sysimg.jl`
@@ -92,6 +103,9 @@ println(" # Stdlibs sorted in dependency, then alphabetical, order by contrib
92103
if exclude_jlls
93104
println(" # Run with the `--exclude-jlls` option to filter out all JLL packages")
94105
end
106+
if only_sysimage
107+
println(" # Run with the `--only-sysimg` option to filter for only packages included in the system image")
108+
end
95109
if exclude_sysimage
96110
println(" # Run with the `--exclude-sysimage` option to filter out all packages included in the system image")
97111
end

doc/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ $ make -C doc doctest=true
2727
```
2828

2929
from the root directory.
30+
31+
## Customizing Doctest Execution
32+
33+
By default, doctests are run using the in-tree Julia executable.
34+
This behavior can be changed by setting the `JULIA_EXECUTABLE` Makefile variable.
35+
36+
> [!WARNING]
37+
> Using a custom `JULIA_EXECUTABLE` will not pick up changes to docstrings for Base or any standard library built into the system image. To see the list of standard libraries that are part of the system image, you can run the `contrib/print_sorted_stdlibs.jl` script (e.g., `julia contrib/print_sorted_stdlibs.jl --only-sysimg`).

0 commit comments

Comments
 (0)