Skip to content

Commit

Permalink
feat: check URL fragments
Browse files Browse the repository at this point in the history
This implements URL fragment checking. Parsing is expanded to also
collect values of all `id` attributes.

For missing fragments in files a `CheckError::Fragment` will be returned
containing a path and the missing fragment.

In Rust documentation non-existent fragments in the form of `#n-m` is
used to highlight a range of lines in the source code. For fragments in
that form additional check is performed to test if all fragments `n`
through `m` exist. In case of missing items in a ranged fragment
`CheckError::Fragment` will be returned containing a path, the
missing ranged fragment, and missing items from the range.

Bare in mind that this introduces overhead of performing n+1 parsing or
fetching via HTTP. This is because multiple links pointing to the same
URL with different fragments end up fetching/parsing the same content
for each fragment. To help with that fragment caching is using
memoization using cached crate.

Fixes #7
  • Loading branch information
zregvart committed Nov 18, 2020
1 parent db618d2 commit 1d617ab
Show file tree
Hide file tree
Showing 10 changed files with 674 additions and 40 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@

* If a URL points to a directory, check if index.html exists in that directory. [PR#90]
* Treat absolute paths as absolute with respect to the `base_url`, not with respect to the file system. [PR#91]
* Check link fragments, with special handling for Rustdoc ranged fragments to highlight source code lines [PR#94]

[PR#90]: https://github.com/deadlinks/cargo-deadlinks/pull/90
[PR#91]: https://github.com/deadlinks/cargo-deadlinks/pull/91
[PR#94]: https://github.com/deadlinks/cargo-deadlinks/pull/94

#### Fixes

Expand Down
187 changes: 182 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ cargo = ["cargo_metadata", "serde_json"]
default = ["cargo"]

[dependencies]
cached = { version = "0.20.0", default-features = false }
cargo_metadata = { version = "0.9", optional = true }
serde_json = { version = "1.0.34", optional = true }
docopt = "1"
env_logger = "0.8"
lol_html = "0.2"
log = "0.4"
num_cpus = "1.8"
once_cell = "1.5.1"
rayon = "1.0"
regex = { version = "1", default-features = false, features = ["std", "perf"] }
ureq = { version = "1.5.2", features = ["tls"], default-features = false }
serde = "1.0"
serde_derive = "1.0"
Expand All @@ -39,3 +42,4 @@ walkdir = "2.1"
[dev-dependencies]
assert_cmd = "1.0"
predicates = "1.0.0"
mockito = "0.28.0"
Loading

0 comments on commit 1d617ab

Please sign in to comment.