Skip to content

About

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

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

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 finds duplicated Rust doctests, and optionally duplicated functions and code blocks, across a workspace. The wiki explains each check, the options and the Action in depth.

A pull request review by dejadoc, with an inline comment on a duplicated doctest and a suggestion that removes the copy

Usage

cargo install dejadoc
cargo dejadoc --functions --context-blocks
Check Enable Default minimum size Set the size
Doctests On by default 0 tokens --min-tokens
Functions --functions 30 weighted body tokens --fn-min-tokens
Contexts --context-blocks 30 canonical weighted tokens --context-min-tokens

Options can also live in .dejadoc.toml at the workspace root, and cargo dejadoc --help lists them all. Keep an intentional copy with a rust,dejadoc fence or a // dejadoc: allow line above the function. The wiki lists what counts as the same code.

GitHub Action

on: pull_request
jobs:
  dejadoc:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      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 }}
          functions: true

The action reviews the pull request and suggests removing each copy it introduces. action.yml lists every input, and these two workflows review pull requests from forks.

Library

let report = dejadoc::Dejadoc::default()
    .functions()
    .context_blocks()
    .run(".")
    .unwrap();
println!("{}", dejadoc::human(&report, false));

Use default-features = false, features = ["std"] to drop the CLI. Coding agents get the same guidance from the dejadoc skill.

npx skills add LucaCappelletti94/cargo-dejadoc

About

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

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages