Skip to content

Should respect target with doc=false when determining docs to check #99

@ayazhafiz

Description

@ayazhafiz

Currently doc = false in a package's manifest is not respected when determining whether a target's docs should be checked:

cargo-deadlinks/src/main.rs

Lines 133 to 150 in fd46075

fn has_docs(target: &cargo_metadata::Target) -> bool {
// Ignore tests, examples, and benchmarks, but still document binaries
// See https://doc.rust-lang.org/cargo/reference/external-tools.html#compiler-messages
// and https://github.com/rust-lang/docs.rs/issues/503#issuecomment-562797599
// for the difference between `kind` and `crate_type`
let mut kinds = target.kind.iter();
// By default, ignore binaries
if target.crate_types.contains(&"bin".into()) {
// But allow them if this is a literal bin, and not a test or example
kinds.all(|kind| kind == "bin")
} else {
// We also have to consider examples and tests that are libraries
// (e.g. because of `cdylib`).
kinds.all(|kind| !["example", "test", "bench"].contains(&kind.as_str()))
}
}

Furthermore, cargo metadata does not seem to report the value of the doc setting for targets, so this is probably an upstream bug to cargo folks first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargoArea: Determining directories based on `cargo metadata`C-bugCategory: This is a bugS-blockedStatus: Blocked on another project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions