Skip to content

Commit fc5664a

Browse files
committed
ci: add linting to the CI for pixi_docs
1 parent 9293b00 commit fc5664a

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ jobs:
146146
git diff
147147
exit 1
148148
fi
149+
150+
# Lint pixi_docs
151+
pixi run lint-pixi_docs
149152
#
150153
# Run tests on important platforms.
151154
#

pixi.toml

+6
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ typos = ">=1.29.10,<2"
9797
[feature.lint.tasks]
9898
actionlint = { cmd = "actionlint", env = { SHELLCHECK_OPTS = "-e SC2086" } }
9999
cargo-clippy = "cargo clippy --all-targets --workspace -- -D warnings"
100+
cargo-clippy-pixi_docs = "cargo clippy --all-targets --workspace --manifest-path pixi_docs/Cargo.toml -- -D warnings"
100101
cargo-fmt = "cargo fmt --all"
102+
cargo-fmt-pixi_docs = "cargo fmt --all --manifest-path pixi_docs/Cargo.toml"
101103
check-openssl = "python tests/scripts/check-openssl.py"
102104
lint = "pre-commit run --all-files --hook-stage=manual"
105+
lint-pixi_docs = { depends-on = [
106+
"cargo-fmt-pixi_docs",
107+
"cargo-clippy-pixi_docs",
108+
] }
103109
pre-commit-install = "pre-commit install --install-hooks"
104110
pre-commit-run = "pre-commit run --all-files"
105111
prettier-fmt = { cmd = "prettier --write" }

pixi_docs/src/main.rs

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clap::{Arg, Command, CommandFactory};
2+
use fs_err as fs;
23
use itertools::Itertools;
34
use std::cmp::Ordering;
45
use std::collections::HashMap;
@@ -7,7 +8,6 @@ use std::fmt::Write;
78
use std::path::{Path, PathBuf};
89
use std::process::exit;
910
use std::str::FromStr;
10-
use fs_err as fs;
1111

1212
const MD_EXTENSION: &str = ".md";
1313

@@ -226,26 +226,24 @@ fn subcommands_table(subcommands: Vec<&Command>, parent: &str) -> String {
226226
let about = if let Some(about) = subcommand.get_about() {
227227
about
228228
} else {
229-
eprintln!("Warning: Subcommand `{}{}` has no description", parent, subcommand.get_name());
229+
eprintln!(
230+
"Warning: Subcommand `{}{}` has no description",
231+
parent,
232+
subcommand.get_name()
233+
);
230234
exit(1);
231235
};
232236
// Create a link to the subcommand's Markdown file
233237
let command_name = subcommand.get_name();
234238
let link = format!("{}/{}{}", parent, command_name, MD_EXTENSION);
235239
let link_md = format!("[`{}`]({})", command_name, link);
236-
writeln!(
237-
buffer,
238-
"| {} | {} |",
239-
link_md,
240-
about,
241-
)
242-
.unwrap();
240+
writeln!(buffer, "| {} | {} |", link_md, about,).unwrap();
243241
}
244242
buffer
245243
}
246244

247245
// Function to write a list of options to the buffer
248-
fn arguments(options: &[&clap::Arg], parents: &Vec<String>) -> String {
246+
fn arguments(options: &[&clap::Arg], parents: &[String]) -> String {
249247
let mut buffer = String::with_capacity(1024);
250248
for opt in options {
251249
if opt.is_hide_set() ||
@@ -261,13 +259,21 @@ fn arguments(options: &[&clap::Arg], parents: &Vec<String>) -> String {
261259
// No long name, but we have value names, assuming positional.
262260
format!("<{}>", value_names[0])
263261
} else {
264-
eprintln!("Error: Option: '{:?}' with parents {} has no long name", opt, parents.join(" "));
262+
eprintln!(
263+
"Error: Option: '{:?}' with parents {} has no long name",
264+
opt,
265+
parents.join(" ")
266+
);
265267
exit(1);
266268
};
267269

268270
// Error on missing help
269271
if opt.get_help().is_none() && opt.get_long().unwrap() != "help" {
270-
eprintln!("Error: Option `{} {}` has no description", parents.join(" "), long_name);
272+
eprintln!(
273+
"Error: Option `{} {}` has no description",
274+
parents.join(" "),
275+
long_name
276+
);
271277
exit(1);
272278
}
273279

0 commit comments

Comments
 (0)