8000 Build docs for target-specific code independent of platform by lschuermann · Pull Request #4122 · tock/tock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Build docs for target-specific code independent of platform #4122

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

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

lschuermann
Copy link
Member

Pull Request Overview

This pull request adds any(doc, ... to target-specific conditional compilation expressions, to ensure that such functions and expressions are always documented.

This makes their documentation comment be rendered in Rustdoc, and also allows us to jump to the correct (non-mock) function definitions from within the documentation.

Testing Strategy

This pull request was tested by cargo doc and cargo check.

TODO or Help Wanted

N/A

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

@github-actions github-actions bot added tock-libraries This affects libraries supported by the Tock project risc-v RISC-V architecture WG-OpenTitan In the purview of the OpenTitan working group. stm32 Change pertains to the stm32 family of MCUSs labels Jul 30, 2024
Comment on lines -13 to -14
#[cfg(all(target_arch = "arm", target_os = "none"))]
use core::arch::global_asm;
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed these conditional imports while I was going over the code. Conditional imports are a great recipe for producing warnings or errors that can easily be avoided by just referring to items using their fully qualified name, or moving imports into the respective functions themselves.

Copy link
Contributor
@bradjc bradjc left a comment
< 8000 div hidden="hidden" data-view-component="true" class="js-comment-show-on-error flash flash-error flash-full">

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.

I think this is the most reasonable path forward for now, until https://doc.rust-lang.org/cargo/reference/unstable.html#per-package-target is stabilized (if it is stabilized).

While I think this is very undesirable (having to further modify the OS source to tell the tooling to fix a mistake/bad asummption it is making), the benefit of actually documenting our code, while not having to manually implement some sort of manual cargo doc for the workspace where we would manually combine different crate docs, seems worth it. The correct documentations is already being generated, it is just only generated per-board, and not for the workspace as a whole.

Theoretically we would want to somehow avoid this being out of date, but, I don't think that is worth it. If a any(doc) is missed, it's no worse than just not having docs, which we are missing in many places already.

I also think this PR inserts any(doc) in many places which don't do anything, but it's not a big deal and it makes copy-paste easier in the future. I choose to believe someday cargo will catch up and we can delete all of these hacks anyway :).

@lschuermann
Copy link
Member Author

@bradjc Agree with all of the above, although one minor comment:

I also think this PR inserts any(doc) in many places which don't do anything

A nice side effect of this is that we now document the actual target language items, instead of the mock variants. Even if those don't have a doc comment attached, things like the View Source button now direct you to the actual target implementation instead.

Comment on lines -147 to +145
#[cfg(all(target_arch = "arm", target_os = "none"))]
global_asm!(
#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
core::arch::global_asm!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this do anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so. My intention here was to make every target selector also set doc properly so when someone copies this expression it would be correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok that was my assumption.

@alevy alevy added the last-call Final review period for a pull request. label Aug 5, 2024
@bradjc bradjc added this pull request to the merge queue Aug 6, 2024
Merged via the queue into tock:master with commit dee00dc Aug 6, 2024
12 checks passed
@bradjc bradjc deleted the dev/cond-compile-docs branch August 6, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
last-call Final review period for a pull request. risc-v RISC-V architecture stm32 Change pertains to the stm32 family of MCUSs tock-libraries This affects libraries supported by the Tock project WG-OpenTitan In the purview of the OpenTitan working group.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0