rust-lang / rust-lang/rust-clippy
`missing_public_function_example` / `missing_private_function_example`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
What it does
missing_public_function_example would flag on functions that are:
- Accessible from outside the crate
- Do not have any examples at all
- 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 https://github.com/rust-lang/rust/pull/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>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named in the issue. Start by reviewing existing Clippy lint implementations and their tests, then determine the intended handling of public versus private functions, example matching, and unstable functions before defining what a complete implementation would require.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100