@@ -4,14 +4,15 @@ using HTMLSanitizer
4
4
using Highlights
5
5
using Downloads
6
6
using Documenter
7
- function build_git_docs (packagespec, buildpath, uri; src_prefix= " " , href_prefix= " " )
7
+
8
+ function build_git_docs (packagespec, buildpath, uri; src_prefix= " " , href_prefix= " " , html_size_threshold_bytes= nothing )
8
9
pkgname = packagespec. name
9
10
return mktempdir () do dir
10
11
return cd (dir) do
11
12
run (` git clone --depth=1 $(uri) $(pkgname) ` )
12
13
docsproject = joinpath (dir, pkgname)
13
14
return cd (docsproject) do
14
- return build_local_docs (packagespec, buildpath, nothing , docsproject, gitdirdocs = true ; src_prefix= src_prefix, href_prefix= href_prefix)
15
+ return build_local_docs (packagespec, buildpath, nothing , docsproject, gitdirdocs = true ; src_prefix= src_prefix, href_prefix= href_prefix, html_size_threshold_bytes = html_size_threshold_bytes )
15
16
end
16
17
end
17
18
end
@@ -84,7 +85,7 @@ function maybe_redirect(uri)
84
85
return uri
85
86
end
86
87
87
- function build_local_docs (packagespec, buildpath, uri, pkgroot = nothing ; gitdirdocs = false , src_prefix= " " , href_prefix= " " )
88
+ function build_local_docs (packagespec, buildpath, uri, pkgroot = nothing ; gitdirdocs = false , src_prefix= " " , href_prefix= " " , html_size_threshold_bytes = nothing )
88
89
uri = something (uri, " docs" )
89
90
mktempdir () do envdir
90
91
pkgname = packagespec. name
@@ -110,7 +111,7 @@ function build_local_docs(packagespec, buildpath, uri, pkgroot = nothing; gitdir
110
111
for docdir in joinpath .(pkgroot, unique ([uri, " docs" , " doc" ]))
111
112
if isdir (docdir)
112
113
@info (" Building vendored Documenter.jl documentation at $(docdir) ." )
113
- output = build_documenter (packagespec, docdir)
114
+ output = build_documenter (packagespec, docdir; html_size_threshold_bytes )
114
115
@info (" Documentation built at $(output) ." )
115
116
if output != = nothing
116
117
@info (" Copying build documentation from $(output) to $(buildpath) " )
@@ -139,7 +140,7 @@ function build_local_docs(packagespec, buildpath, uri, pkgroot = nothing; gitdir
139
140
140
141
# fallback docs (readme & docstrings)
141
142
return mktempdir () do docsdir
142
- output = build_readme_docs (pkgname, pkgroot, docsdir, src_prefix, href_prefix, could_use_pkg)
143
+ output = build_readme_docs (pkgname, pkgroot, docsdir, src_prefix, href_prefix, could_use_pkg, html_size_threshold_bytes )
143
144
if output != = nothing
144
145
cp (output, buildpath, force = true )
145
146
return Dict (
@@ -161,7 +162,7 @@ function build_local_docs(packagespec, buildpath, uri, pkgroot = nothing; gitdir
161
162
end
162
163
end
163
164
164
- function build_legacy_documenter (packagespec, docdir)
165
+ function build_legacy_documenter (packagespec, docdir; html_size_threshold_bytes = nothing )
165
166
open (joinpath (docdir, " Project.toml" ), " w" ) do io
166
167
println (io, """
167
168
[deps]
@@ -171,16 +172,16 @@ function build_legacy_documenter(packagespec, docdir)
171
172
Documenter = "~0.20"
172
173
""" )
173
174
end
174
- build_documenter (packagespec, docdir)
175
+ build_documenter (packagespec, docdir; html_size_threshold_bytes )
175
176
end
176
177
177
- function build_documenter (packagespec, docdir)
178
+ function build_documenter (packagespec, docdir; html_size_threshold_bytes = nothing )
178
179
pkgdir = normpath (joinpath (docdir, " .." ))
179
180
cd (pkgdir) do
180
181
docsproject = joinpath (docdir, " Project.toml" )
181
182
docsmanifest = joinpath (docdir, " Manifest.toml" )
182
183
if ! isfile (docsproject)
183
- return build_legacy_documenter (packagespec, docdir)
184
+ return build_legacy_documenter (packagespec, docdir; html_size_threshold_bytes )
184
185
end
185
186
186
187
# fix permissions to allow us to add the main pacakge to the docs project
@@ -190,7 +191,7 @@ function build_documenter(packagespec, docdir)
190
191
chmod (joinpath (pkgdir, " Project.toml" ), 0o660 )
191
192
isfile (joinpath (pkgdir, " Manifest.toml" )) && chmod (joinpath (pkgdir, " Manifest.toml" ), 0o660 )
192
193
193
- rundcocumenter = joinpath (@__DIR__ , " rundocumenter.jl" )
194
+ rundocumenter = joinpath (@__DIR__ , " rundocumenter.jl" )
194
195
195
196
makefile = joinpath (docdir, " make.jl" )
196
197
if ! isfile (makefile)
@@ -203,15 +204,17 @@ function build_documenter(packagespec, docdir)
203
204
makefile = joinpath (docdir, jlfiles[1 ])
204
205
@info (" Using $(makefile) to generate Documenter docs." )
205
206
end
206
- _, builddir = fix_makefile (makefile)
207
+ _, builddir = fix_makefile (makefile; html_size_threshold_bytes )
207
208
pkgimagesopt = VERSION >= v " 1.9" ? " --pkgimages=no" : " "
209
+ opt_ser = isnothing (html_size_threshold_bytes) ? " -" : html_size_threshold_bytes
208
210
cmd = ```
209
211
$(julia ())
210
212
--project="$(docdir) "
211
213
$(isempty (pkgimagesopt) ? [] : pkgimagesopt)
212
- $(rundcocumenter )
214
+ $(rundocumenter )
213
215
$(pkgdir)
214
216
$(makefile)
217
+ $(opt_ser)
215
218
```
216
219
217
220
try
@@ -229,7 +232,7 @@ function build_documenter(packagespec, docdir)
229
232
end
230
233
end
231
234
232
- function build_readme_docs (pkgname, pkgroot, docsdir, src_prefix, href_prefix, could_use_pkg)
235
+ function build_readme_docs (pkgname, pkgroot, docsdir, src_prefix, href_prefix, could_use_pkg, html_size_threshold_bytes = nothing )
233
236
@info (" Generating readme-only fallback docs." )
234
237
235
238
if pkgroot === nothing || ! ispath (pkgroot)
@@ -265,7 +268,11 @@ function build_readme_docs(pkgname, pkgroot, docsdir, src_prefix, href_prefix, c
265
268
end
266
269
end
267
270
end
268
-
271
+ doc_format_str = if isnothing (html_size_threshold_bytes)
272
+ " Documenter.HTML()"
273
+ else
274
+ " Documenter.HTML(;size_threshold=$html_size_threshold_bytes )"
275
+ end
269
276
makejl_str = """
270
277
using Pkg
271
278
Pkg.add(name="Documenter", version="1")
@@ -275,7 +282,7 @@ function build_readme_docs(pkgname, pkgroot, docsdir, src_prefix, href_prefix, c
275
282
using $(pkgname)
276
283
277
284
makedocs(
278
- format = Documenter.HTML( ),
285
+ format = $(doc_format_str ) ,
279
286
sitename = "$(pkgname) .jl",
280
287
modules = [$(pkgname) ],
281
288
root = "$(docsdir) ",
0 commit comments