-
Notifications
You must be signed in to change notification settings - Fork 181
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
docs(iroh-net): Update endpoint docs #2334
Conversation
This rewrites quite a bit of the docs aiming to be more consistent and clear: - First line is a single-line summary. - In the 3rd person. - Functions are now sorted for both the Builder and Endpoint. This order is the order they are rendered in the docs. - Functions try to refer to each other correctly and use consistent terminology. No code was changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not only an improvement on style but also on the docs itself, which is great.
However, I'm finding hard to justify the reordering of functions. Right now it's not alphabetically -accept used to be before connect-, so it's not clear what's the reasoning cargo docs
is using for this, so that we can keep it. If we don't intend to keep it, little value is gained here. If we do intend to keep it, without understanding we are now bound to check cargo docs
every time something new is added.
My general preference, and what I think had been going on here before, is to have first public constructors, then public getters before modifiers and private functions either at the end or close to the public ones that use them. And finally destructors, followed by #cfg(test)
ones. As such, before this change we had:
builder
- constructor relatedbind
- constructor relatedaccept
- out of place imonode_id
- getter-likesecret_key
- getter-likediscovery
- getter-likelocal_addr
- getter-likelocal_endpoints
my_relay
my_addr
my_addr_with_endpoints
- let's call it a getter...... although it's a weird one, to me it makes sense that it's aftermy_addr
ok the list is long but more or less the pattern is being followed except for some oddities. Modifiers I would consider accept
, connect
, add_node_addr
, etc.
At the end we do then have close
and the testing ones to get the underlying magic socket and quinn endpoint.
The point I'm trying to make is that, while imperfect, the previous order made some sense, in some way we can recognize. Now, at least me, I don't see it.
iroh-net/src/endpoint.rs
Outdated
/// Returns the local IP endpoints in use as a stream. | ||
/// | ||
/// The [`Endpoint`] continuously monitors the local IP endpoints, the IP addresses it | ||
/// can be reached on by other nodes, for changes. Whenever changes are detected this | ||
/// stream will yield a new list of endpoints. | ||
/// | ||
/// Upon the first creation, the first local IP endpoint discovery might still be | ||
/// underway, in this case the first item of the stream will not be immediately | ||
/// available. Once this first set of local IP endpoints are discovered the stream will | ||
/// always return the first set of IP endpoints immediately, which are the most recently | ||
/// discovered IP endpoints. | ||
/// | ||
/// The list of IP endpoints yielded contains both the locally-bound addresses and the | ||
/// [`Endpoint`]'s publicly-reachable addresses, if they could be discovered through | ||
/// STUN or port mapping. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting on others to comment in internal discussions, but the Ip Endpoint
term is not working for me here. I don't find it clear from the naming, it has never been introduced before and from our discussions, it's also slightly inaccurate.
One could say it's being introduced here in
the local IP endpoints, the IP addresses it can be reached on by other nodes
and yet it does not feel clear to me, in particular since direct addresses
has been used as the remote counterpart. With this I mean: the ip-port pairs we use to connect to other nodes, we have consistently called direct addresses
, yet the ip-port pairs that can be used to connect to us have a different name. From an user perspective, I don't think this provides really any value and instead generates confussion. It would be more useful to just use the same for both imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree this isn't very satisfactory yet. In this PR I don't want to change the function name yet, but I think that's how it will turn out. Just don't yet know what to. But we should get the doc comment working into a better shape already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, doubling down on "direct addresses" for this term. not changing APIs in this PR though, leaving that cleanup as a followup.
Co-authored-by: Divma <[email protected]>
What I've been aiming for is to make reading the documentation the most helpful. So items you need the most commonly are shown first, then less common things. And finally also grouped per topic. So for
Note I'm ignoring items that are private or cfg_test, they can all come at the end or in the middle if they belong more in a group. Would it help if we add comments to each group in the source code? That way it might be easier when adding items to help them get into the right location. Whichever order/groups we settle on. For the |
@divagant-martian I've re-sorted the private methods a bit, and tried to document the reasoning for the ordering in the source. Feel free to still have different ideas about the actual ordering though. |
@divagant-martian please still leave your feedback if you're still not convinced of some ordering or wording even though it's merged. We can still improve the docs, just wanted this to at least partially make the release. |
Description
This rewrites quite a bit of the docs aiming to be more consistent and
clearly describe the various parts of the API and how they interact.
It also tries to get the style standardised following https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
The order of the functions has been deliberately changed, the order is used by rust doc as well so directly affects how users see the documentation.
Some
PublicKey
types have been changed intoNodeId
. They mostlyalready had
node_id
as parameter names and were described as such.But no other code changes have been made.
Breaking Changes
Notes & open questions
The sorting makes the diff rather difficult to read, sorry about that. But
maybe that's not so bad for the doc comments as the result is more important
than the diff.
I've taken to calling the logical thing the
Endpoint
controls an "iroh-net node". This is the thing that goes into theNodeMap
etc, so is consistent with naming. But I'm usually using "iroh-net node" in prose to distinguish it from theiroh::node::Node
.Change checklist
[ ] Tests if relevant.[ ] All breaking changes documented.