-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from JuliaDocs/mg/58-linkcheck
Check links inside the bibliography
- Loading branch information
Showing
11 changed files
with
128 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using DocumenterCitations | ||
using Test | ||
using IOCapture: IOCapture | ||
|
||
include("run_makedocs.jl") | ||
|
||
|
||
@testset "Check invalid url in .bib file " begin | ||
|
||
# https://github.com/JuliaDocs/DocumenterCitations.jl/issues/58 | ||
|
||
root = splitext(@__FILE__)[1] | ||
|
||
bib = CitationBibliography(joinpath(root, "src", "invalidlink.bib"), style=:numeric) | ||
|
||
run_makedocs( | ||
root; | ||
linkcheck=true, | ||
sitename="Test", | ||
plugins=[bib], | ||
pages=["Home" => "index.md", "References" => "references.md",], | ||
check_failure=true, | ||
env=Dict("PATH" => "$root:$(ENV["PATH"])"), # Unix only | ||
# The updated PATH allows to use the mock `curl` in `root`. | ||
) do dir, result, success, backtrace, output | ||
|
||
@test !success | ||
@test contains(output, r"Error:.*http://www.invalid-server.doesnotexist/page.html") | ||
@test contains( | ||
output, | ||
"Error: linkcheck 'http://httpbin.org/status/404' status: 404." | ||
) | ||
@test contains( | ||
output, | ||
"Error: linkcheck 'http://httpbin.org/status/500' status: 500." | ||
) | ||
@test contains( | ||
output, | ||
"Error: linkcheck 'http://httpbin.org/status/403' status: 403." | ||
) | ||
@test contains(result.msg, "`makedocs` encountered an error [:linkcheck]") | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env julia | ||
|
||
RESPONSE = Dict( | ||
"http://httpbin.org/status/404" => "404 http://httpbin.org/status/404 ", | ||
"http://httpbin.org/status/500" => "500 http://httpbin.org/status/500 ", | ||
"http://httpbin.org/status/403" => "403 http://httpbin.org/status/403 ", | ||
) | ||
|
||
# The above responses must match what `curl` as called by the `linkcheck` | ||
# function in Documenter would return. In particular, `linkcheck` calls `curl` | ||
# with `--write-out "%{http_code} %{url_effective} %{redirect_url}"` | ||
|
||
if "--version" in ARGS | ||
println("mocked") | ||
exit(0) | ||
else | ||
url = ARGS[findfirst(startswith("http"), ARGS)] | ||
try | ||
print(RESPONSE[url]) | ||
catch | ||
# URLs not in RESPONSE will cause an failure, equivalent to the normal | ||
# `curl` not being able to connect. | ||
exit(1) | ||
end | ||
exit(0) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Testing link checks for broken links | ||
|
||
|
||
## Problem description | ||
|
||
The `linkcheck` option for `makedocs` should complain about [broken links](http://httpbin.org/status/403). | ||
|
||
Ref [GoerzPhd2015](@cite) contains broken links. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@phdthesis{GoerzPhd2015, | ||
Author = {Goerz, Michael}, | ||
Title = {Optimizing Robust Quantum Gates in Open Quantum Systems}, | ||
School = {Universität Kassel}, | ||
url = {http://www.invalid-server.doesnotexist/page.html}, | ||
Year = {2015}, | ||
note = {See \url{http://httpbin.org/status/404} for additional formats. Source available on \href{http://httpbin.org/status/500}{Github}}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## References | ||
|
||
```@bibliography | ||
``` |