Skip to content

Commit eff20bd

Browse files
authored
chore: update tokio-console screenshots for v0.1.13 (#591)
The screenshots on the docs.rs page for tokio-console are a bit out of date. They are from v0.1.8 and still show the Target column instead of the Kind column. With the task size instrumentation and new lints which will be released in the next version of Tokio Console, we need screenshots which match what the user will see. The same goes for the screenshots in the repository root README.md, which anyone visiting the repo page on GitHub will see. This change adds new screenshots for docs.rs and replaces the README screenshots. We have to keep the docs.rs images from previous versions still, since docs.rs pages for previous versions still reference them. Additionally, a new CI job to build the docs.rs documentation and also to check that all the images referenced from the tokio-console README file (which is used on docs.rs) are present in the repository, as we can't inspect the documentation until the change is merged. This is done via a new `xtask` operation.
1 parent f4ee0df commit eff20bd

File tree

11 files changed

+104
-7
lines changed

11 files changed

+104
-7
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@ jobs:
101101
- name: Run cargo clippy
102102
run: cargo clippy --workspace --all-targets --no-deps -- -D warnings
103103

104+
docs:
105+
name: Docs
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: Checkout sources
109+
uses: actions/checkout@v4
110+
111+
- name: Install ${{ matrix.rust }} toolchain
112+
uses: dtolnay/rust-toolchain@master
113+
with:
114+
toolchain: stable
115+
116+
- uses: Swatinem/rust-cache@v2
117+
118+
- name: Run xtask check-docs-images
119+
run: cargo run --bin xtask -- check-docs-images
120+
104121
grpc_web:
105122
name: gRPC-web Example
106123
runs-on: ubuntu-latest

assets/readme/task-details.png

-26.8 KB
Loading

assets/readme/top-for-tasks.png

106 KB
Loading
Loading
Loading
511 KB
Loading
236 KB
Loading
375 KB
Loading

tokio-console/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ tokio-console --lang en_US.UTF-8
121121
When the console CLI is launched, it displays a list of all [asynchronous tasks]
122122
in the program:
123123

124-
![tasks list](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.8/tasks_list.png)
124+
![tasks list](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.13/tasks_list.png)
125125

126126
Tasks are displayed in a table.
127127

@@ -154,7 +154,7 @@ task.
154154

155155
This view shows details about a specific task:
156156

157-
![task details](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.8/task_details.png)
157+
![task details](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.13/task_details.png)
158158

159159
The task details view includes percentiles and a visual histogram of the polling (busy) times
160160
and scheduled times.
@@ -166,7 +166,7 @@ Pressing the <kbd>escape</kbd> key returns to the task list.
166166
The <kbd>r</kbd> key switches from the list of tasks to a list of [resources],
167167
such as synchronization primitives, I/O resources, et cetera:
168168

169-
![resource list](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.8/resources_list.png)
169+
![resource list](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.13/resources_list.png)
170170

171171
Resources are displayed in a table similar to the task list.
172172

@@ -192,13 +192,13 @@ while a resource is highlighted displays details about that resource.
192192

193193
### Resource Details
194194

195-
![resource details --- sleep](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.8/resource_details_sleep.png)
195+
![resource details --- sleep](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.13/resource_details_sleep.png)
196196

197197
The resource details view lists the tasks currently waiting on that resource.
198198
This may be a single task, as in the [`tokio::time::Sleep`] above, or
199199
a large number of tasks, such as this private `tokio::sync::batch_semaphore::Semaphore`:
200200

201-
![resource details --- semaphore](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.8/resource_details_semaphore.png)
201+
![resource details --- semaphore](https://raw.githubusercontent.com/tokio-rs/console/main/assets/tokio-console-0.1.13/resource_details_semaphore.png)
202202

203203
The resource details view includes a table of async ops belonging to the resource.
204204

xtask/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ tonic-build = { version = "0.12", default-features = false, features = [
1212
] }
1313
clap = { version = "~4.5.4", features = ["derive"] }
1414
color-eyre = "0.6"
15+
regex = "1.11.0"

xtask/src/main.rs

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
use std::{
2+
fmt::Write,
3+
fs,
4+
io::{BufRead, BufReader},
5+
path::{Path, PathBuf},
6+
};
7+
18
use clap::Parser;
29
use color_eyre::{
3-
eyre::{ensure, WrapErr},
10+
eyre::{ensure, eyre, WrapErr},
411
Result,
512
};
6-
use std::{fs, path::PathBuf};
13+
use regex::Regex;
714

815
/// tokio-console dev tasks
916
#[derive(Debug, clap::Parser)]
@@ -16,6 +23,9 @@ struct Args {
1623
enum Command {
1724
/// Generate `console-api` protobuf bindings.
1825
GenProto,
26+
27+
/// Check images needed for tokio-console docs.rs main page
28+
CheckDocsImages,
1929
}
2030

2131
fn main() -> Result<()> {
@@ -27,6 +37,7 @@ impl Command {
2737
fn run(&self) -> Result<()> {
2838
match self {
2939
Self::GenProto => gen_proto(),
40+
Self::CheckDocsImages => check_docs_rs_images(),
3041
}
3142
}
3243
}
@@ -78,3 +89,71 @@ fn gen_proto() -> Result<()> {
7889
.compile_protos(&proto_files[..], &[proto_dir])
7990
.context("failed to compile protobuf files")
8091
}
92+
93+
fn check_docs_rs_images() -> Result<()> {
94+
eprintln!("checking images for tokio-console docs.rs page...");
95+
96+
let base_dir = {
97+
let mut mydir = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"));
98+
ensure!(mydir.pop(), "manifest path should not be relative!");
99+
mydir
100+
};
101+
102+
let readme_path = base_dir.join("tokio-console/README.md");
103+
let file =
104+
fs::File::open(&readme_path).expect("couldn't open tokio-console README.md for reading");
105+
106+
let regex_line = line!() + 1;
107+
let re = Regex::new(
108+
r"https://raw.githubusercontent.com/tokio-rs/console/main/(assets/tokio-console-[\d\.]+\/\w+\.png)",
109+
)
110+
.expect("couldn't compile regex");
111+
let reader = BufReader::new(file);
112+
let mut readme_images = Vec::new();
113+
for line in reader.lines() {
114+
let Ok(line) = line else {
115+
break;
116+
};
117+
118+
let Some(image_match) = re.captures(&line) else {
119+
continue;
120+
};
121+
122+
let image_path = image_match.get(1).unwrap().as_str();
123+
readme_images.push(image_path.to_string());
124+
}
125+
126+
if readme_images.is_empty() {
127+
let regex_file = file!();
128+
let readme_path = readme_path.to_string_lossy();
129+
return Err(eyre!(
130+
"No images found in tokio-console README.md!\n\n\
131+
The README that was read is located at: {readme_path}\n\n\
132+
This probably means that there is a problem with the regex defined at \
133+
{regex_file}:{regex_line}."
134+
));
135+
}
136+
137+
let mut missing = Vec::new();
138+
for image_path in &readme_images {
139+
if !Path::new(image_path).exists() {
140+
missing.push(image_path.to_string());
141+
}
142+
}
143+
144+
if missing.is_empty() {
145+
eprintln!(
146+
"OK: verified existance of image files in README, count: {}",
147+
readme_images.len()
148+
);
149+
150+
Ok(())
151+
} else {
152+
let mut error_buffer = "Tokio console README images missing:\n".to_string();
153+
for path in missing {
154+
writeln!(&mut error_buffer, " - {path}")?;
155+
}
156+
157+
Err(eyre!("{}", error_buffer))
158+
}
159+
}

0 commit comments

Comments
 (0)