Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing_public_function_example / missing_private_function_example #12420

Open
tgross35 opened this issue Mar 5, 2024 · 2 comments
Open

missing_public_function_example / missing_private_function_example #12420

tgross35 opened this issue Mar 5, 2024 · 2 comments
Labels
A-lint Area: New lints

Comments

@tgross35
Copy link
Contributor

tgross35 commented Mar 5, 2024

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>
@tgross35 tgross35 added the A-lint Area: New lints label Mar 5, 2024
@tgross35
Copy link
Contributor Author

tgross35 commented Mar 5, 2024

I really feel like this has to exist or have been suggested somewhere, but I couldn't find it...

@tgross35 tgross35 changed the title missing_public_function_example / missing_private_function_example to flag missing_public_function_example / missing_private_function_example Mar 5, 2024
@Skgland
Copy link
Contributor

Skgland commented Mar 5, 2024

There is the rustdoc nightly-only missing_doc_code_examples lint, tracking issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

2 participants