Skip to content

missing_public_function_example / missing_private_function_example #12420

Open
@tgross35

Description

@tgross35

What it does

missing_public_function_example would flag on functions that are:

  1. Accessible from outside the crate
  2. Do not have any examples at all
  3. Or have examples but nothing with that function name (iffy about this one, it would probably just be a text search rather than actually trying to understand the code in the examples)

missing_private_function_example would flag in the same cases except also for internal functions.

Maybe there could be a config option to ignore unstable functions so this could be used in std.

Don't look for a # Examples header because a lot of times it isn't there or isn't needed.

Advantage

This will help identify functions that have no example of usage, inspired by rust-lang/rust#121213.

Drawbacks

Possible FNs if this tries to detect the function in the example by name, but the example doesn't actually resolve to this function.

Example

/// Use this when you want to order drinks at the foobar
pub fn foo(bar: i32) {}

Could be written as:

/// Use this when you want to order drinks at the foobar
///
/// ```
/// foo(10);
/// ```
pub fn foo(bar: i32) {}
<code>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions