Skip to content

Commit 982fce1

Browse files
authored
Fix rustdoc warnings and test cargo doc in CI (#4711)
## Problem `cargo +nightly doc` is giving a lot of warnings: broken links, naked URLs, etc. ## Summary of changes * update the `proc-macro2` dependency so that it can compile on latest Rust nightly, see dtolnay/proc-macro2#391 and dtolnay/proc-macro2#398 * allow the `private_intra_doc_links` lint, as linking to something that's private is always more useful than just mentioning it without a link: if the link breaks in the future, at least there is a warning due to that. Also, one might enable [`--document-private-items`](https://doc.rust-lang.org/cargo/commands/cargo-doc.html#documentation-options) in the future and make these links work in general. * fix all the remaining warnings given by `cargo +nightly doc` * make it possible to run `cargo doc` on stable Rust by updating `opentelemetry` and associated crates to version 0.19, pulling in a fix that previously broke `cargo doc` on stable: open-telemetry/opentelemetry-rust#904 * Add `cargo doc` to CI to ensure that it won't get broken in the future. Fixes #2557 ## Future work * Potentially, it might make sense, for development purposes, to publish the generated rustdocs somewhere, like for example [how the rust compiler does it](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/index.html). I will file an issue for discussion.
1 parent e767ced commit 982fce1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+200
-138
lines changed

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ opt-level = 3
1212
# Turn on a small amount of optimization in Development mode.
1313
opt-level = 1
1414

15+
[build]
16+
# This is only present for local builds, as it will be overridden
17+
# by the RUSTDOCFLAGS env var in CI.
18+
rustdocflags = ["-Arustdoc::private_intra_doc_links"]
19+
1520
[alias]
1621
build_testing = ["build", "--features", "testing"]
1722
neon = ["run", "--bin", "neon_local"]

.github/workflows/build_and_test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ jobs:
127127
- name: Run cargo clippy (release)
128128
run: cargo hack --feature-powerset clippy --release $CLIPPY_COMMON_ARGS
129129

130+
- name: Check documentation generation
131+
run: cargo doc --workspace --no-deps --document-private-items
132+
env:
133+
RUSTDOCFLAGS: "-Dwarnings -Arustdoc::private_intra_doc_links"
134+
130135
# Use `${{ !cancelled() }}` to run quck tests after the longer clippy run
131136
- name: Check formatting
132137
if: ${{ !cancelled() }}

Cargo.lock

Lines changed: 22 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ notify = "5.0.0"
8484
num_cpus = "1.15"
8585
num-traits = "0.2.15"
8686
once_cell = "1.13"
87-
opentelemetry = "0.18.0"
88-
opentelemetry-otlp = { version = "0.11.0", default_features=false, features = ["http-proto", "trace", "http", "reqwest-client"] }
89-
opentelemetry-semantic-conventions = "0.10.0"
87+
opentelemetry = "0.19.0"
88+
opentelemetry-otlp = { version = "0.12.0", default_features=false, features = ["http-proto", "trace", "http", "reqwest-client"] }
89+
opentelemetry-semantic-conventions = "0.11.0"
9090
parking_lot = "0.12"
9191
pbkdf2 = "0.12.1"
9292
pin-project-lite = "0.2"
@@ -95,7 +95,7 @@ prost = "0.11"
9595
rand = "0.8"
9696
regex = "1.4"
9797
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] }
98-
reqwest-tracing = { version = "0.4.0", features = ["opentelemetry_0_18"] }
98+
reqwest-tracing = { version = "0.4.0", features = ["opentelemetry_0_19"] }
9999
reqwest-middleware = "0.2.0"
100100
reqwest-retry = "0.2.2"
101101
routerify = "3"
@@ -130,7 +130,7 @@ toml_edit = "0.19"
130130
tonic = {version = "0.9", features = ["tls", "tls-roots"]}
131131
tracing = "0.1"
132132
tracing-error = "0.2.0"
133-
tracing-opentelemetry = "0.18.0"
133+
tracing-opentelemetry = "0.19.0"
134134
tracing-subscriber = { version = "0.3", default_features = false, features = ["smallvec", "fmt", "tracing-log", "std", "env-filter"] }
135135
url = "2.2"
136136
uuid = { version = "1.2", features = ["v4", "serde"] }

compute_tools/src/pg_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const POSTGRES_WAIT_TIMEOUT: Duration = Duration::from_millis(60 * 1000); // mil
1919
/// Escape a string for including it in a SQL literal. Wrapping the result
2020
/// with `E'{}'` or `'{}'` is not required, as it returns a ready-to-use
2121
/// SQL string literal, e.g. `'db'''` or `E'db\\'`.
22-
/// See https://github.com/postgres/postgres/blob/da98d005cdbcd45af563d0c4ac86d0e9772cd15f/src/backend/utils/adt/quote.c#L47
22+
/// See <https://github.com/postgres/postgres/blob/da98d005cdbcd45af563d0c4ac86d0e9772cd15f/src/backend/utils/adt/quote.c#L47>
2323
/// for the original implementation.
2424
pub fn escape_literal(s: &str) -> String {
2525
let res = s.replace('\'', "''").replace('\\', "\\\\");

control_plane/src/background_process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! (non-Neon binaries don't necessarily follow our pidfile conventions).
1111
//! The pid stored in the file is later used to stop the service.
1212
//!
13-
//! See [`lock_file`] module for more info.
13+
//! See the [`lock_file`](utils::lock_file) module for more info.
1414
1515
use std::ffi::OsStr;
1616
use std::io::Write;

control_plane/src/broker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
//!
33
//! In the local test environment, the data for each safekeeper is stored in
44
//!
5+
//! ```text
56
//! .neon/safekeepers/<safekeeper id>
6-
//!
7+
//! ```
78
use anyhow::Context;
89

910
use std::path::PathBuf;

control_plane/src/endpoint.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
//!
33
//! In the local test environment, the data for each endpoint is stored in
44
//!
5+
//! ```text
56
//! .neon/endpoints/<endpoint id>
7+
//! ```
68
//!
79
//! Some basic information about the endpoint, like the tenant and timeline IDs,
810
//! are stored in the `endpoint.json` file. The `endpoint.json` file is created
@@ -22,7 +24,7 @@
2224
//!
2325
//! Directory contents:
2426
//!
25-
//! ```ignore
27+
//! ```text
2628
//! .neon/endpoints/main/
2729
//! compute.log - log output of `compute_ctl` and `postgres`
2830
//! endpoint.json - serialized `EndpointConf` struct

control_plane/src/safekeeper.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
//!
33
//! In the local test environment, the data for each safekeeper is stored in
44
//!
5+
//! ```text
56
//! .neon/safekeepers/<safekeeper id>
6-
//!
7+
//! ```
78
use std::io::Write;
89
use std::path::PathBuf;
910
use std::process::Child;

libs/metrics/src/metric_vec_duration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Helpers for observing duration on HistogramVec / CounterVec / GaugeVec / MetricVec<T>.
1+
//! Helpers for observing duration on `HistogramVec` / `CounterVec` / `GaugeVec` / `MetricVec<T>`.
22
33
use std::{future::Future, time::Instant};
44

0 commit comments

Comments
 (0)