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

#![deny(missing_docs)] prevents compilation when using #[automock] #104

Closed
codehearts opened this issue Feb 24, 2020 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@codehearts
Copy link

I'm trying to export mocks behind a feature flag in a project with #![deny(missing_docs)] set. My trait and all of its members are documented, but the output of #[automock] causes "missing documentation for" messages:

My example source:

/// Trait for abstracting connections to the database
///
/// A `MockDatabaseAbstraction` struct is exported when the "mockall" feature is used
#[cfg_attr(feature = "mockall", automock)]
pub trait DatabaseAbstraction {
    /// Selects a row for a user login, otherwise `None` is returned
    ///
    /// # Errors
    ///
    /// When a connection can't be obtained from the pool, or the query fails
    fn read_user_login(
        &self,
        user_id: u64,
    ) -> Result<Option<Login>, std::io::Error>;
}

My example output (line numbers are slightly off due to other boilerplate code):

error: missing documentation for a module
  --> src/example.rs:24:33
   |
24 | #[cfg_attr(feature = "mockall", automock)]
   |                                 ^^^^^^^^
   |
note: lint level defined here
  --> src/lib.rs:10:9
   |
10 | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^

error: missing documentation for a struct
  --> src/example.rs:24:33
   |
24 | #[cfg_attr(feature = "mockall", automock)]
   |                                 ^^^^^^^^

error: missing documentation for a module
  --> src/example.rs:24:33
   |
24 | #[cfg_attr(feature = "mockall", automock)]
   |                                 ^^^^^^^^

error: missing documentation for a method
  --> src/example.rs:24:33
   |
24 | #[cfg_attr(feature = "mockall", automock)]
   |                                 ^^^^^^^^

error: aborting due to 4 previous errors

It might be useful to carry over the documentation of the trait itself, and fill in something generic for the generated module. Some IDEs may display useful hints when writing mocked tests

@asomers
Copy link
Owner

asomers commented Feb 24, 2020

Please try again, using the mock_doc_comments branch (the branch for PR #102). Do you still get the same errors?

@codehearts
Copy link
Author

It helps partially, but three of the errors persist:

error: missing documentation for a module
  --> src/example.rs:24:33
   |
24 | #[cfg_attr(feature = "mockall", automock)]
   |                                 ^^^^^^^^
   |
note: lint level defined here
  --> src/lib.rs:10:9
   |
10 | #![deny(missing_docs)]
   |         ^^^^^^^^^^^^

error: missing documentation for a module
  --> src/example.rs:24:33
   |
24 | #[cfg_attr(feature = "mockall", automock)]
   |                                 ^^^^^^^^

error: missing documentation for a method
  --> src/example.rs:24:33
   |
24 | #[cfg_attr(feature = "mockall", automock)]
   |                                 ^^^^^^^^

error: aborting due to 3 previous errors

Seems that only the generated struct received documentation in this case

asomers added a commit that referenced this issue Mar 12, 2020
asomers added a commit that referenced this issue Mar 13, 2020
@asomers asomers added the bug Something isn't working label Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants