-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Improve Workspaces docs page #13580
Comments
We can deal with each proposed solution per pull request.
This might be the easiest one, by expanding this Root package section, though not sure what needs to be captured. I can think of one: root package becomes the default workspace member when no other specified.
This could be as simple as a link to Resolver versions section, if I understand correctly.
These are covered by #11234 I believe. While I am going to mark this as |
I may not have understood it accurately in this regard, but I'd like to try to address it. @rustbot claim |
Cargo book workspace The chapters are already given a link when they first appear, so it seems like there's no need for extra explanation or link? Could it be that I'm missing something?
|
From the comment.
Maybe But I seem to have found something else.I looked at the previous chapters and realized that in 3.1 Specifying Dependencies mentions a lot of
In addition, it occurred to me that I could add a sub-section |
@epage @weihanglo , I've written a rough post to show my plan and would like your advice. Creating a New WorkspaceIn this chapter we implement the creation of a workspace As mentioned in [workspace] section, the workspace must have at least one member, either the root package or a virtual manifest. Here we recommend setting the root of the workspace to be a virtual manifest. The reason is as follows:
Let's look at how a workspace containing a virtual inventory should be created. Currently # [new_workspace]/Cargo.toml
[workspace] If using a virtual workspace, then the version of resolver needs to be specified in the table (if not, the default version of resolver for a workspace is [workspace]
resolver = "2" You can then proceed to create workspace members. As mentioned above, if you have a lot of workspace members, we recommend designing the workspace with a flat structure. So add all the workspace members in the directory There are several ways to add members to the workspace, we recommend using the command $ cargo new crates/foo-bin
$ cargo new crates/bar-lib Cargo will automatically add members to # [new_workspace]/Cargo.toml
[workspace]
resolver = "2"
members = [ "bar-lib","foo-bin"]
[package]
... The project at this point contains the following files: $ cd new_workspace
$ tree .
.
├── Cargo.toml
└── crates
├── bar-lib
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── foo-bin
├── Cargo.toml
└── src
└── main.rs
5 directories, 5 files Up to this point, we have achieved creating a workspace that contains multiple |
If we're adding a how-to to the reference, that feels backwards and out of place. The existing "examples" sections are showing practices related to the reference, not tutorial-level documentation. We could likely add one of those for workspaces but that is different than "Creating a workspace". If we add a section hanging off of the reference, it would more likely be related to #11234. This would also accomplish the high level goal set out in this issue (showing a cohesive picture of workspaces).
Personally, I'm not too worried about the exact ordering of the reference as it is reference level material and cross-references itself all over the place. There isn't really a clear "start with this" |
So, is it possible to reach a consensus on the following. The location of the new section is Are there any other suggestions to discuss? If not can I proceed to the next step and submit a PR? |
For a user to read the reference and to understand when each type of workspace might be right for them, they have to know to also read the section on Package Selection. This reframes the section on needing to set `resolver = "2"` to being about differences when there isn't a root package and extends it to summarize a part of Package Selection, linking out to it. The hope is that this will make it all of the differences more discoverable without retreading too much of the same ground within Reference-style documentation. Part of rust-lang#13580
For a user to read the reference and to understand when each type of workspace might be right for them, they have to know to also read the section on Package Selection. This reframes the section on needing to set `resolver = "2"` to being about differences when there isn't a root package and extends it to summarize a part of Package Selection, linking out to it. The hope is that this will make it all of the differences more discoverable without retreading too much of the same ground within Reference-style documentation. Part of rust-lang#13580
For a user to read the reference and to understand when each type of workspace might be right for them, they have to know to also read the section on Package Selection. This reframes the section on needing to set `resolver = "2"` to being about differences when there isn't a root package and extends it to summarize a part of Package Selection, linking out to it. The hope is that this will make it all of the differences more discoverable without retreading too much of the same ground within Reference-style documentation. Part of rust-lang#13580
docs(ref): Index differences between virtual / real manifests ### What does this PR try to resolve? For a user to read the reference and to understand when each type of workspace might be right for them, they have to know to also read the section on Package Selection. This reframes the section on needing to set `resolver = "2"` to being about differences when there isn't a root package and extends it to summarize a part of Package Selection, linking out to it. The hope is that this will make it all of the differences more discoverable without retreading too much of the same ground within Reference-style documentation. Part of #13580 ### How should we test and review this PR? ### Additional information r? `@weihanglo`
Problem
https://doc.rust-lang.org/cargo/reference/workspaces.html is comprehensive, but could benefit from some clarifications and examples of how to create a workspace
Anyone trying to create a workspace would have to piece together multiple code snippets and go by trial and error.
Most people probably get it right the first time, but making it clearer in the docs will help.
Proposed Solution
Copied from and earlier discussion (#13579 (comment))
Notes
Related:
cargo new --workspace
to create a workspace #8365The text was updated successfully, but these errors were encountered: