1
1
module MultiDocumenter
2
2
3
+ import DocumenterTools
3
4
import Gumbo, AbstractTrees
4
5
using HypertextLiteral
5
6
import Git: git
@@ -25,13 +26,15 @@ struct MultiDocRef
25
26
path:: String
26
27
name:: String
27
28
29
+ fix_canonical_url:: Bool
30
+
28
31
# these are not actually used internally
29
32
giturl:: String
30
33
branch:: String
31
34
end
32
35
33
- function MultiDocRef (; upstream, name, path, giturl = " " , branch = " gh-pages" )
34
- MultiDocRef (upstream, path, name, giturl, branch)
36
+ function MultiDocRef (; upstream, name, path, giturl = " " , branch = " gh-pages" , fix_canonical_url = true )
37
+ MultiDocRef (upstream, path, name, fix_canonical_url, giturl, branch)
35
38
end
36
39
37
40
struct DropdownNav
76
79
include (" renderers.jl" )
77
80
include (" search/flexsearch.jl" )
78
81
include (" search/stork.jl" )
82
+ include (" canonical.jl" )
79
83
80
84
const DEFAULT_ENGINE = SearchConfig (index_versions = [" stable" , " dev" ], engine = FlexSearch)
81
85
@@ -91,6 +95,7 @@ const DEFAULT_ENGINE = SearchConfig(index_versions = ["stable", "dev"], engine =
91
95
prettyurls = true,
92
96
rootpath = "/",
93
97
hide_previews = true,
98
+ canonical = nothing,
94
99
)
95
100
96
101
Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`.
@@ -105,6 +110,9 @@ Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`
105
110
- `prettyurls` removes all `index.html` suffixes from links in the global navigation.
106
111
- `rootpath` is the path your site ends up being deployed at, e.g. `/foo/` if it's hosted at `https://bar.com/foo`
107
112
- `hide_previews` removes preview builds from the aggregated documentation.
113
+ - `canonical`: if set to the root URL of the MultiDocumenter site, will check and, if necessary, update the
114
+ canonical URL tags for each package site to point to the directory. Similar to the `canonical` argument of
115
+ `Documenter.HTML` constructor.
108
116
"""
109
117
function make (
110
118
outdir,
@@ -117,10 +125,12 @@ function make(
117
125
prettyurls = true ,
118
126
rootpath = " /" ,
119
127
hide_previews = true ,
128
+ canonical:: Union{AbstractString, Nothing} = nothing ,
120
129
)
121
130
maybe_clone (flatten_multidocrefs (docs))
122
131
123
- dir = make_output_structure (flatten_multidocrefs (docs), prettyurls, hide_previews)
132
+ canonical = rstrip (canonical, ' /' )
133
+ dir = make_output_structure (flatten_multidocrefs (docs), prettyurls, hide_previews; canonical)
124
134
out_assets = joinpath (dir, " assets" )
125
135
if assets_dir != = nothing && isdir (assets_dir)
126
136
cp (assets_dir, out_assets)
@@ -192,7 +202,10 @@ function maybe_clone(docs::Vector{MultiDocRef})
192
202
end
193
203
end
194
204
195
- function make_output_structure (docs:: Vector{MultiDocRef} , prettyurls, hide_previews)
205
+ function make_output_structure (
206
+ docs:: Vector{MultiDocRef} , prettyurls, hide_previews;
207
+ canonical:: Union{AbstractString, Nothing}
208
+ )
196
209
dir = mktempdir ()
197
210
198
211
for doc in docs
@@ -210,6 +223,8 @@ function make_output_structure(docs::Vector{MultiDocRef}, prettyurls, hide_previ
210
223
if hide_previews && isdir (previewpath)
211
224
rm (previewpath, recursive = true )
212
225
end
226
+
227
+ fix_canonical_url! (doc; canonical, root_dir= dir)
213
228
end
214
229
215
230
open (joinpath (dir, " index.html" ), " w" ) do io
0 commit comments