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

Lint non-code syntax for variables in documentation comments #2178

Open
gnzlbg opened this issue Oct 26, 2017 · 5 comments
Open

Lint non-code syntax for variables in documentation comments #2178

gnzlbg opened this issue Oct 26, 2017 · 5 comments
Labels
C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. S-needs-discussion Status: Needs further discussion before merging or work can be started

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 26, 2017

Here:

/// This function adds a with `b`.
fn add(a: u32, b: u32) -> u32 { a + b };

note how in the documentation comment 'b' is quoted but a is not. We should lint about these.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 27, 2017

Your example is the one that's the most impossible... a is an english word.

We'd be getting false positives left and right even if we'd have some english language parser. Not really sure if we can act on this. Maybe somebody's got ideas how to do it.

@oli-obk oli-obk added C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. S-needs-discussion Status: Needs further discussion before merging or work can be started labels Oct 27, 2017
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 27, 2017

Your example is the one that's the most impossible... a is an english word.

Indeed.

How do Rust IDEs infer what variables do?

For example in C++ there is the Doxygen format which IDEs use it to give detailed descriptions of the arguments and return type, something like:

/// Adds two values. 
///
/// Long description.
///
/// # Arguments
///
/// - `T`: type of the arguments to add
/// - `a`: argument to add
/// - `b`: argument to add
///
/// # Returns
///
/// Sum of `a` and `b`.
///
/// # Panics
///
/// If the sum of `a` and `b` overflows.
///
/// # Complexity
/// 
/// - time: O(1) 
/// - space: O(1)
fn add<T>(a: T, b: T) -> T;

@oli-obk
Copy link
Contributor

oli-obk commented Oct 27, 2017

I'd really want to have

fn add<T>(
    /// super first argument
    a: T,
    /// horrible second argument
    b: T,
/// Returns sum of `a` and `b`
) -> T;

Maybe I'll do an rfc next year

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Oct 27, 2017

@oli-obk we should ping the new rustdoc repo on this as well. It might be easier to prototype this there than in the old rustdoc.

@killercup
Copy link
Member

@gnzlbg cf #1007 (comment) re: doc format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-an-interesting-project Category: Interesting projects, that usually are more involved design/code wise. S-needs-discussion Status: Needs further discussion before merging or work can be started
Projects
None yet
Development

No branches or pull requests

3 participants