Skip to content

Docs: Update doctest info, enhance stdlib script #58503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions contrib/print_sorted_stdlibs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ function check_flag(flag)
end

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

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

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

if exclude_sysimage
loaded_modules = Set(map(k->k.name, collect(keys(Base.loaded_modules))))
filter!(p->!in(p, loaded_modules), sorted_projects)
if only_sysimage && exclude_sysimage
println(stderr, "Warning: --only-sysimg and --exclude-sysimage are mutually exclusive. Prioritizing --only-sysimg.")
exclude_sysimage = false
end

if only_sysimage || exclude_sysimage
loaded_modules_set = Set(map(k->k.name, collect(keys(Base.loaded_modules))))

if only_sysimage
filter!(p -> in(p, loaded_modules_set), sorted_projects)
else
filter!(p -> !in(p, loaded_modules_set), sorted_projects)
end
end

# Print out sorted projects, ready to be pasted into `sysimg.jl`
Expand All @@ -92,6 +103,9 @@ println(" # Stdlibs sorted in dependency, then alphabetical, order by contrib
if exclude_jlls
println(" # Run with the `--exclude-jlls` option to filter out all JLL packages")
end
if only_sysimage
println(" # Run with the `--only-sysimg` option to filter for only packages included in the system image")
end
if exclude_sysimage
println(" # Run with the `--exclude-sysimage` option to filter out all packages included in the system image")
end
Expand Down
8 changes: 8 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ $ make -C doc doctest=true
```

from the root directory.

## Customizing Doctest Execution

By default, doctests are run using the in-tree Julia executable.
This behavior can be changed by setting the `JULIA_EXECUTABLE` Makefile variable.

> [!WARNING]
> 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`).