Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

Zildj1an
Copy link
Contributor

Add documentation style guidelines within CONTRIBUTING.md to help clarify our expectations from a documentation standpoint. Co-developed by @00xc.

@Zildj1an
Copy link
Contributor Author

Unrelated to this commit, apparently the SignedOff check can't understand multiple signatures:

From https://github.com/coconut-svsm/svsm
 * branch            main       -> FETCH_HEAD
Checking b08ee52ee93c8fdac56a31df3a1fca99d3a064b1
Author name mismatch on commit b08ee52ee93c8fdac56a31df3a1fca99d3a064b1
    Commit author name: Carlos Bilbao
    Signed-off-by name: Carlos López
Carlos Bilbao
Error: Process completed with exit code 1.

@00xc
Copy link
Member

00xc commented Oct 24, 2023

Unrelated to this commit, apparently the SignedOff check can't understand multiple signatures:

From https://github.com/coconut-svsm/svsm
 * branch            main       -> FETCH_HEAD
Checking b08ee52ee93c8fdac56a31df3a1fca99d3a064b1
Author name mismatch on commit b08ee52ee93c8fdac56a31df3a1fca99d3a064b1
    Commit author name: Carlos Bilbao
    Signed-off-by name: Carlos López
Carlos Bilbao
Error: Process completed with exit code 1.

I'll look into this

@00xc
Copy link
Member

00xc commented Oct 24, 2023

Other than the script failing, your email for the commit does not match your signed-off, could you update the PR?

@Zildj1an
Copy link
Contributor Author

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?

@00xc
Copy link
Member

00xc commented Oct 24, 2023

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

@00xc
Copy link
Member

00xc commented Oct 24, 2023

In the meantime I opened #142 so this does not fail in the future.

Copy link
Member

@joergroedel joergroedel left a 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.

CONTRIBUTING.md Outdated Show resolved Hide resolved
@00xc
Copy link
Member

00xc commented Oct 31, 2023

Once @joergroedel's comments are addressed the new version of check-signed-off.sh should run, removing the CI failure.

@Zildj1an
Copy link
Contributor Author

I have made the requested changes @joergroedel. Looks like there's still an issue with the CI @00xc?

@00xc
Copy link
Member

00xc commented Oct 31, 2023

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

@Zildj1an
Copy link
Contributor Author

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

I should have known! :) It works now.

README.md Outdated Show resolved Hide resolved
@Zildj1an Zildj1an force-pushed the doc_guidelines branch 2 times, most recently from 85459c7 to da0ea98 Compare November 1, 2023 19:38
Copy link
Member

@00xc 00xc left a 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 Show resolved Hide resolved
Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
Comment on lines 88 to 118
- 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.
```
Copy link
Member

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]>
@Zildj1an
Copy link
Contributor Author

Zildj1an commented Nov 9, 2023

I have some additional comments. As for examples, I would perhaps have smaller more specific examples for each point that requires one.

Thanks @00xc I applied the suggested changes.

@Zildj1an Zildj1an closed this Nov 9, 2023
@Zildj1an Zildj1an reopened this Nov 9, 2023
Copy link
Member

@00xc 00xc left a 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.

Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
///
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());
Copy link
Member

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 {
Copy link
Member

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.

Documentation/DOC-GUIDELINES.md Outdated Show resolved Hide resolved
@joergroedel
Copy link
Member

Will merge it now, please send any updates on top of this.

Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

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

LGTM

@joergroedel
Copy link
Member

Merged manually. Closing.

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.

3 participants