1616 specifying the root of the canonical URL.
1717"""
1818function update_canonical_links_for_version (
19- docs_directory:: AbstractString ;
20- canonical:: AbstractString
21- )
19+ docs_directory:: AbstractString ;
20+ canonical:: AbstractString ,
21+ )
2222 canonical = rstrip (canonical, ' /' )
2323
2424 walkdocs (docs_directory, isdochtml) do fileinfo
@@ -49,10 +49,9 @@ function update_canonical_links_for_version(
4949 e isa Gumbo. HTMLElement || continue
5050 Gumbo. tag (e) == :head || continue
5151 canonical_href_element = Gumbo. HTMLElement {:link} (
52- [], e, Dict (
53- " rel" => " canonical" ,
54- " href" => new_canonical_href,
55- )
52+ [],
53+ e,
54+ Dict (" rel" => " canonical" , " href" => new_canonical_href),
5655 )
5756 push! (e. children, canonical_href_element)
5857 @debug " update_canonical_links_for_version: added new canonical_href" new_canonical_href fileinfo. relpath
@@ -69,17 +68,17 @@ function update_canonical_links_for_version(
6968 end
7069end
7170
72- is_canonical_element (e) = (e isa Gumbo. HTMLElement) && (Gumbo. tag (e) == :link ) && (Gumbo. getattr (e, " rel" , nothing ) == " canonical" )
71+ is_canonical_element (e) =
72+ (e isa Gumbo. HTMLElement) &&
73+ (Gumbo. tag (e) == :link ) &&
74+ (Gumbo. getattr (e, " rel" , nothing ) == " canonical" )
7375joinurl (ps:: AbstractString... ) = join (ps, ' /' )
7476
7577"""
7678Takes the multi-versioned Documenter site in `docs_directory` and updates the HTML canonical URLs
7779to point to `canonical`.
7880"""
79- function update_canonical_links (
80- docs_directory:: AbstractString ;
81- canonical:: AbstractString
82- )
81+ function update_canonical_links (docs_directory:: AbstractString ; canonical:: AbstractString )
8382 canonical = rstrip (canonical, ' /' )
8483 docs_directory = abspath (docs_directory)
8584 isdir (docs_directory) || throw (ArgumentError (" No such directory: $(docs_directory) " ))
@@ -144,12 +143,14 @@ function get_meta_redirect_url(indexhtml_path::AbstractString)
144143 Gumbo. getattr (e, " http-equiv" , nothing ) == " refresh" || continue
145144 content = Gumbo. getattr (e, " content" , nothing )
146145 if isnothing (content)
147- @warn " <meta http-equiv=\" refresh\" ...> with no content attribute" path = indexhtml_path
146+ @warn " <meta http-equiv=\" refresh\" ...> with no content attribute" path =
147+ indexhtml_path
148148 continue
149149 end
150150 m = match (r" [0-9]+;\s *url=(.*)" , content)
151151 if isnothing (m)
152- @warn " Unable to parse content value of <meta http-equiv=\" refresh\" ...>" content path = indexhtml_path
152+ @warn " Unable to parse content value of <meta http-equiv=\" refresh\" ...>" content path =
153+ indexhtml_path
153154 continue
154155 end
155156 return m. captures[1 ]
@@ -161,7 +162,8 @@ function canonical_version_from_versions_js(docs_directory)
161162 isdir (docs_directory) || throw (ArgumentError (" Not a directory: $(docs_directory) " ))
162163 # Try to extract the list of versions from versions.js
163164 versions_js = joinpath (docs_directory, " versions.js" )
164- isfile (versions_js) || throw (ArgumentError (" versions.js is missing in $(docs_directory) " ))
165+ isfile (versions_js) ||
166+ throw (ArgumentError (" versions.js is missing in $(docs_directory) " ))
165167 versions = map (extract_versions_list (versions_js)) do version_str
166168 isversion, version_number = if occursin (Base. VERSION_REGEX, version_str)
167169 true , VersionNumber (version_str)
@@ -212,7 +214,9 @@ function canonical_version_from_versions_js(docs_directory)
212214 _, idx = findmax (first, version_symlinks)
213215 version_symlinks[idx][2 ]
214216 elseif length (non_version_symlinks) > 1
215- error (" Unable to determine the canonical path. Found multiple non-version symlinks.\n $(non_version_symlinks) " )
217+ error (
218+ " Unable to determine the canonical path. Found multiple non-version symlinks.\n $(non_version_symlinks) " ,
219+ )
216220 else
217221 only (non_version_symlinks)
218222 end
0 commit comments