|
9 | 9 |
|
10 | 10 | //! # Cargo as a library
|
11 | 11 | //!
|
12 |
| -//! Cargo, the Rust package manager, is also provided as a library. |
13 |
| -//! |
14 | 12 | //! There are two places you can find API documentation of cargo-the-library,
|
15 | 13 | //!
|
16 |
| -//! - <https://docs.rs/cargo> and |
17 |
| -//! - <https://doc.rust-lang.org/nightly/nightly-rustc/cargo>. |
18 |
| -//! |
19 |
| -//! Each of them targets on a slightly different audience. |
20 |
| -//! |
21 |
| -//! ## For external tool developers |
22 |
| -//! |
23 |
| -//! The documentation on <https://docs.rs/cargo> contains public-facing items in cargo-the-library. |
24 |
| -//! External tool developers may find it useful when trying to reuse existing building blocks from Cargo. |
25 |
| -//! However, using Cargo as a library has drawbacks, especially cargo-the-library is unstable, |
26 |
| -//! and there is no clear path to stabilize it soon at the time of writing. |
27 |
| -//! See [The Cargo Book: External tools] for more on this topic. |
28 |
| -//! |
29 |
| -//! Cargo API documentation on docs.rs gets updates along with each Rust release. |
30 |
| -//! Its version always has a 0 major version to state it is unstable. |
31 |
| -//! The minor version is always +1 of rustc's minor version |
32 |
| -//! (that is, `cargo 0.66.0` corresponds to `rustc 1.65`). |
33 |
| -//! |
34 |
| -//! ## For Cargo contributors |
| 14 | +//! - <https://docs.rs/cargo>: targeted at external tool developers using cargo-the-library |
| 15 | +//! - Released with every rustc release |
| 16 | +//! - <https://doc.rust-lang.org/nightly/nightly-rustc/cargo>: targeted at cargo contributors |
| 17 | +//! - Updated on each update of the `cargo` submodule in `rust-lang/rust` |
35 | 18 | //!
|
36 |
| -//! The documentation on <https://doc.rust-lang.org/nightly/nightly-rustc/cargo> contains all items in Cargo. |
37 |
| -//! Contributors of Cargo may find it useful as a reference of Cargo's implementation details. |
38 |
| -//! It's built with `--document-private-items` rustdoc flag, |
39 |
| -//! so you might expect to see some noise and strange items here. |
40 |
| -//! The Cargo team and contributors strive for jotting down every details |
41 |
| -//! from their brains in each issue and PR. |
42 |
| -//! However, something might just disappear in the air with no reason. |
43 |
| -//! This documentation can be seen as their extended minds, |
44 |
| -//! sharing designs and hacks behind both public and private interfaces. |
| 19 | +//! **WARNING:** Using Cargo as a library has drawbacks, particulary the API is unstable, |
| 20 | +//! and there is no clear path to stabilize it soon at the time of writing. See [The Cargo Book: |
| 21 | +//! External tools] for more on this topic. |
45 | 22 | //!
|
46 |
| -//! If you are just diving into Cargo internals, [Cargo Architecture Overview] |
47 |
| -//! is the best material to get a broader context of how Cargo works under the hood. |
48 |
| -//! Things also worth a read are important concepts reside in source code, |
49 |
| -//! which Cargo developers have been crafting for a while, namely |
| 23 | +//! ## Overview |
50 | 24 | //!
|
51 |
| -//! - [`cargo::core::resolver`](crate::core::resolver), |
52 |
| -//! - [`cargo::core::compiler::fingerprint`](core/compiler/fingerprint/index.html), |
53 |
| -//! - [`cargo::util::config`](crate::util::config), |
54 |
| -//! - [`cargo::ops::fix`](ops/fix/index.html), and |
55 |
| -//! - [`cargo::sources::registry`](crate::sources::registry). |
| 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. |
56 | 63 | //!
|
57 |
| -//! This API documentation is published on each push of rust-lang/cargo master branch. |
58 |
| -//! 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]. |
59 | 98 | //!
|
60 | 99 | //! ## Contribute to Cargo documentations
|
61 | 100 | //!
|
|
0 commit comments