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 documentation #340

Merged
merged 10 commits into from Feb 10, 2022
Merged

Improve documentation #340

merged 10 commits into from Feb 10, 2022

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Nov 18, 2021

In a continued effort to find my feet around here, and inspired by issue #128 I've done a codebase wide audit of the docs (primarily just rustdocs but I glanced at // docs as well). Each change is in a separate commit so can be removed if resistance is met. ("resistance is futile").

I've based the stylistic decisions on work done in rust-bitcoin.

I believe the only controversial change is the last (commit: da161c9 Use rust-bitcoin module doc style), please review that one carefully.

@apoelstra
Copy link
Member

concept ACK.

This PR touches a lot of code and is likely to get quickly out-of-date (and conversely to invalidate lots of open PRs). For that reason I'm hesitant to move forward with it, but I'm happy to try if others want to.

@tcharding
Copy link
Member Author

tcharding commented Jan 2, 2022

Not sure what to do about this. I'll put it back to draft until some idea comes to me.

Cheers.

@tcharding
Copy link
Member Author

I'm reopening this because we have a bit of a quiet time right now, there are not many PRs open for this to conflict with, possibly only @dr-orlovsky's #309?

'context' does not need need a capital letter in the middle of a
sentence.
Add the terminating period to all docs sentences. (Also one instance of
capitialize initial character in sentence.)
Make all the various size constant docs uniform by using form 'The size
...' and also by ending with a period.
As is typical in the Rust ecosystem use the third person tense when
documenting functions. E.g.,

```
/// Creates a new Foo.
```
As opposed to

```
/// Create a new Foo.
```
For added clarity add ticks around words that are code.
To save devs looking up the commit themselves add a link to it in the
rustdoc.
Recently we introduced uniform styling for module docs over in
`rust-bitcoin` repo. We can do the same here but its a bit controversial
because it removes the heading from module docs and every single public
module in rust-secp256k1 uses a heading. Instead we use a full
sentences. Also makes uniform the trailing `//!`.
src/context.rs Outdated
/// A trait for all kinds of Context's that lets you define the exact flags and a function to deallocate memory.
/// It shouldn't be possible to implement this for types outside this crate.
/// A trait for all kinds of contexts that lets you define the exact flags and a function to
/// deallocate memory. It shouldn't be possible to implement this for types outside this crate.
Copy link
Member

Choose a reason for hiding this comment

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

In 269bde0:

You could change "shouldn't be possible" to "isn't possible". I think we've come to trust rustc more than when this comment was written :)

src/context.rs Outdated
// on one hand this trait is public, on the other it's in a private module
// so it's not visible to anyone besides it's parent (the context module)
// On one hand this trait is public, on the other it's in a private module
// so it's not visible to anyone besides it's parent (the context module).
Copy link
Member

Choose a reason for hiding this comment

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

In 5e07e75:

Should also change the second it's to its

Copy link
Member

Choose a reason for hiding this comment

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

Also we could probably drop the exposition here; it's a pretty standard idiom now.

src/lib.rs Outdated
/// (Re)randomizes the Secp256k1 context for cheap sidechannel resistance;
/// see comment in libsecp256k1 commit d2275795f by Gregory Maxwell. Requires
/// compilation with "rand" feature.
/// (Re)randomizes the Secp256k1 context for cheap sidechannel resistance.
Copy link
Member

Choose a reason for hiding this comment

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

In 3fa6762:

Let's replace "cheap" with "extra". The cost is comparable to a signing operation.

@apoelstra
Copy link
Member

Done reviewing c9e6ca1

I think it's a quiet enough time that we can get this in, it's not that disruptive and we're mostly done with Schnorr signatures.

This definitely isn't possible, change the phrase.
The nested pub inside a private module is easy to understand, we do not
need an explanation.
The word 'extra' better describes the sidechannel resistance gained by
re-randomising the context.
@tcharding
Copy link
Member Author

All suggestions implemented as separate additional patches, thanks.

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 c73eb2f

@apoelstra apoelstra merged commit df7520e into rust-bitcoin:master Feb 10, 2022
@tcharding tcharding deleted the docs branch February 11, 2022 08:37
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.

None yet

2 participants