Skip to content

Document the items the macros generate - #286

Merged
soareschen merged 1 commit into
mainfrom
docs/generated-docs
Nov 7, 2026
Merged

soareschen merged 1 commit into
mainfrom
docs/generated-docs

Conversation

@soareschen

Copy link
Copy Markdown
Collaborator

Overview

[deepseek-v4.1-flash] Every macro that declares a public item now emits a short doc for it, so a crate can enable #![warn(missing_docs)] without the lint reporting generated code. A user's own doc comment is preserved, and a #[cgp_fn] function's doc now stays on the method instead of moving to the trait.

Motivation

missing_docs runs after macro expansion, so it reports the items a macro generates, and a doc comment written on the invocation never reaches them: rustdoc does not document macro invocations, so the macro must emit the documentation itself. Before this change, a crate that used a component and enabled the lint failed the build on the component marker, the provider struct, the namespace items, and the data derives' companion types.

Impact

The generated lines name the item and link the trait it belongs to, such as Component marker for [CanGreet]. and Provider GreetHello for [Greeter].. A generated line is never appended after a user's doc: it fills a gap, so no item carries both.

A doc on a #[cgp_component] consumer trait is copied onto the five items the macro derives from it, which is harmless on docs.rs because impl docs are not rendered. A doc on a cgp_namespace! or delegate_components! invocation is dropped with an unused_doc_comments warning, so the generated line is all those items can carry.

The generated_docs module in the test library denies missing_docs while using every macro, so a generated item that loses its line fails the build. It lives in the library crate because missing_docs only fires on items exported from a library, and a test binary exports nothing. Three snapshots pin where a user's doc comment lands, in the concept targets that own their macros.

A crate that enabled `missing_docs` failed the build on every item a CGP
macro declares, because a doc comment on the invocation never reaches the
generated code. Each macro now emits a short doc for the items it
declares: the component marker, the provider struct, the namespace
struct, trait, and associated type, the wiring-table structs, and the
data derives' companion types.

A `#[cgp_fn]` function's own doc now stays on the method, where the
function's body lands, instead of moving to the trait, and the trait
carries a generated line naming the operation.

The `generated_docs` module in the test library denies `missing_docs`
while using every macro, so a generated item that loses its line fails
the build, and three snapshots pin where a user's doc comment lands.
@soareschen
soareschen marked this pull request as ready for review November 7, 2026 21:59
@soareschen
soareschen merged commit 73af05f into main Nov 7, 2026
3 checks passed
@soareschen
soareschen deleted the docs/generated-docs branch November 7, 2026 22:00
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.

1 participant