docs: improve API documentation - #320
Open
Tim-Zhang wants to merge 1 commit into
Open
Conversation
Document public APIs and improve the crate landing page. Signed-off-by: Tim Zhang <tim@hyper.sh>
Tim-Zhang
marked this pull request as ready for review
August 6, 2026 13:05
Tim-Zhang
requested review from
teawater and
wllenyj
and
a lite review from Copilot
August 6, 2026 13:30
There was a problem hiding this comment.
🟡 Changes recommended
A stray unindented /// in src/asynchronous/shutdown.rs is likely to trigger warnings/errors under -D warnings rustdoc builds.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR significantly expands and modernizes the rustdoc surface across the workspace (crate landing pages, public APIs, and examples) and adds rustdoc lint guards to keep documentation quality high going forward.
Changes:
- Rewrites crate/module-level docs to focus on onboarding (getting started, runtime selection, transport addresses) and API “tours”.
- Adds/updates rustdoc for many public types and methods across sync/async runtimes, streaming, transports, framing, and codegen/compiler crates.
- Enables rustdoc linting via
#![warn(missing_docs)]and#![warn(rustdoc::broken_intra_doc_links)], and adds a dev-dependency to support doc tests/examples.
File summaries
| File | Description |
|---|---|
| ttrpc-codegen/src/lib.rs | Adds crate-level docs, examples, and missing-docs/broken-link lint warnings for codegen APIs. |
| src/sync/utils.rs | Documents sync request context and generated dispatch traits. |
| src/sync/server.rs | Expands sync Server docs with examples, error/panic semantics, and configuration details. |
| src/sync/mod.rs | Adds module overview docs for the sync runtime. |
| src/sync/client.rs | Documents sync Client behavior, ownership, and request failure modes. |
| src/proto.rs | Documents framing constants, headers, frame types, and codec traits. |
| src/lib.rs | Redesigns crate landing page (getting started, runtime choice, transports, security) and enables rustdoc lints. |
| src/error.rs | Improves error type and helper function documentation. |
| src/context.rs | Documents request context semantics, metadata behavior, and conversion helpers. |
| src/asynchronous/utils.rs | Documents async handler traits and async request context. |
| src/asynchronous/transport/windows.rs | Documents named-pipe bind/connect helpers. |
| src/asynchronous/transport/vsock.rs | Documents vsock bind/connect helpers and FD safety/ownership. |
| src/asynchronous/transport/unix.rs | Documents unix bind/connect helpers and FD safety/ownership. |
| src/asynchronous/transport/tcp.rs | Documents async TCP transport helpers (Unix-only via module cfg). |
| src/asynchronous/transport/mod.rs | Adds module overview and documents transport extension points and address binding/connection APIs. |
| src/asynchronous/stream.rs | Documents streaming handle types, split semantics, and error cases. |
| src/asynchronous/shutdown.rs | Adds module overview and documents shutdown coordination primitives. |
| src/asynchronous/server.rs | Documents async Server lifecycle, listener ownership, registration behavior, and failure modes. |
| src/asynchronous/mod.rs | Adds async runtime module overview and clarifies runtime requirements. |
| src/asynchronous/client.rs | Documents async Client behavior, runtime requirements, and request/streaming APIs. |
| compiler/src/prost_codegen.rs | Adds module-level docs and documents failure semantics for legacy protoc/prost pipeline. |
| compiler/src/lib.rs | Adds crate-level docs plus rustdoc lint warnings; improves public API field docs. |
| compiler/src/codegen.rs | Documents key public generator entry points and their error/panic semantics. |
| compiler/src/bin/ttrpc_rust_plugin.rs | Documents the protoc plugin binary entry point. |
| Cargo.toml | Adds ttrpc-codegen as a dev-dependency for workspace doc tests/examples. |
Review details
- Files reviewed: 25/25 changed files
- Comments generated: 2
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Comment on lines
+81
to
+83
| /// Replaces all metadata values for `key`. | ||
| /// | ||
| /// Passing an empty vector removes the key. Non-empty keys are normalized to lowercase. |
Comment on lines
+141
to
+143
| /// Requests shutdown and wakes all current waiters. | ||
| /// | ||
| /// Calling this method more than once has no additional effect. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
The existing API documentation was sparse and did not clearly explain the code generation workflow, runtime choices, feature flags, transport support, or failure semantics. This update makes docs.rs useful as both an onboarding guide and an API reference.
This is a documentation-only change and does not alter runtime behavior.
Validation
RUSTDOCFLAGS='-D missing_docs -D rustdoc::broken_intra_doc_links' cargo doc --workspace --all-features --no-deps-D warningscargo test --workspace --all-features --docmake check-allgit diff --check