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

Allow documentation at mock macro #100

Closed
MOZGIII opened this issue Feb 15, 2020 · 3 comments · Fixed by #102
Closed

Allow documentation at mock macro #100

MOZGIII opened this issue Feb 15, 2020 · 3 comments · Fixed by #102
Assignees

Comments

@MOZGIII
Copy link

MOZGIII commented Feb 15, 2020

The code produced by the mock! macro cannot be documented right now, but we would like to expose our mocks to the public and provide the documentation for them.
Can you please add support for documentation?

MOZGIII added a commit to pubnub/rust that referenced this issue Feb 15, 2020
MOZGIII added a commit to pubnub/rust that referenced this issue Feb 15, 2020
MOZGIII added a commit to pubnub/rust that referenced this issue Feb 15, 2020
MOZGIII added a commit to pubnub/rust that referenced this issue Feb 15, 2020
@asomers asomers self-assigned this Feb 15, 2020
@asomers
Copy link
Owner

asomers commented Feb 15, 2020

Yeah, I can probably make this work. Could you please provide a short example of what you want to do?

@MOZGIII
Copy link
Author

MOZGIII commented Feb 15, 2020

#![deny(missing_docs)]

// This code fails the missing docs check, simply put I want it to pass:

mock! {
    /// The mock for a `Trasport` interface. Use `MockTransport::new()` to create new mock.
    pub Transport {
        /// ...
        fn publish_request(
            &self,
            request: request::Publish,
        ) -> BoxFuture<'static, Result<Timetoken, MockTransportError>> {}

        /// ...
        fn subscribe_request(
            &self,
            request: request::Subscribe,
        ) -> BoxFuture<'static, Result<(Vec<Message>, Timetoken), MockTransportError>> {}
    }
    trait Clone {
        fn clone(&self) -> Self {}
    }
}

Just for clarity, in this example, the "main" trait is implemented separately (i.e. impl Transport for MockTransport { ... }).

asomers added a commit that referenced this issue Feb 20, 2020
Previously, the build would fail if the mock struct line contained a doc
comment.  Now, the build will pass, and doc comments on the struct and
methods will be propagated to the generated code.

Fixes #100
@asomers
Copy link
Owner

asomers commented Feb 20, 2020

@MOZGIII try the linked PR. Let me know if it fixes your problem.

asomers added a commit that referenced this issue Feb 20, 2020
Previously, the build would fail if the mock struct line contained a doc
comment.  Now, the build will pass, and doc comments on the struct and
methods will be propagated to the generated code.

Fixes #100
MOZGIII added a commit to pubnub/rust that referenced this issue Feb 21, 2020
asomers added a commit that referenced this issue Mar 11, 2020
Previously, the build would fail if the mock struct line contained a doc
comment.  Now, the build will pass, and doc comments on the struct and
methods will be propagated to the generated code.

Fixes #100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants