Skip to content

Commit

Permalink
Fix documentation for derives and hide internal things
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Apr 28, 2024
1 parent 2203c97 commit 16bf8d7
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
- run: cargo doc --lib --no-deps --document-private-items
- run: cargo doc --all-features --lib --no-deps --document-private-items
env:
RUSTFLAGS: --cfg doc_cfg
RUSTDOCFLAGS: --cfg doc_cfg -Dwarnings
18 changes: 0 additions & 18 deletions crates/musli-core/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@
//! }
//! ```

/// Derive which automatically implements the [`Decode` trait].
///
/// See the [`derives` module] for detailed documentation.
///
/// [`derives` module]: <https://docs.rs/musli/latest/musli/help/derives/index.html>
/// [`Decode` trait]: trait@Decode
///
/// # Examples
///
/// ```
/// use musli::Decode;
///
/// #[derive(Decode)]
/// struct MyType {
/// data: [u8; 128],
/// }
/// ```
#[doc(inline)]
pub use musli_macros::Decode;

mod as_decoder;
Expand Down
18 changes: 0 additions & 18 deletions crates/musli-core/src/en/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@
//! }
//! ```

/// Derive which automatically implements the [`Encode` trait].
///
/// See the [`derives` module] for detailed documentation.
///
/// [`derives` module]: <https://docs.rs/musli/latest/musli/help/derives/index.html>
/// [`Encode` trait]: trait@Encode
///
/// # Examples
///
/// ```
/// use musli::Encode;
///
/// #[derive(Encode)]
/// struct MyType {
/// data: [u8; 128],
/// }
/// ```
#[doc(inline)]
pub use musli_macros::Encode;

mod encode;
Expand Down
3 changes: 3 additions & 0 deletions crates/musli-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ verbose = []
proc-macro2 = "1.0.79"
quote = "1.0.35"
syn = { version = "2.0.55", features = ["full", "extra-traits"] }

[dev-dependencies]
musli = { version = "=0.0.120", path = "../musli" }
34 changes: 34 additions & 0 deletions crates/musli-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,45 @@ use proc_macro::TokenStream;

const CRATE_DEFAULT: &str = "musli";

/// Derive which automatically implements the [`Encode` trait].
///
/// See the [`derives` module] for detailed documentation.
///
/// [`derives` module]: <https://docs.rs/musli/latest/musli/help/derives/index.html>
/// [`Encode` trait]: <https://docs.rs/musli/latest/musli/trait.Encode.html>
///
/// # Examples
///
/// ```
/// use musli::Encode;
///
/// #[derive(Encode)]
/// struct MyType {
/// data: [u8; 128],
/// }
/// ```
#[proc_macro_derive(Encode, attributes(musli))]
pub fn musli_derive_encode(input: TokenStream) -> TokenStream {
derive_encode(input, CRATE_DEFAULT)
}

/// Derive which automatically implements the [`Decode` trait].
///
/// See the [`derives` module] for detailed documentation.
///
/// [`derives` module]: <https://docs.rs/musli/latest/musli/help/derives/index.html>
/// [`Decode` trait]: <https://docs.rs/musli/latest/musli/trait.Decode.html>
///
/// # Examples
///
/// ```
/// use musli::Decode;
///
/// #[derive(Decode)]
/// struct MyType {
/// data: [u8; 128],
/// }
/// ```
#[proc_macro_derive(Decode, attributes(musli))]
pub fn musli_derive_decode(input: TokenStream) -> TokenStream {
derive_decode(input, CRATE_DEFAULT)
Expand Down
2 changes: 1 addition & 1 deletion crates/musli/src/descriptive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub use self::encoding::to_vec;
#[doc(inline)]
pub use self::encoding::to_writer;
#[doc(inline)]
pub use self::encoding::{decode, encode, from_slice, to_fixed_bytes, Encoding, OPTIONS};
pub use self::encoding::{decode, encode, from_slice, to_fixed_bytes, Encoding, DEFAULT, OPTIONS};
#[doc(inline)]
pub use self::error::Error;

Expand Down
2 changes: 1 addition & 1 deletion crates/musli/src/json/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub type Result<T, E = Error> = core::result::Result<T, E>;
#[doc(inline)]
pub use self::encoding::to_writer;
#[doc(inline)]
pub use self::encoding::{decode, encode, from_slice, from_str, to_fixed_bytes, Encoding};
pub use self::encoding::{decode, encode, from_slice, from_str, to_fixed_bytes, Encoding, DEFAULT};
#[cfg(feature = "alloc")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
#[doc(inline)]
Expand Down
3 changes: 3 additions & 0 deletions crates/musli/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ macro_rules! rt {
/// This is used to test when there is a decode assymmetry, such as the decoded
/// value does not match the encoded one due to things such as skipped fields.
#[cfg(feature = "test")]
#[doc(hidden)]
#[macro_export]
macro_rules! assert_decode_eq {
($what:ident, $expr:expr, $expected:expr $(, $($extra:tt)*)?) => {{
Expand All @@ -457,6 +458,7 @@ macro_rules! assert_decode_eq {

#[cfg(feature = "test")]
#[macro_export]
#[doc(hidden)]
macro_rules! extra {
($expr:expr $(,)?) => {};

Expand All @@ -474,6 +476,7 @@ macro_rules! extra {
}

#[cfg(feature = "test")]
#[doc(hidden)]
#[macro_export]
macro_rules! test_matrix {
(full, $call:path) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/musli/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ pub use self::encoding::to_vec;
#[doc(inline)]
pub use self::encoding::to_writer;
#[doc(inline)]
pub use self::encoding::{decode, encode, from_slice, to_fixed_bytes, Encoding, OPTIONS};
pub use self::encoding::{decode, encode, from_slice, to_fixed_bytes, Encoding, DEFAULT, OPTIONS};
#[doc(inline)]
pub use self::error::Error;
2 changes: 1 addition & 1 deletion crates/musli/src/wire/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub use self::encoding::to_vec;
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
pub use self::encoding::to_writer;
#[doc(inline)]
pub use self::encoding::{decode, encode, from_slice, to_fixed_bytes, Encoding, OPTIONS};
pub use self::encoding::{decode, encode, from_slice, to_fixed_bytes, Encoding, DEFAULT, OPTIONS};
#[doc(inline)]
pub use self::error::Error;

Expand Down

0 comments on commit 16bf8d7

Please sign in to comment.