@@ -8,7 +8,7 @@ using Pkg
88Pkg. instantiate ()
99
1010using Documenter
11- using DocumenterInventoryWritingBackport
11+ import LibGit2
1212
1313baremodule GenStdLib end
1414
@@ -43,6 +43,68 @@ cd(joinpath(@__DIR__, "src")) do
4343 end
4444end
4545
46+ # Because we have standard libraries that are hosted outside of the julia repo,
47+ # but their docs are included in the manual, we need to populate the remotes argument
48+ # of makedocs(), to make sure that Documenter knows how to resolve the directories
49+ # in stdlib/ to the correct remote Git repositories (for source and edit links).
50+ #
51+ # This function parses the *.version files in stdlib/, returning a dictionary with
52+ # all the key-value pairs from those files. *_GIT_URL and *_SHA1 fields are the ones
53+ # we will actually be interested in.
54+ function parse_stdlib_version_file (path)
55+ values = Dict {String,String} ()
56+ for line in readlines (path)
57+ m = match (r" ^([A-Z0-9_]+)\s +:?=\s +(\S +)$" , line)
58+ if isnothing (m)
59+ @warn " Unable to parse line in $(path) " line
60+ else
61+ values[m[1 ]] = m[2 ]
62+ end
63+ end
64+ return values
65+ end
66+ # This generates the value that will be passed to the `remotes` argument of makedocs(),
67+ # by looking through all *.version files in stdlib/.
68+ documenter_stdlib_remotes = let stdlib_dir = realpath (joinpath (@__DIR__ , " .." , " stdlib" ))
69+ # Get a list of all *.version files in stdlib/..
70+ version_files = filter (readdir (stdlib_dir)) do fname
71+ isfile (joinpath (stdlib_dir, fname)) && endswith (fname, " .version" )
72+ end
73+ # .. and then parse them, each becoming an entry for makedocs's remotes.
74+ # The values for each are of the form path => (remote, sha1), where
75+ # - path: the path to the stdlib package's root directory, i.e. "stdlib/$PACKAGE"
76+ # - remote: a Documenter.Remote object, pointing to the Git repository where package is hosted
77+ # - sha1: the SHA1 of the commit that is included with the current Julia version
78+ remotes_list = map (version_files) do version_fname
79+ package = match (r" (.+)\. version" , version_fname)[1 ]
80+ versionfile = parse_stdlib_version_file (joinpath (stdlib_dir, version_fname))
81+ # From the (all uppercase) $(package)_GIT_URL and $(package)_SHA1 fields, we'll determine
82+ # the necessary information. If this logic happens to fail for some reason for any of the
83+ # standard libraries, we'll crash the documentation build, so that it could be fixed.
84+ remote = let git_url_key = " $(uppercase (package)) _GIT_URL"
85+ haskey (versionfile, git_url_key) || error (" Missing $(git_url_key) in $version_fname " )
86+ m = match (LibGit2. GITHUB_REGEX, versionfile[git_url_key])
87+ isnothing (m) && error (" Unable to parse $(git_url_key) ='$(versionfile[git_url_key]) ' in $version_fname " )
88+ Documenter. Remotes. GitHub (m[2 ], m[3 ])
89+ end
90+ package_sha = let sha_key = " $(uppercase (package)) _SHA1"
91+ haskey (versionfile, sha_key) || error (" Missing $(sha_key) in $version_fname " )
92+ versionfile[sha_key]
93+ end
94+ # Construct the absolute (local) path to the stdlib package's root directory
95+ package_root_dir = joinpath (stdlib_dir, " $(package) -$(package_sha) " )
96+ # Documenter needs package_root_dir to exist --- it's just a sanity check it does on the remotes= keyword.
97+ # In normal (local) builds, this will be the case, since the Makefiles will have unpacked the standard
98+ # libraries. However, on CI we do this thing where we actually build docs in a clean worktree, just
99+ # unpacking the `usr/` directory from the main build, and the unpacked stdlibs will be missing, and this
100+ # will cause Documenter to throw an error. However, we don't _actually_ need the source files of the standard
101+ # libraries to be present, so we just generate empty root directories to satisfy the check in Documenter.
102+ isdir (package_root_dir) || mkpath (package_root_dir)
103+ package_root_dir => (remote, package_sha)
104+ end
105+ Dict (remotes_list)
106+ end
107+
46108# Check if we are building a PDF
47109const render_pdf = " pdf" in ARGS
48110
288350 collapselevel = 1 ,
289351 sidebar_sitename = false ,
290352 ansicolor = true ,
353+ size_threshold = 800 * 2 ^ 10 , # 800 KiB
354+ size_threshold_warn = 200 * 2 ^ 10 , # the manual has quite a few large pages, so we warn at 200+ KiB only
291355 )
292356end
293357
@@ -299,12 +363,12 @@ makedocs(
299363 doctest = (" doctest=fix" in ARGS ) ? (:fix ) : (" doctest=only" in ARGS ) ? (:only ) : (" doctest=true" in ARGS ) ? true : false ,
300364 linkcheck = " linkcheck=true" in ARGS ,
301365 linkcheck_ignore = [" https://bugs.kde.org/show_bug.cgi?id=136779" ], # fails to load from nanosoldier?
302- strict = true ,
303366 checkdocs = :none ,
304367 format = format,
305368 sitename = " The Julia Language" ,
306369 authors = " The Julia Project" ,
307370 pages = PAGES,
371+ remotes = documenter_stdlib_remotes,
308372)
309373
310374# Update URLs to external stdlibs (JuliaLang/julia#43199)
0 commit comments