Skip to content

Commit 3fa1bc4

Browse files
committed
add some windows handling
1 parent c7354d8 commit 3fa1bc4

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

src/MultiDocumenter.jl

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,9 @@ function walk_outputs(f, root, docs::Vector{MultiDocRef}, dirs::Vector{String})
7474
p = joinpath(root, ref.path)
7575
for dir in dirs
7676
dirpath = joinpath(p, dir)
77-
# Symlinks do not really work on Windows. There are permissions problems and we can not
78-
# actually traverse them.
79-
if Sys.iswindows() && islink(dirpath)
80-
@warn "[WINDOWS] Symlink encountered at $(dirpath) -- excluding from search index, since symlinks are not properly supported on Windows."
77+
if !_windows_symlink_wrapper(isdir, dirpath)
8178
continue
8279
end
83-
isdir(dirpath) || continue
8480
DocumenterTools.walkdocs(dirpath, DocumenterTools.isdochtml) do fileinfo
8581
f(relpath(dirname(fileinfo.fullpath), root), fileinfo.fullpath)
8682
end
@@ -487,4 +483,27 @@ function inject_styles_and_global_navigation(
487483
end
488484
end
489485

486+
function _windows_symlink_wrapper(f::Base.Callable, path::AbstractString)
487+
if Sys.iswindows() && islink(path)
488+
if isinteractive()
489+
@warn """
490+
A symlink was ignored for $(f) at $(path)
491+
This only happens when running interactive on Windows."""
492+
return false
493+
else
494+
throw(SymlinkOnWindowsError())
495+
end
496+
end
497+
return f(path)
498+
end
499+
500+
struct SymlinkOnWindowsError <: Exception end
501+
function Base.showerror(io::IO, err::SymlinkOnWindowsError)
502+
print(io, """
503+
SymlinkOnWindowsError: this builds requires symlinks, but these are not properly supported in Windows
504+
You can still run the build interactively for debugging/testing (i.e. in the REPL), but the
505+
build will not exactly match the full build.""")
506+
print(io, err.msg)
507+
end
508+
490509
end

test/runtests.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,16 @@ MultiDocumenter.make(
107107
@testset "structure" begin
108108
@test isdir(outpath, "inf")
109109
@test !isdir(outpath, "inf", "previews")
110-
@test isdir(outpath, "inf", "stable")
111-
@test isfile(outpath, "inf", "stable", "index.html")
110+
if Sys.iswindows()
111+
# On Windows, symlinks are either kept as simple files, or are in fact
112+
# symlinks, but then you would run into permission errors with isdir().
113+
# So we need to have platform-specific test logic here.
114+
path = joinpath(outpath, "inf", "stable")
115+
@test islink(path) || isdir(path)
116+
else
117+
@test isdir(outpath, "inf", "stable")
118+
@test isfile(outpath, "inf", "stable", "index.html")
119+
end
112120

113121
@test read(joinpath(outpath, "inf", "index.html"), String) == """
114122
<!--This file is automatically generated by Documenter.jl-->

0 commit comments

Comments
 (0)