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 13, 2020
1 parent 1240c7a commit c7b4642
Show file tree
Hide file tree
Showing 10 changed files with 619 additions and 40 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,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 @@ -9,13 +9,16 @@ readme = "README.md"
license = "MIT OR Apache-2.0"

[dependencies]
cached = { version = "0.20.0", default-features = false }
cargo_metadata = "0.9"
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 @@ -26,3 +29,4 @@ serde_json = "1.0.34"
[dev-dependencies]
assert_cmd = "1.0"
predicates = "1.0.0"
mockito = "0.28.0"
Loading

0 comments on commit c7b4642

Please sign in to comment.