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

Improve public re-exports #137

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Oct 10, 2023

Improve the public exports in two ways:

  1. Inline re-exports into the docs of the module that re-exports them.
  2. Separate public and private use statements

Recently we discussed a way to separate the public and private import statements to make the code more clear and prevent rustfmt joining them all together.

Separate public exports using a code block and #[rustfmt::skip]. Has the nice advantage of reducing the number of #[doc(inline)] attributes also.

  1. Modules first, as they are part of the project's structure.
  2. Private imports
  3. Public re-exports (using rustfmt::skip to prevent merge)

Use the format

mod xyz;
mod abc;

use ...;

pub use {
    ...,
};

This patch introduces changes to the rendered HTML docs.

@tcharding
Copy link
Member Author

Based on discussion here: rust-bitcoin/rust-bitcoin#2088

Improve the public exports in two ways:

1. Inline re-exports into the docs of the module that re-exports them.
2. Separate public and private use statements

Recently we discussed a way to separate the public and private import
statements to make the code more clear and prevent `rustfmt` joining
them all together.

Separate public exports using a code block and `#[rustfmt::skip]`. Has
the nice advantage of reducing the number of `#[doc(inline)]` attributes
also.

1. Modules first, as they are part of the project's structure.
2. Private imports
3. Public re-exports (using `rustfmt::skip` to prevent merge)

Use the format

```rust
mod xyz;
mod abc;

use ...;

pub use {
    ...,
};
```

This patch introduces changes to the rendered HTML docs.
@tcharding tcharding force-pushed the 10-10-import-statements branch from 33c7ef5 to 1d4d337 Compare October 10, 2023 04:12
@tcharding tcharding changed the title Separate public and private use statements Improve public re-exports Oct 10, 2023
Copy link
Member

@clarkmoody clarkmoody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have a strong opinion on this one, but I'm fine with it.

ACK 1d4d337

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 1d4d337

@apoelstra apoelstra merged commit 202b59f into rust-bitcoin:master Oct 12, 2023
12 checks passed
@apoelstra apoelstra deleted the 10-10-import-statements branch October 12, 2023 15:09
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 this pull request may close these issues.

3 participants