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
// git repo. Instead, `cargo xtask release` runs this test before making

View File

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

View File

@ -8,8 +8,12 @@ use crate::{
util::list_rust_files,
};
pub(crate) fn generate(_check: bool) {
pub(crate) fn generate(check: bool) {
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 = add_preamble(crate::flags::CodegenType::FeatureDocs, contents);
let dst = project_root().join("docs/book/src/features_generated.md");