Skip to content

Commit 0f9bfb9

Browse files
committed
docs(contrib): Move overview to lib
Unfortunately, the intra-doc links seem to follow the same visibility rule as using the API items, meaning that for `lib.rs` to link to a `mod`, it has to have visibility of the `mod`, requiring some mods to be made `pub(crate)` that previously weren't. I've gone ahead and done this for now as the goal of this effort is for us to catch broken docs through refactorings by using intra-doc links. For now, the contrib docs page that was moved just links to the nightly docs. Over time, all of this will just be collapsed into the architecture page which will link out to the nightly docs.
1 parent 2b0b3b2 commit 0f9bfb9

File tree

4 files changed

+79
-124
lines changed

4 files changed

+79
-124
lines changed

src/cargo/core/compiler/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
3434
pub mod artifact;
3535
mod build_config;
36-
mod build_context;
36+
pub(crate) mod build_context;
3737
mod build_plan;
3838
mod compilation;
3939
mod compile_kind;
40-
mod context;
40+
pub(crate) mod context;
4141
mod crate_type;
4242
mod custom_build;
43-
mod fingerprint;
43+
pub(crate) mod fingerprint;
4444
pub mod future_incompat;
4545
mod job_queue;
4646
mod layout;

src/cargo/lib.rs

+73-13
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,81 @@
2020
//! and there is no clear path to stabilize it soon at the time of writing. See [The Cargo Book:
2121
//! External tools] for more on this topic.
2222
//!
23-
//! ## For Cargo contributors
23+
//! ## Overview
2424
//!
25-
//! If you are just diving into Cargo internals, [Cargo Architecture Overview]
26-
//! is the best material to get a broader context of how Cargo works under the hood.
27-
//! Things also worth a read are important concepts reside in source code,
28-
//! which Cargo developers have been crafting for a while, namely
25+
//! - [`ops`]:
26+
//! Every major operation is implemented here. Each command is a thin wrapper around ops.
27+
//! - [`ops::cargo_compile`]:
28+
//! This is the entry point for all the compilation commands. This is a
29+
//! good place to start if you want to follow how compilation starts and
30+
//! flows to completion.
31+
//! - [`core::resolver`]:
32+
//! This is the dependency and feature resolvers.
33+
//! - [`core::compiler`]:
34+
//! This is the code responsible for running `rustc` and `rustdoc`.
35+
//! - [`core::compiler::build_context`]:
36+
//! The [`BuildContext`]['core::compiler::BuildContext] is the result of the "front end" of the
37+
//! build process. This contains the graph of work to perform and any settings necessary for
38+
//! `rustc`. After this is built, the next stage of building is handled in
39+
//! [`Context`][core::compiler::Context].
40+
//! - [`core::compiler::context`]:
41+
//! The `Context` is the mutable state used during the build process. This
42+
//! is the core of the build process, and everything is coordinated through
43+
//! this.
44+
//! - [`core::compiler::fingerprint`]:
45+
//! The `fingerprint` module contains all the code that handles detecting
46+
//! if a crate needs to be recompiled.
47+
//! - [`core::source`]:
48+
//! The [`core::Source`] trait is an abstraction over different sources of packages.
49+
//! Sources are uniquely identified by a [`core::SourceId`]. Sources are implemented in the [`sources`]
50+
//! directory.
51+
//! - [`util`]:
52+
//! This directory contains generally-useful utility modules.
53+
//! - [`util::config`]:
54+
//! This directory contains the config parser. It makes heavy use of
55+
//! [serde](https://serde.rs/) to merge and translate config values. The
56+
//! [`util::Config`] is usually accessed from the
57+
//! [`core::Workspace`]
58+
//! though references to it are scattered around for more convenient access.
59+
//! - [`util::toml`]:
60+
//! This directory contains the code for parsing `Cargo.toml` files.
61+
//! - [`ops::lockfile`]:
62+
//! This is where `Cargo.lock` files are loaded and saved.
2963
//!
30-
//! - [`cargo::core::resolver`](crate::core::resolver),
31-
//! - [`cargo::core::compiler::fingerprint`](core/compiler/fingerprint/index.html),
32-
//! - [`cargo::util::config`](crate::util::config),
33-
//! - [`cargo::ops::fix`](ops/fix/index.html), and
34-
//! - [`cargo::sources::registry`](crate::sources::registry).
35-
//!
36-
//! This API documentation is published on each push of rust-lang/cargo master branch.
37-
//! In other words, it always reflects the latest doc comments in source code on master branch.
64+
//! Related crates:
65+
//! - [`cargo-platform`](https://crates.io/crates/cargo-platform)
66+
//! ([nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/cargo_platform)):
67+
//! This library handles parsing `cfg` expressions.
68+
//! - [`cargo-util`](https://crates.io/crates/cargo-util)
69+
//! ([nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/cargo_util)):
70+
//! This contains general utility code that is shared between cargo and the testsuite
71+
//! - [`crates-io`](https://crates.io/crates/crates-io)
72+
//! ([nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/crates_io)):
73+
//! This contains code for accessing the crates.io API.
74+
//! - [`home`](https://crates.io/crates/home):
75+
//! This library is shared between cargo and rustup and is used for finding their home directories.
76+
//! This is not directly depended upon with a `path` dependency; cargo uses the version from crates.io.
77+
//! It is intended to be versioned and published independently of Rust's release system.
78+
//! Whenever a change needs to be made, bump the version in Cargo.toml and `cargo publish` it manually, and then update cargo's `Cargo.toml` to depend on the new version.
79+
//! - [`cargo-test-support`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-test-support)
80+
//! ([nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/cargo_test_support/index.html)):
81+
//! This contains a variety of code to support writing tests
82+
//! - [`cargo-test-macro`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-test-macro)
83+
//! ([nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/cargo_test_macro/index.html)):
84+
//! This is the `#[cargo_test]` proc-macro used by the test suite to define tests.
85+
//! - [`credential`](https://github.com/rust-lang/cargo/tree/master/crates/credential)
86+
//! This subdirectory contains several packages for implementing the
87+
//! experimental
88+
//! [credential-process](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#credential-process)
89+
//! feature.
90+
//! - [`mdman`](https://github.com/rust-lang/cargo/tree/master/crates/mdman)
91+
//! ([nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/mdman/index.html)):
92+
//! This is a utility for generating cargo's man pages. See [Building the man
93+
//! pages](https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages)
94+
//! for more information.
95+
//! - [`resolver-tests`](https://github.com/rust-lang/cargo/tree/master/crates/resolver-tests)
96+
//! This is a dedicated package that defines tests for the [dependency
97+
//! resolver][core::resolver].
3898
//!
3999
//! ## Contribute to Cargo documentations
40100
//!

src/cargo/ops/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub use self::vendor::{vendor, VendorOptions};
3434

3535
pub mod cargo_add;
3636
mod cargo_clean;
37-
mod cargo_compile;
37+
pub(crate) mod cargo_compile;
3838
pub mod cargo_config;
3939
mod cargo_doc;
4040
mod cargo_fetch;
@@ -51,7 +51,7 @@ mod cargo_test;
5151
mod cargo_uninstall;
5252
mod common_for_install_and_uninstall;
5353
mod fix;
54-
mod lockfile;
54+
pub(crate) mod lockfile;
5555
pub(crate) mod registry;
5656
mod resolve;
5757
pub mod tree;
+1-106
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,3 @@
11
# Codebase Overview
22

3-
This is a very high-level overview of the Cargo codebase.
4-
5-
* [`src/bin/cargo`](https://github.com/rust-lang/cargo/tree/master/src/bin/cargo)
6-
--- Cargo is split in a library and a binary. This is the binary side that
7-
handles argument parsing, and then calls into the library to perform the
8-
appropriate subcommand. Each Cargo subcommand is a separate module here. See
9-
[SubCommands](subcommands.md).
10-
11-
* [`src/cargo/ops`](https://github.com/rust-lang/cargo/tree/master/src/cargo/ops)
12-
--- Every major operation is implemented here. This is where the binary CLI
13-
usually calls into to perform the appropriate action.
14-
15-
* [`src/cargo/ops/cargo_compile/mod.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_compile/mod.rs)
16-
--- This is the entry point for all the compilation commands. This is a
17-
good place to start if you want to follow how compilation starts and
18-
flows to completion.
19-
20-
* [`src/cargo/core/resolver`](https://github.com/rust-lang/cargo/tree/master/src/cargo/core/resolver)
21-
--- This is the dependency and feature resolvers.
22-
23-
* [`src/cargo/core/compiler`](https://github.com/rust-lang/cargo/tree/master/src/cargo/core/compiler)
24-
--- This is the code responsible for running `rustc` and `rustdoc`.
25-
26-
* [`src/cargo/core/compiler/build_context/mod.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/build_context/mod.rs)
27-
--- The `BuildContext` is the result of the "front end" of the build
28-
process. This contains the graph of work to perform and any settings
29-
necessary for `rustc`. After this is built, the next stage of building
30-
is handled in `Context`.
31-
32-
* [`src/cargo/core/compiler/context`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/context/mod.rs)
33-
--- The `Context` is the mutable state used during the build process. This
34-
is the core of the build process, and everything is coordinated through
35-
this.
36-
37-
* [`src/cargo/core/compiler/fingerprint.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/fingerprint.rs)
38-
--- The `fingerprint` module contains all the code that handles detecting
39-
if a crate needs to be recompiled.
40-
41-
* [`src/cargo/core/source`](https://github.com/rust-lang/cargo/tree/master/src/cargo/core/source)
42-
--- The `Source` trait is an abstraction over different sources of packages.
43-
Sources are uniquely identified by a `SourceId`. Sources are implemented in
44-
the
45-
[`src/cargo/sources`](https://github.com/rust-lang/cargo/tree/master/src/cargo/sources)
46-
directory.
47-
48-
* [`src/cargo/util`](https://github.com/rust-lang/cargo/tree/master/src/cargo/util)
49-
--- This directory contains generally-useful utility modules.
50-
51-
* [`src/cargo/util/config`](https://github.com/rust-lang/cargo/tree/master/src/cargo/util/config)
52-
--- This directory contains the config parser. It makes heavy use of
53-
[serde](https://serde.rs/) to merge and translate config values. The
54-
`Config` is usually accessed from the
55-
[`Workspace`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/workspace.rs),
56-
though references to it are scattered around for more convenient access.
57-
58-
* [`src/cargo/util/toml`](https://github.com/rust-lang/cargo/tree/master/src/cargo/util/toml)
59-
--- This directory contains the code for parsing `Cargo.toml` files.
60-
61-
* [`src/cargo/ops/lockfile.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/lockfile.rs)
62-
--- This is where `Cargo.lock` files are loaded and saved.
63-
64-
* [`src/doc`](https://github.com/rust-lang/cargo/tree/master/src/doc)
65-
--- This directory contains Cargo's documentation and man pages.
66-
67-
* [`src/etc`](https://github.com/rust-lang/cargo/tree/master/src/etc)
68-
--- These are files that get distributed in the `etc` directory in the Rust release.
69-
The man pages are auto-generated by a script in the `src/doc` directory.
70-
71-
* [`crates`](https://github.com/rust-lang/cargo/tree/master/crates)
72-
--- A collection of independent crates used by Cargo.
73-
74-
## Extra crates
75-
76-
Some functionality is split off into separate crates, usually in the
77-
[`crates`](https://github.com/rust-lang/cargo/tree/master/crates) directory.
78-
79-
* [`cargo-platform`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-platform)
80-
--- This library handles parsing `cfg` expressions.
81-
* [`cargo-test-macro`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-test-macro)
82-
--- This is a proc-macro used by the test suite to define tests. More
83-
information can be found at [`cargo_test`
84-
attribute](../tests/writing.md#cargo_test-attribute).
85-
* [`cargo-test-support`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-test-support)
86-
--- This contains a variety of code to support [writing
87-
tests](../tests/writing.md).
88-
* [`cargo-util`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-util)
89-
--- This contains general utility code that is shared between cargo and the
90-
testsuite.
91-
* [`crates-io`](https://github.com/rust-lang/cargo/tree/master/crates/crates-io)
92-
--- This contains code for accessing the crates.io API.
93-
* [`credential`](https://github.com/rust-lang/cargo/tree/master/crates/credential)
94-
--- This subdirectory contains several packages for implementing the
95-
experimental
96-
[credential-process](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#credential-process)
97-
feature.
98-
* [`home`](https://github.com/rust-lang/cargo/tree/master/crates/home) --- This library is shared between cargo and rustup and is used for finding their home directories.
99-
This is not directly depended upon with a `path` dependency; cargo uses the version from crates.io.
100-
It is intended to be versioned and published independently of Rust's release system.
101-
Whenever a change needs to be made, bump the version in Cargo.toml and `cargo publish` it manually, and then update cargo's `Cargo.toml` to depend on the new version.
102-
* [`mdman`](https://github.com/rust-lang/cargo/tree/master/crates/mdman)
103-
--- This is a utility for generating cargo's man pages. See [Building the man
104-
pages](https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages)
105-
for more information.
106-
* [`resolver-tests`](https://github.com/rust-lang/cargo/tree/master/crates/resolver-tests)
107-
--- This is a dedicated package that defines tests for the [dependency
108-
resolver](../architecture/packages.md#resolver).
3+
See [nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/cargo/index.html)

0 commit comments

Comments
 (0)