fix(codegen): do not generate docs with --check

Running `cargo codegen --check` should not generate any mdbook files,
since they are ignored in the repo and used only while releasing a new
copy of the documentation.

Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
Prajwal S N 2025-03-17 14:12:11 +05:30
parent b0632f749e
commit 1f366e7efe
No known key found for this signature in database
GPG key ID: 60701A603988FAC2
3 changed files with 18 additions and 7 deletions

View file

@ -53,6 +53,11 @@ r#####"
); );
} }
// Do not generate assists manual when run with `--check`
if check {
return;
}
{ {
// Generate assists manual. Note that we do _not_ commit manual to the // Generate assists manual. Note that we do _not_ commit manual to the
// git repo. Instead, `cargo xtask release` runs this test before making // git repo. Instead, `cargo xtask release` runs this test before making

View file

@ -10,14 +10,16 @@ use crate::{
pub(crate) fn generate(check: bool) { pub(crate) fn generate(check: bool) {
let diagnostics = Diagnostic::collect().unwrap(); let diagnostics = Diagnostic::collect().unwrap();
if !check { // Do not generate docs when run with `--check`
if check {
return;
}
let contents = let contents =
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"); diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
let contents = add_preamble(crate::flags::CodegenType::DiagnosticsDocs, contents); let contents = add_preamble(crate::flags::CodegenType::DiagnosticsDocs, contents);
let dst = project_root().join("docs/book/src/diagnostics_generated.md"); let dst = project_root().join("docs/book/src/diagnostics_generated.md");
fs::write(dst, contents).unwrap(); fs::write(dst, contents).unwrap();
} }
}
#[derive(Debug)] #[derive(Debug)]
struct Diagnostic { struct Diagnostic {

View file

@ -8,8 +8,12 @@ use crate::{
util::list_rust_files, util::list_rust_files,
}; };
pub(crate) fn generate(_check: bool) { pub(crate) fn generate(check: bool) {
let features = Feature::collect().unwrap(); let features = Feature::collect().unwrap();
// Do not generate docs when run with `--check`
if check {
return;
}
let contents = features.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"); let contents = features.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
let contents = add_preamble(crate::flags::CodegenType::FeatureDocs, contents); let contents = add_preamble(crate::flags::CodegenType::FeatureDocs, contents);
let dst = project_root().join("docs/book/src/features_generated.md"); let dst = project_root().join("docs/book/src/features_generated.md");