Michael-F-Bryan / mdbook-linkcheck

A backend for `mdbook` which will check your links for you.

Home Page:https://michael-f-bryan.github.io/mdbook-linkcheck/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Push new versions to crates.io?

mark-i-m opened this issue · comments

commented

It looks like the most recent version is 0.1.2

Yep, looking at the commits that seems to be correct. 96f6df3 is the 0.1.2 commit then f5a489d (master) just bumps the version in Cargo.toml to start the 0.1.3 release cycle.

Is there anything in particular you'd like me to make a new release for? (e.g. a bug fix or new feature).

commented

It seems that compatibility is broken with the latest mdbook (0.2). For example, link check passes in rust-lang/rustc-dev-guide#184 but shouldn't.

Ah. I think that's because mdbook-linkcheck is linking against v0.1.* instead of v0.2.0. I just updated all dependencies and ran the new linkcheck against rustc-guide.

$ RUST_LOG=mdbook_linkcheck=trace mdbook build >debug_output.txt 2>&1 
$ tail debug_output.txt 
TRACE 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Checking "https://github.com/rust-lang/rust/tree/master/src/librustdoc" in rustdoc.md#6
DEBUG 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Ignoring "https://en.wikipedia.org/wiki/Abstract_syntax_tree"
DEBUG 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Ignoring "https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/driver/struct.CompileState.html"
DEBUG 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Searching for /home/michael/Documents/forks/rustc-guide/src/ty.md
DEBUG 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Ignoring "https://github.com/rust-lang-nursery/chalk/blob/94a1941a021842a5fcb35cd043145c8faae59f08/src/ir.rs#L721"
TRACE 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Checking "ty.html" in appendix/glossary.md#67
DEBUG 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Ignoring "https://github.com/rust-lang/rust/tree/master/src/librustdoc"
TRACE 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Checking "https://en.wikipedia.org/wiki/Universal_quantification" in traits/chalk-overview.md#61
DEBUG 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Searching for /home/michael/Documents/forks/rustc-guide/src/ty.md
DEBUG 2018-08-24T12:29:04Z: mdbook_linkcheck::validation: Ignoring "https://en.wikipedia.org/wiki/Universal_quantification"

By default it'll ignore links that require searching the internet (because they take forever), but there's a follow-web-links config option.

diff --git a/book.toml b/book.toml
index ecbe513..aca502a 100644
--- a/book.toml
+++ b/book.toml
@@ -6,5 +6,6 @@ description = "A guide to developing rustc"
 [output.html]
 
 [output.linkcheck]
+follow-web-links = true
 
 [output.html.search]

I really need to document that in the README!

After updating book.toml this is what I see:

$ RUST_LOG=mdbook_linkcheck=trace mdbook build >debug_output_with_follow.txt 2>&1  
$ tail -f debug_output_with_follow.txt
DEBUG 2018-08-24T12:31:40Z: mdbook_linkcheck::validation: Fetching "https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.Ident.html"
TRACE 2018-08-24T12:31:40Z: mdbook_linkcheck::validation: Checking "./tests/adding.html" in compiletest.md#25
DEBUG 2018-08-24T12:31:40Z: mdbook_linkcheck::validation: Searching for /home/michael/Documents/forks/rustc-guide/src/./tests/adding.md
TRACE 2018-08-24T12:31:40Z: mdbook_linkcheck::validation: Checking "https://github.com/rust-lang/rust/tree/master/src/test" in compiletest.md#31
DEBUG 2018-08-24T12:31:40Z: mdbook_linkcheck::validation: Fetching "https://github.com/rust-lang/rust/tree/master/src/test"
There were 4 broken links:
tests/intro.md#174: "https://crates.io/" returned 404 Not Found
diag.md#303: "https://doc.rust-lang.org/nightly/nightly-rustc/syntax/early_buffered_lints/struct.BufferedEarlyLintId.html" returned 404 Not Found
appendix/stupid-stats.md#77: "https://github.com/rust-lang/rust/tree/master/src/librustc_trans" returned 404 Not Found
appendix/stupid-stats.md#86: "https://github.com/rust-lang/rust/tree/master/src/librustc_back" returned 404 Not Found

debug_output_with_follow.txt

Other than the https://crates.io/, does the output make sense to you? I may need to tweak the inter-chapter link checking logic though. v0.2.0 changes to using relative links everywhere, doesn't it?

commented

@Michael-F-Bryan I would expect far more broken links reported. Shouldn't all of the relative links to other parts of rustc-guide be reported?

@mark-i-m I built the book locally with v0.2.1 and skimming through it seems like all the links are correct and working. mdbook uses relative links to link pages, which is the same logic that mdbook-linkcheck is checking for.

I think I've done things correctly, but I haven't would you be able to build mdbook-linkcheck locally and find an example of a broken link that's slipping through the link checker?

commented

@Michael-F-Bryan I think it only shows up with nested, relative links. For example,
I just installed mdbook 0.2.1 and mdbook-linkcheck from the master branch of this repo (and verified that cargo used mdbook 0.2.1). No errors are reported, but the following link is broken:

https://github.com/rust-lang-nursery/rustc-guide/blob/master/src/traits/goals-and-clauses.md#L5

EDIT: I just realized that GitHub doesn't show the line very well. It is the "lowering to logic" link in the first paragraph.

I ran mdbook-linkcheck (latest #85269856031b4c091b79d1546efe0ed94f4e6743) on a private mdbook and had a lot less problems than with the current stable mdbook-linkcheck. E.g. the stable mdbook-linkcheck failed to find local md links e.g. ./chapter_1.md. So I think it's kind of worth releasing it even if there are still problems.

@mark-i-m I just added a test for nested relative links (d6ec161 and 5cfd434) and it looks like they're detected correctly 😞 I've been looking through the logs and am genuinely confused why that lowering-to-traits link is turned into a correct path...

@marcelbuesing has a good point. I think I'll release a v0.2.0 so we're in sync with mdbook again, even if I can't figure out why some seemingly broken links are still slipping through.

commented

Would it help if I turned on debug logging in my PR?

So... I just found the problem. Turns out I didn't update everything when updating from absolute to relative paths with mdbook v0.2. Of course I didn't find this until just after releasing v0.2.0 for mdbook-linkcheck.

@mark-i-m would you be able to run the link checker against rustc-guide using the latest master and see if the reported errors are correct?

commented

This looks much more promising!

$ mdbook build
2018-09-08 21:10:41 [INFO] (mdbook::book): Book building has started
2018-09-08 21:10:41 [INFO] (mdbook::book): Running the html backend
2018-09-08 21:10:41 [INFO] (mdbook::book): Running the linkcheck backend
2018-09-08 21:10:41 [INFO] (mdbook::renderer): Invoking the "linkcheck" renderer
There were 128 broken links:
tests/intro.md#8: "./tests/running.html" doesn't exist
tests/intro.md#9: "./tests/adding.html" doesn't exist
tests/intro.md#27: "./tests/adding.html" doesn't exist
tests/intro.md#62: "./conventions.html" doesn't exist
tests/adding.md#12: "./conventions.html" doesn't exist
traits/resolution.md#9: "./traits/index.html" doesn't exist
traits/resolution.md#215: "./param_env.html" doesn't exist
traits/caching.md#23: "./traits/resolution.html" doesn't exist
traits/caching.md#34: "./traits/resolution.html" doesn't exist
traits/caching.md#50: "./param_env.html" doesn't exist
traits/caching.md#51: "./ty.html" doesn't exist
traits/index.md#7: "./traits/resolution.html" doesn't exist
traits/index.md#16: "./traits/lowering-to-logic.html" doesn't exist
traits/index.md#18: "./traits/goals-and-clauses.html" doesn't exist
traits/index.md#20: "./traits/lowering-rules.html" doesn't exist
traits/index.md#22: "./traits/canonical-queries.html" doesn't exist
traits/index.md#26: "./traits/associated-types.html" doesn't exist
traits/index.md#29: "./traits/regions.html" doesn't exist
traits/lowering-to-logic.md#170: "./traits/bibliography.html" doesn't exist
traits/lowering-to-logic.md#171: "./traits/bibliography.html" doesn't exist
traits/goals-and-clauses.md#5: "./traits/lowering-to-logic.html" doesn't exist
traits/goals-and-clauses.md#37: "./traits/bibliography.html" doesn't exist
traits/goals-and-clauses.md#96: "./traits/associated-types.html" doesn't exist
traits/goals-and-clauses.md#102: "./traits/associated-types.html" doesn't exist
traits/goals-and-clauses.md#104: "./traits/associated-types.html" doesn't exist
traits/goals-and-clauses.md#133: "./traits/lowering-rules.html" doesn't exist
traits/goals-and-clauses.md#149: "./traits/lowering-rules.html" doesn't exist
traits/goals-and-clauses.md#213: "./traits/lowering-rules.html" doesn't exist
traits/associated-types.md#20: "./type-checking.html" doesn't exist
traits/associated-types.md#133: "./type-inference.html" doesn't exist
traits/canonical-queries.md#6: "./query.html" doesn't exist
traits/canonical-queries.md#10: "./traits/associated-types.html" doesn't exist
traits/canonical-queries.md#109: "./traits/slg.html" doesn't exist
traits/canonical-queries.md#135: "./traits/regions.html" doesn't exist
traits/canonical-queries.md#220: "./type-checking.html" doesn't exist
traits/canonicalization.md#5: "./traits/canonical-queries.html" doesn't exist
traits/canonicalization.md#9: "./type-inference.html" doesn't exist
traits/canonicalization.md#44: "./appendix/background.html" doesn't exist
traits/canonicalization.md#101: "./traits/slg.html" doesn't exist
traits/canonicalization.md#102: "./traits/canonical-queries.html" doesn't exist
traits/canonicalization.md#132: "./traits/canonical-queries.html" doesn't exist
traits/lowering-rules.md#4: "./traits/goals-and-clauses.html" doesn't exist
traits/lowering-rules.md#5: "./traits/goals-and-clauses.html" doesn't exist
traits/lowering-rules.md#19: "./traits/goals-and-clauses.html" doesn't exist
traits/lowering-rules.md#36: "./traits/goals-and-clauses.html" doesn't exist
traits/lowering-rules.md#144: "./traits/goals-and-clauses.html" doesn't exist
traits/lowering-rules.md#269: "./traits/associated-types.html" doesn't exist
traits/lowering-module.md#4: "./traits/lowering-rules.html" doesn't exist
traits/lowering-module.md#11: "./query.html" doesn't exist
traits/chalk-overview.md#10: "traits/lowering-to-logic.html" doesn't exist
traits/chalk-overview.md#11: "traits/lowering-rules.html" doesn't exist
traits/chalk-overview.md#62: "./traits/lowering-to-logic.html" doesn't exist
traits/chalk-overview.md#71: "./traits/goals-and-clauses.html" doesn't exist
traits/chalk-overview.md#102: "hir.html" doesn't exist
traits/chalk-overview.md#115: "traits/lowering-rules.html" doesn't exist
traits/chalk-overview.md#130: "./traits/slg.html" doesn't exist
mir/index.md#4: "./hir.html" doesn't exist
mir/index.md#25: "./appendix/background.html" doesn't exist
mir/index.md#39: "./appendix/background.html" doesn't exist
mir/index.md#215: "appendix/glossary.html" doesn't exist
mir/index.md#218: "appendix/glossary.html" doesn't exist
mir/passes.md#128: "mir/visitor.html" doesn't exist
mir/passes.md#159: "./query.html" doesn't exist
mir/borrowck.md#15: "hir.html" doesn't exist
mir/borrowck.md#46: "./appendix/glossary.html" doesn't exist
mir/borrowck.md#47: "./mir/regionck.html" doesn't exist
mir/borrowck.md#48: "./appendix/background.html" doesn't exist
mir/borrowck.md#54: "./mir/regionck.html" doesn't exist
mir/regionck.md#16: "appendix/background.html" doesn't exist
mir/regionck.md#134: "appendix/background.html" doesn't exist
mir/regionck.md#151: "./appendix/background.html" doesn't exist
mir/regionck.md#190: "./appendix/background.html" doesn't exist
appendix/background.md#97: "./variance.html" doesn't exist
appendix/glossary.md#10: "./appendix/background.html" doesn't exist
appendix/glossary.md#11: "./appendix/background.html" doesn't exist
appendix/glossary.md#15: "./appendix/background.html" doesn't exist
appendix/glossary.md#16: "./const-eval.html" doesn't exist
appendix/glossary.md#18: "incremental-compilation.html" doesn't exist
appendix/glossary.md#19: "./appendix/background.html" doesn't exist
appendix/glossary.md#25: "./appendix/background.html" doesn't exist
appendix/glossary.md#26: "ty.html" doesn't exist
appendix/glossary.md#28: "hir.html" doesn't exist
appendix/glossary.md#39: "./mir/index.html" doesn't exist
appendix/glossary.md#40: "./miri.html" doesn't exist
appendix/glossary.md#41: "./traits/associated-types.html" doesn't exist
appendix/glossary.md#43: "./mir/regionck.html" doesn't exist
appendix/glossary.md#45: "traits/resolution.html" doesn't exist
appendix/glossary.md#46: "./traits/goals-and-clauses.html" doesn't exist
appendix/glossary.md#47: "./mir/index.html" doesn't exist
appendix/glossary.md#48: "query.html" doesn't exist
appendix/glossary.md#49: "./appendix/background.html" doesn't exist
appendix/glossary.md#50: "query.html" doesn't exist
appendix/glossary.md#52: "./name-resolution.html" doesn't exist
appendix/glossary.md#56: "./mir/regionck.html" doesn't exist
appendix/glossary.md#60: "ty.html" doesn't exist
appendix/glossary.md#61: "ty.html" doesn't exist
appendix/glossary.md#62: "./traits/goals-and-clauses.html" doesn't exist
appendix/glossary.md#63: "the-parser.html" doesn't exist
appendix/glossary.md#66: "ty.html" doesn't exist
appendix/glossary.md#67: "ty.html" doesn't exist
appendix/glossary.md#68: "type-checking.html" doesn't exist
appendix/glossary.md#71: "./appendix/background.html" doesn't exist
appendix/glossary.md#71: "./variance.html" doesn't exist
appendix/code-index.md#9: "hir.html" doesn't exist
appendix/code-index.md#10: "rustc-driver.html" doesn't exist
appendix/code-index.md#11: "the-parser.html" doesn't exist
appendix/code-index.md#12: "hir.html" doesn't exist
appendix/code-index.md#13: "hir.html" doesn't exist
appendix/code-index.md#14: "diag.html" doesn't exist
appendix/code-index.md#15: "rustdoc.html" doesn't exist
appendix/code-index.md#16: "hir.html" doesn't exist
appendix/code-index.md#17: "hir.html" doesn't exist
appendix/code-index.md#18: "param_env.html" doesn't exist
appendix/code-index.md#19: "the-parser.html" doesn't exist
appendix/code-index.md#20: "name-resolution.html" doesn't exist
appendix/code-index.md#21: "the-parser.html" doesn't exist
appendix/code-index.md#21: "rustc-driver.html" doesn't exist
appendix/code-index.md#22: "the-parser.html" doesn't exist
appendix/code-index.md#23: "the-parser.html" doesn't exist
appendix/code-index.md#24: "diag.html" doesn't exist
appendix/code-index.md#25: "the-parser.html" doesn't exist
appendix/code-index.md#26: "the-parser.html" doesn't exist
appendix/code-index.md#26: "macro-expansion.html" doesn't exist
appendix/code-index.md#27: "ty.html" doesn't exist
appendix/code-index.md#28: "traits/goals-and-clauses.html" doesn't exist
appendix/code-index.md#28: "traits/lowering-rules.html" doesn't exist
appendix/code-index.md#29: "type-checking.html" doesn't exist
appendix/code-index.md#30: "ty.html" doesn't exist
2018-09-08 21:10:41 [ERROR] (mdbook::renderer): Renderer exited with non-zero return code.
2018-09-08 21:10:41 [ERROR] (mdbook::utils): Error: Rendering failed
2018-09-08 21:10:41 [ERROR] (mdbook::utils): 	Caused By: The "linkcheck" renderer failed
commented

All of these errors look reasonable, judging by the paths printed.

Awesome! If that's the case, I'm going to make a 0.2.1 release.