-
Notifications
You must be signed in to change notification settings - Fork 47
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: Add documentation style guidelines #141
Conversation
Unrelated to this commit, apparently the SignedOff check can't understand multiple signatures:
|
I'll look into this |
Other than the script failing, your email for the commit does not match your signed-off, could you update the PR? |
You're absolutely correct, but, I would prefer not to close and open a new PR if the commit already has the correct signatures. Is it possible to proceed with the existing PR? |
Yes, you just need to amend the commit with the correct email and force push, no need to open a new PR :) This should work: $ git commit --author="Name <email>" --amend --no-edit && git push origin your_branch --force |
In the meantime I opened #142 so this does not fail in the future. |
b08ee52
to
baebc8d
Compare
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.
Please also create a separate Documentation/
directory and put this guide into a separate file there. With the directory we can also move other general (non auto-generated) documentation files there.
Once @joergroedel's comments are addressed the new version of |
baebc8d
to
49cd05d
Compare
I have made the requested changes @joergroedel. Looks like there's still an issue with the CI @00xc? |
It also needs a rebase on main, my bad |
49cd05d
to
2979f45
Compare
I should have known! :) It works now. |
85459c7
to
da0ea98
Compare
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 have some additional comments. As for examples, I would perhaps have smaller more specific examples for each point that requires one.
Documentation/DOC-GUIDELINES.md
Outdated
- We can't have a section "Panic" for every place the SVSM may panic, but | ||
they should be included if your code checks assertions or uses the | ||
`unwrap()` method. For instance: | ||
|
||
```rust | ||
/// # Panics | ||
/// | ||
/// This function does not panic under normal circumstances. However, if | ||
/// the length `len` is greater than the allocated memory's actual capacity, | ||
/// it will panic. | ||
``` |
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.
By the way, I just realized that running clippy in pedantic mode (cargo clippy --all -- -W clippy::all -W clippy::pedantic
) will warn you about these. For example:
warning: docs for function which may panic missing `# Panics` section
--> src/svsm.rs:325:1
|
325 | pub extern "C" fn svsm_start(li: &KernelLaunchInfo, vb_addr: usize) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: first possible panic found here
--> src/svsm.rs:332:9
|
332 | launch_info.kernel_region_phys_start.try_into().unwrap(),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc
I don't think we'll be running pedantic mode in our CI anytime soon, as there's just too many warnings, but maybe worth mentioning.
Add documentation style guidelines within CONTRIBUTING.md to help clarify our expectations from a documentation standpoint. Place it in a new directory Documentation/. Co-developed-by: Carlos López <[email protected]> Signed-off-by: Carlos López <[email protected]> Signed-off-by: Carlos Bilbao <[email protected]>
da0ea98
to
9067a9d
Compare
Thanks @00xc I applied the suggested changes. |
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.
There are still things we can cleanup, I have added more suggestions.
/// | ||
pub unsafe fn example_memcpy<T>(dest: *mut T, src: *const T, len: usize) { | ||
// Ensure the pointers are not null | ||
assert!(!dest.is_null() && !src.is_null()); |
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.
The function should have a # Panics
section in this case. We can even merge this example with the one below.
assert!(!dest.is_null() && !src.is_null()); | ||
let mut rcx: usize; | ||
|
||
unsafe { |
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.
The function is already unsafe, so there is no need for this unsafe block as far as I know.
Co-authored-by: Carlos López <[email protected]>
Co-authored-by: Carlos López <[email protected]>
Will merge it now, please send any updates on top of this. |
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.
LGTM
Merged manually. Closing. |
Add documentation style guidelines within CONTRIBUTING.md to help clarify our expectations from a documentation standpoint. Co-developed by @00xc.