feat(xtask): Add check to ensure proc-macro generated user-space items are documented or hidden#5030
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new xtask CI check to detect undocumented (or not-#[doc(hidden)]) proc-macro-generated items by running cargo rustdoc --document-private-items --show-coverage against a representative end-user binary example.
Changes:
- Run a new CI-facing
xtaskstep that executescargo rustdoconexamples/async/embassy_hello_worldand enforces 100% private-item doc coverage. - Update the embassy hello world async example to document an
#[embassy_executor::task]function. - Hide the proc-macro generated
__mainmodule inesp-hal-procmacroswith#[doc(hidden)]to keep rustdoc coverage clean.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
xtask/src/main.rs |
Adds the new “generated doc artifacts” rustdoc coverage check to CI checks. |
examples/async/embassy_hello_world/src/main.rs |
Documents a task function to satisfy private-item doc coverage. |
esp-hal-procmacros/src/rtos_main.rs |
Marks generated __main module as #[doc(hidden)] to avoid coverage failures from macro output. |
bb303b2 to
99460f4
Compare
99460f4 to
15383d2
Compare
15383d2 to
0effe5f
Compare
|
the proc-macro changes look useful - not sure if just having unit tests for the macros wouldn't be enough |
|
Also please add a line about this to the developer guidelines, maybe copilot is smart enough to catch unwanted changes early. |
I'm not sure if this is easily feasible. Ultimately, it's what ends up in the final binary that matters. The current tests verify that the proc-macro matches a specific string, but documentation coverage is a bit more broad. |
|
This makes me wonder if we should have a specifically tailored package to cover |
49390a2 to
056aab7
Compare
|
I don't know... you're testing a set of macros, and nothing really guarantees that we won't add more, that won't be tested. At that point, doc coverage is essentially the same as the unit tests - we need to keep something in mind in order to test it, but the extra check just brings in extra complication and takes time to run. Not to mention this uses 2 unstable features so it's pretty much guaranteed to break at some point for one reason or another. |
056aab7 to
24a8c77
Compare
Yeah. This is quite an unstable situation, with no strong verification barriers. The current checked binary doesn't cover The current architecture allows future extension like enforcing documentation coverage for all stabilized public items, if that's desired. |
|
New commits in main has made this PR unmergable. Please resolve the conflicts. |
24a8c77 to
d0575bd
Compare
d0575bd to
11671a4
Compare
bugadani
left a comment
There was a problem hiding this comment.
If you would please undo the CI and xtask changes, we could perhaps move forward here.
|
What do you mean? I thought we wanted this to run in nightly CI? |
|
Because the CI check needs to know about the potentially problematic macros, there's no point in running the CI check in the first place. The unit tests should be sufficient, I don't see the value in the complexity added to the xtask. |
11671a4 to
c2cc1c4
Compare
…` proc-macro - Add missing `#[doc(hidden)]` for the `__main` module generated by the `esp_rtos::main` macro
c2cc1c4 to
e856f1c
Compare
|
Got it! Fixed and rebased |
Thank you for your contribution!
We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:
Submission Checklist 📝
cargo xtask fmt-packagescommand to ensure that all changed code is formatted correctly.CHANGELOG.mdin the proper section.Extra:
Pull Request Details 📖
Description
This is a naive attempt at checking rustdoc coverage on a proper binary, using all of the generated pro-macros to ensure that expanded code in the user's app is either documented or hidden.
Related: #1233
cargo rustdoc --document-private-items --show-coverageonexamples/async/embassy_hello_world.100.0%, catching undocumented macro-generated items in user-facing apps.__mainmodule inesp-hal-procmacrosas#[doc(hidden)]and document example tasks to keep baseline coverage passing.Testing
Tested locally by adding and removing
#[doc(hidden)].Will need a proper CI run to ensure it's fully working on all targets.