Skip to content

Commit f126ea4

Browse files
committed
Auto merge of #11019 - weihanglo:doc-private-items-cargo-itself, r=epage
Document private items for Cargo and publish under contributor guide
2 parents 5276a04 + 1c82d9c commit f126ea4

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

.github/workflows/contrib.yml

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
mkdir mdbook
2222
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.9/mdbook-v0.4.9-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
2323
echo `pwd`/mdbook >> $GITHUB_PATH
24+
- name: Build API doc
25+
run: |
26+
cargo doc --document-private-items --no-deps
2427
- name: Deploy docs
2528
run: |
2629
cd src/doc/contrib
@@ -33,6 +36,8 @@ jobs:
3336
git update-ref -d refs/heads/gh-pages
3437
rm -rf contrib
3538
mv ../book contrib
39+
# Move rustdoc under contrib/
40+
mv ../../../../target/doc contrib/apidoc
3641
git add contrib
3742
git commit -m "Deploy $GITHUB_SHA to gh-pages"
3843
git push --force

src/cargo/lib.rs

+68
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,74 @@
66
// necessarily an improvement, we prefer to not use them at this time.
77
#![allow(clippy::all)]
88

9+
//! # Cargo as a library
10+
//!
11+
//! Cargo, the Rust package manager, is also provided as a library.
12+
//!
13+
//! There are two places you can find API documentation of cargo-the-library,
14+
//!
15+
//! - <https://docs.rs/cargo> and
16+
//! - <https://doc.crates.io/contrib/apidoc/cargo>.
17+
//!
18+
//! Each of them targets on a slightly different audience.
19+
//!
20+
//! ## For external tool developers
21+
//!
22+
//! The documentation on <https://docs.rs/cargo> contains public-facing items in cargo-the-library.
23+
//! External tool developers may find it useful when trying to reuse existing building blocks from Cargo.
24+
//! However, using Cargo as a library has drawbacks, especially cargo-the-library is unstable,
25+
//! and there is no clear path to stabilize it soon at the time of writing.
26+
//! See [The Cargo Book: External tools] for more on this topic.
27+
//!
28+
//! Cargo API documentation on docs.rs gets updates along with each Rust release.
29+
//! Its version always has a 0 major version to state it is unstable.
30+
//! The minor version is always +1 of rustc's minor version
31+
//! (that is, `cargo 0.66.0` corresponds to `rustc 1.65`).
32+
//!
33+
//! ## For Cargo contributors
34+
//!
35+
//! The documentation on <https://doc.crates.io/contrib/apidoc/cargo> contains all items in Cargo.
36+
//! Contributors of Cargo may find it useful as a reference of Cargo's implementation details.
37+
//! It's built with `--document-private-items` rustdoc flag,
38+
//! so you might expect to see some noise and strange items here.
39+
//! The Cargo team and contributors strive for jotting down every details
40+
//! from their brains in each issue and PR.
41+
//! However, something might just disappear in the air with no reason.
42+
//! This documentation can be seen as their extended minds,
43+
//! sharing designs and hacks behind both public and private interfaces.
44+
//!
45+
//! If you are just diving into Cargo internals, [Cargo Architecture Overview]
46+
//! is the best material to get a broader context of how Cargo works under the hood.
47+
//! Things also worth a read are important concepts reside in source code,
48+
//! which Cargo developers have been crafting for a while, namely
49+
//!
50+
//! - [`cargo::core::resolver`](crate::core::resolver),
51+
//! - [`cargo::core::compiler::fingerprint`](core/compiler/fingerprint/index.html),
52+
//! - [`cargo::util::config`](crate::util::config),
53+
//! - [`cargo::ops::fix`](ops/fix/index.html), and
54+
//! - [`cargo::sources::registry`](crate::sources::registry).
55+
//!
56+
//! This API documentation is published on each push of rust-lang/cargo master branch.
57+
//! In other words, it always reflects the latest doc comments in source code on master branch.
58+
//!
59+
//! ## Contribute to Cargo documentations
60+
//!
61+
//! The Cargo team always continues improving all external and internal documentations.
62+
//! If you spot anything could be better, don't hesitate to discuss with the team on
63+
//! Zulip [`t-cargo` stream], or [submit an issue] right on GitHub.
64+
//! There is also an issue label [`A-documenting-cargo-itself`],
65+
//! which is generally for documenting user-facing [The Cargo Book],
66+
//! but the Cargo team is welcome any form of enhancement for the [Cargo Contributor Guide]
67+
//! and this API documentation as well.
68+
//!
69+
//! [The Cargo Book: External tools]: https://doc.rust-lang.org/stable/cargo/reference/external-tools.html
70+
//! [Cargo Architecture Overview]: https://doc.crates.io/contrib/architecture
71+
//! [`t-cargo` stream]: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo
72+
//! [submit an issue]: https://github.com/rust-lang/cargo/issues/new/choose
73+
//! [`A-documenting-cargo-itself`]: https://github.com/rust-lang/cargo/labels/A-documenting-cargo-itself
74+
//! [The Cargo Book]: https://doc.rust-lang.org/cargo/
75+
//! [Cargo Contributor Guide]: https://doc.crates.io/contrib/
76+
977
use crate::core::shell::Verbosity::Verbose;
1078
use crate::core::Shell;
1179
use anyhow::Error;

src/cargo/ops/registry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ pub enum RegistryConfig {
4848
impl RegistryConfig {
4949
/// Returns `true` if the credential is [`None`].
5050
///
51-
/// [`None`]: Credential::None
51+
/// [`None`]: Self::None
5252
pub fn is_none(&self) -> bool {
5353
matches!(self, Self::None)
5454
}
5555
/// Returns `true` if the credential is [`Token`].
5656
///
57-
/// [`Token`]: Credential::Token
57+
/// [`Token`]: Self::Token
5858
pub fn is_token(&self) -> bool {
5959
matches!(self, Self::Token(..))
6060
}

0 commit comments

Comments
 (0)