Skip to content

Commit

Permalink
Skip redirect if no entry to redirect to, fixes #1693 (#1704)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson authored Sep 25, 2021
1 parent 9dfdae2 commit d01a54c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Documenter.jl changelog

## Version `v0.27.7`

* ![Bugfix][badge-bugfix] Fix an error when building documentation for the first time with `push_preview`. ([#1704][github-1704])

## Version `v0.27.6`

* ![Feature][badge-feature] Add support for generating `index.html` to redirect to `dev` or `stable`. The redirected destination is the same as the outdated warning. If there's already user-generated `index.html`, Documenter will not overwrite the file. ([#937][github-937], [#1657][github-1657], [#1658][github-1658])
Expand Down Expand Up @@ -910,6 +914,7 @@
[github-1665]: https://github.com/JuliaDocs/Documenter.jl/pull/1665
[github-1687]: https://github.com/JuliaDocs/Documenter.jl/pull/1687
[github-1691]: https://github.com/JuliaDocs/Documenter.jl/pull/1691
[github-1704]: https://github.com/JuliaDocs/Documenter.jl/pull/1704

[julia-38079]: https://github.com/JuliaLang/julia/issues/38079
[julia-39841]: https://github.com/JuliaLang/julia/pull/39841
Expand Down
1 change: 1 addition & 0 deletions src/Writers/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ function generate_redirect_file(redirectfile::AbstractString, entries)
comment = "<!--This file is automatically generated by Documenter.jl-->"

isfile(redirectfile) && !startswith(read(redirectfile, String), comment) && return
isempty(entries) && return

open(redirectfile, "w") do buf
println(buf, comment)
Expand Down
8 changes: 8 additions & 0 deletions test/htmlwriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ end
verify_version_file(versionfile, entries)
generate_redirect_file(redirectfile, entries)
verify_redirect_file(redirectfile, "dev")

# Case 7: no entries
entries = String[]
generate_version_file(versionfile, entries)
verify_version_file(versionfile, entries)
rm(redirectfile)
generate_redirect_file(redirectfile, entries)
@test !isfile(redirectfile)
end

# Exhaustive Conversion from Markdown to Nodes.
Expand Down

0 comments on commit d01a54c

Please sign in to comment.