dejadoc 0.1.4

Find duplicated Rust doctests across a workspace
Documentation

cargo-dejadoc

CI codecov Quality Gate crates.io docs.rs

Whoa, deja vu. A doctest went past us, and then another that looked just like it.

cargo dejadoc scans and canonicalizes every doctest your workspace's rustdoc would run, reporting any identified duplicates.

The flags under cargo dejadoc --help restrict the package, set the threshold and minimum token count, point at a config file, and switch the output to JSON. Without flags, parameters come from .dejadoc.toml at the workspace root.

To allow a known copy, add the dejadoc token to the fence's info list, as in rust,dejadoc. rustdoc runs the doctest and ignores the unknown token, so nothing else about the site changes.

In CI, the composite action installs the crate and runs the gate.

- uses: LucaCappelletti94/cargo-dejadoc@v1
  with:
    threshold: 2

In a pull request, the action posts the findings as a review instead of failing the job.

on: pull_request
jobs:
  dejadoc:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: LucaCappelletti94/cargo-dejadoc@v1
        with:
          pr-number: ${{ github.event.pull_request.number }}

The review lists every duplicated group, and each site gets an inline comment when its file is part of the pull request diff. Sites that cannot be commented inline are listed in the review body. Pull requests from forks run with a read-only GITHUB_TOKEN, so the action skips the review with a warning. To post on fork pull requests, enable the repository setting Send write tokens to workflows from pull requests, use pull_request_target, or supply a write token.

The library builds the same report in memory.

let report = dejadoc::Dejadoc::default().run("tests/fixtures/dupws").unwrap();
assert_eq!(report.groups.len(), 2);