Skip to content

Commit b67c572

Browse files
mortenpiLilithHafner
authored andcommitted
Update Documenter 0.27.23 => 1.2.1 (#47105)
Currently mainly to test a few things on CI here, but will update this to an actual PR once 0.28.0 is out. --------- Co-authored-by: Lilith Orion Hafner <lilithhafner@gmail.com>
1 parent 7dc20dc commit b67c572

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

doc/make.jl

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ using Pkg
88
Pkg.instantiate()
99

1010
using Documenter
11+
import LibGit2
1112

1213
baremodule GenStdLib end
1314

@@ -42,6 +43,68 @@ cd(joinpath(@__DIR__, "src")) do
4243
end
4344
end
4445

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+
45108
# Check if we are building a PDF
46109
const render_pdf = "pdf" in ARGS
47110

@@ -287,6 +350,8 @@ else
287350
collapselevel = 1,
288351
sidebar_sitename = false,
289352
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
290355
)
291356
end
292357

@@ -298,12 +363,12 @@ makedocs(
298363
doctest = ("doctest=fix" in ARGS) ? (:fix) : ("doctest=only" in ARGS) ? (:only) : ("doctest=true" in ARGS) ? true : false,
299364
linkcheck = "linkcheck=true" in ARGS,
300365
linkcheck_ignore = ["https://bugs.kde.org/show_bug.cgi?id=136779"], # fails to load from nanosoldier?
301-
strict = true,
302366
checkdocs = :none,
303367
format = format,
304368
sitename = "The Julia Language",
305369
authors = "The Julia Project",
306370
pages = PAGES,
371+
remotes = documenter_stdlib_remotes,
307372
)
308373

309374
# Update URLs to external stdlibs (JuliaLang/julia#43199)

stdlib/Dates/docs/src/index.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
```@meta
2-
EditURL = "https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/docs/src/index.md"
3-
```
4-
51
# Dates
62

73
```@meta

0 commit comments

Comments
 (0)