Skip to content

Commit a46926d

Browse files
authored
Merge pull request #70 from fredrikekre/fe/servedocs
Fix #69 and add verbose option to servedocs
2 parents 18170d0 + 882b2ef commit a46926d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/utils.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function servedocs_callback(fp::AbstractString, vwf::Vector{WatchedFile}, makejl
3131
# changes from docs/src create change in docs/build which trigger a pass which
3232
# regenerates files in docs/build etc...
3333
if ismakejl || occursin(joinpath("docs", "src"), fp)
34-
include(makejl)
34+
Main.include(makejl)
3535
file_changed_callback(fp)
3636
end
3737
return nothing
@@ -60,25 +60,27 @@ function scan_docs!(dw::SimpleWatcher)
6060
end
6161

6262
"""
63-
servedocs()
63+
servedocs(; verbose=false)
6464
65-
Can be used when developping a package to run the `docs/make.jl` file from Documenter.jl and
65+
Can be used when developing a package to run the `docs/make.jl` file from Documenter.jl and
6666
then serve the `docs/build` folder with LiveServer.jl. This function assumes you are in the
6767
directory `[MyPackage].jl` with a subfolder `docs`.
68+
69+
* `verbose` is a boolean switch to make the server print information about file changes and connections.
6870
"""
69-
function servedocs()
71+
function servedocs(; verbose::Bool=false)
7072
# Custom file watcher: it's the standard `SimpleWatcher` but with a custom callback.
7173
docwatcher = SimpleWatcher()
7274
set_callback!(docwatcher, fp->servedocs_callback(fp, docwatcher.watchedfiles, makejl))
7375

7476
makejl = scan_docs!(docwatcher)
7577

7678
# trigger a first pass of Documenter
77-
include(makejl)
79+
Main.include(makejl)
7880

7981
# note the `docs/build` exists here given that if we're here it means the documenter
8082
# pass did not error and therefore that a docs/build has been generated.
81-
serve(docwatcher, dir=joinpath("docs", "build"))
83+
serve(docwatcher, dir=joinpath("docs", "build"), verbose=verbose)
8284

8385
return nothing
8486
end

0 commit comments

Comments
 (0)