Skip to content

Commit b9613ec

Browse files
committed
Auto merge of #6695 - ordovicia:doc-link, r=dwijnand
Link from ARCHITECTURE.md to docs.rs and github These links should help contributors dive into Cargo internals.
2 parents c457274 + 85c5fe1 commit b9613ec

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

ARCHITECTURE.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,37 @@ and more.
1212

1313
## Subcommands
1414

15-
Cargo is a single binary composed of a set of [`clap`][] subcommands. All subcommands live in
15+
Cargo is a single binary composed of a set of [`clap`] subcommands. All subcommands live in
1616
`src/bin/cargo/commands` directory. `src/bin/cargo/main.rs` is the entry point.
1717

18-
Each subcommand, such as `src/bin/cargo/commands/build.rs`, has its own API
18+
Each subcommand, such as [`src/bin/cargo/commands/build.rs`], has its own API
1919
interface, similarly to Git's, parsing command line options, reading the
2020
configuration files, discovering the Cargo project in the current directory and
2121
delegating the actual implementation to one
22-
of the functions in `src/cargo/ops/mod.rs`. This short file is a good
22+
of the functions in [`src/cargo/ops/mod.rs`]. This short file is a good
2323
place to find out about most of the things that Cargo can do.
2424
Subcommands are designed to pipe to one another, and custom subcommands make
2525
Cargo easy to extend and attach tools to.
2626

2727
[`clap`]: https://clap.rs/
28+
[`src/bin/cargo/commands/build.rs`]: src/bin/cargo/commands/build.rs
29+
[`src/cargo/ops/mod.rs`]: src/cargo/ops/mod.rs
2830

2931

3032
## Important Data Structures
3133

3234
There are some important data structures which are used throughout
3335
Cargo.
3436

35-
`Config` is available almost everywhere and holds "global"
37+
[`Config`] is available almost everywhere and holds "global"
3638
information, such as `CARGO_HOME` or configuration from
37-
`.cargo/config` files. The `shell` method of `Config` is the entry
39+
`.cargo/config` files. The [`shell`] method of [`Config`] is the entry
3840
point for printing status messages and other info to the console.
3941

40-
`Workspace` is the description of the workspace for the current
42+
[`Workspace`] is the description of the workspace for the current
4143
working directory. Each workspace contains at least one
42-
`Package`. Each package corresponds to a single `Cargo.toml`, and may
43-
define several `Target`s, such as the library, binaries, integration
44+
[`Package`]. Each package corresponds to a single `Cargo.toml`, and may
45+
define several [`Target`]s, such as the library, binaries, integration
4446
test or examples. Targets are crates (each target defines a crate
4547
root, like `src/lib.rs` or `examples/foo.rs`) and are what is actually
4648
compiled by `rustc`.
@@ -50,18 +52,26 @@ auxiliary ones. Packages are a unit of dependency in Cargo, and when
5052
package `foo` depends on package `bar`, that means that each target
5153
from `foo` needs the library target from `bar`.
5254

53-
`PackageId` is the unique identifier of a (possibly remote)
55+
[`PackageId`] is the unique identifier of a (possibly remote)
5456
package. It consist of three components: name, version and source
5557
id. Source is the place where the source code for package comes
5658
from. Typical sources are crates.io, a git repository or a folder on
5759
the local hard drive.
5860

59-
`Resolve` is the representation of a directed acyclic graph of package
60-
dependencies, which uses `PackageId`s for nodes. This is the data
61+
[`Resolve`] is the representation of a directed acyclic graph of package
62+
dependencies, which uses [`PackageId`]s for nodes. This is the data
6163
structure that is saved to the lock file. If there is no lock file,
6264
Cargo constructs a resolve by finding a graph of packages which
6365
matches declared dependency specification according to semver.
6466

67+
[`Config`]: https://docs.rs/cargo/latest/cargo/util/config/struct.Config.html
68+
[`shell`]: https://docs.rs/cargo/latest/cargo/util/config/struct.Config.html#method.shell
69+
[`Workspace`]: https://docs.rs/cargo/latest/cargo/core/struct.Workspace.html
70+
[`Package`]: https://docs.rs/cargo/latest/cargo/core/package/struct.Package.html
71+
[`Target`]: https://docs.rs/cargo/latest/cargo/core/manifest/struct.Target.html
72+
[`PackageId`]: https://docs.rs/cargo/latest/cargo/core/package_id/struct.PackageId.html
73+
[`Resolve`]: https://docs.rs/cargo/latest/cargo/core/struct.Resolve.html
74+
6575

6676
## Persistence
6777

@@ -70,9 +80,11 @@ the information used by Cargo must be persisted on the hard drive. The
7080
main sources of information are `Cargo.toml` and `Cargo.lock` files,
7181
`.cargo/config` configuration files and the globally shared registry
7282
of packages downloaded from crates.io, usually located at
73-
`~/.cargo/registry`. See `src/sources/registry` for the specifics of
83+
`~/.cargo/registry`. See [`src/cargo/sources/registry`] for the specifics of
7484
the registry storage format.
7585

86+
[`src/cargo/sources/registry`]: src/cargo/sources/registry
87+
7688

7789
## Concurrency
7890

@@ -108,15 +120,18 @@ p.cargo("run").stream().run();
108120

109121
Alternatively to build and run a custom version of cargo simply run `cargo build`
110122
and execute `target/debug/cargo`. Note that `+nightly`/`+stable` (and variants),
111-
being [rustup](https://rustup.rs/) features, won't work when executing the locally
123+
being [rustup] features, won't work when executing the locally
112124
built cargo binary directly, you have to instead build with `cargo +nightly build`
113125
and run with `rustup run` (e.g `rustup run nightly
114126
<path-to-cargo>/target/debug/cargo <args>..`) (or set the `RUSTC` env var to point
115127
to nightly rustc).
116128

129+
[rustup]: https://rustup.rs/
130+
131+
117132
## Logging
118133

119-
Cargo uses [`env_logger`](https://docs.rs/env_logger/*/env_logger/), so you can set
134+
Cargo uses [`env_logger`], so you can set
120135
`RUST_LOG` environment variable to get the logs. This is useful both for diagnosing
121136
bugs in stable Cargo and for local development. Cargo also has internal hierarchical
122137
profiling infrastructure, which is activated via `CARGO_PROFILE` variable
@@ -131,3 +146,5 @@ $ RUST_LOG=cargo::core::resolver=trace cargo generate-lockfile
131146
# Output first three levels of profiling info
132147
$ CARGO_PROFILE=3 cargo generate-lockfile
133148
```
149+
150+
[`env_logger`]: https://docs.rs/env_logger/*/env_logger/

0 commit comments

Comments
 (0)