Is there a way to hide a Rust macro pattern from docs?

As of Rust 1.6.0 , patterns in macro have hidden implementation.

Is there a way to hide some of the patterns from the Cargo-generated docs? Or am I left with extracting them to separate macros and adding #[doc(hidden)] to those?

macro_rules! mc {
    /// hide this
    ( ... ) => ( ... );
}

Since there is no other answer, I guess this is the optimum solution:

/// Not meant to be called directly
#[doc(hidden)]
#[macro_export]
macro_rules! hidden {
    ( $hidden_rule1:expr ) => { ... };
    ( $hidden_rule2:expr ) => { ... };
    ...
}

#[macro_export]
macro_rules! public {
    ( $public:expr ) => ( hidden!($public) );
}

You're using a separate hidden macro (which will probably needs to be public) but which is not part of the documentation. All the rules that should be hidden will be hidden and the public one will be visible in the public macro which is part of the documentation.

链接地址: http://www.djcxy.com/p/32166.html

上一篇: 如何阅读谷歌日历中的提醒

下一篇: 有没有办法从文档中隐藏Rust宏模式?