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(book-cc): document the process for adding new workspace crates #273

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ROMemories
Copy link
Collaborator

Not sure the Coding Conventions is the best place to document this, maybe we should have a book section for documenting processes.

@ROMemories ROMemories added the docs Improvements or additions to documentation label Apr 24, 2024
book/src/coding-conventions.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@elenaf9 elenaf9 left a comment

Choose a reason for hiding this comment

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

Subjective opinion: not sure if we really need this section, given that we don't add new crates that often
The first couple of points aren't RIOT-rs specific. Only really the points about rexporting the crate from riot-rs and adding it (and potential features flag) to the CI are. Maybe it makes sense to have them, but then I'm in favor of shortening it down.

But not a strong opinion :)

book/src/coding-conventions.md Outdated Show resolved Hide resolved
book/src/coding-conventions.md Outdated Show resolved Hide resolved
book/src/coding-conventions.md Outdated Show resolved Hide resolved
@ROMemories
Copy link
Collaborator Author

Subjective opinion: not sure if we really need this section, given that we don't add new crates that often

I agree it's not a weekly event, but it does happen quite regularly: riot-rs-random was added two weeks ago, and I'm in the process of adding two more (for the sensor abstraction and the built-in sensors).

The first couple of points aren't RIOT-rs specific.

I also agree that not all of it is RIOT-rs-specific, but it helps clarify what tools and configuration we embrace, especially as these are always changing—e.g., inheritance of workspace lints was only added a few months ago and I was personally pleasantly surprised when I saw that using cargo init to add a new workspace crate automatically makes that new crate inherits the workspace lints. It additionally allows us to make explicit some policies that cannot be inferred from the current state of the codebase.
That process is also likely to be relevant to new contributors, as the first step of adding a new piece of functionality may well be to create a new workspace crate.

This was referenced Oct 21, 2024
@ROMemories
Copy link
Collaborator Author

This has proven useful these past few weeks, I've updated it and I think we can get it in now.

@ROMemories ROMemories changed the title book(dev): document the process for adding new workspace crates docs(book-cc): document the process for adding new workspace crates Nov 14, 2024

1. Create the new crate's directory in `src/`.
1. Run `cargo init --lib` in that directory.
1. Add relevant lints (e.g., `#![deny(missing_docs)]` and `#![deny(clippy::pedantic)]`) to the crate; some lints are already inherited from the workspace and do not need to be added to the new crate.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this needs to be more specific. Better state e.g., "Add #![deny(missing_docs)] and #![deny(clippy::pedantic)] to the crate"

1. Create the new crate's directory in `src/`.
1. Run `cargo init --lib` in that directory.
1. Add relevant lints (e.g., `#![deny(missing_docs)]` and `#![deny(clippy::pedantic)]`) to the crate; some lints are already inherited from the workspace and do not need to be added to the new crate.
1. Cargo has added the crate to the workspace members in the workspace's `Cargo.toml`, move the added string to its own line, preserving lexicographic order.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
1. Cargo has added the crate to the workspace members in the workspace's `Cargo.toml`, move the added string to its own line, preserving lexicographic order.
1. In the workspace's `Cargo.toml` `workspace.members`, ensure the crate's entry keeps the lexicographic order.

1. Cargo has added the crate to the workspace members in the workspace's `Cargo.toml`, move the added string to its own line, preserving lexicographic order.
1. Add the crate to the list of crates checked by Clippy in `.github/workflows/main.yml`, preserving lexicographic order.
1. Consider adding the crate to the list of crates run by cargo test in `.github/workflows/main.yml`, preserving lexicographic order.
1. Re-export the crate from the `riot-rs` crate, inline it in the docs as done for the other crates, and feature-gate it if necessary.
Copy link
Collaborator

Choose a reason for hiding this comment

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

move to third place (after "add lints", before the CI fixes start)

1. Run `cargo init --lib` in that directory.
1. Add relevant lints (e.g., `#![deny(missing_docs)]` and `#![deny(clippy::pedantic)]`) to the crate; some lints are already inherited from the workspace and do not need to be added to the new crate.
1. Cargo has added the crate to the workspace members in the workspace's `Cargo.toml`, move the added string to its own line, preserving lexicographic order.
1. Add the crate to the list of crates checked by Clippy in `.github/workflows/main.yml`, preserving lexicographic order.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This and the next I found not obvious and thus skipped it. Can we have ANCHORS in those yamls? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants