vdev/commands/check/
component_docs.rs

1use crate::git;
2use anyhow::{Ok, Result};
3
4/// Check that component documentation is up-to-date
5#[derive(clap::Args, Debug)]
6#[command()]
7pub struct Cli {}
8
9impl Cli {
10    pub fn exec(self) -> Result<()> {
11        let files: Vec<String> = git::get_modified_files()?;
12        let dirty_component_files: Vec<String> = files
13            .into_iter()
14            .filter(|file| file.starts_with("website/cue/reference/components"))
15            .collect();
16
17        // If it is not empty, there are out-of-sync component Cue files in the current branch.
18        if !dirty_component_files.is_empty() {
19            println!("Found out-of-sync component Cue files in this branch:");
20            for file in dirty_component_files {
21                println!(" - {file}");
22            }
23            println!("Run `make generate-component-docs` locally to update your branch and commit/push the changes.");
24            std::process::exit(1);
25        }
26
27        Ok(())
28    }
29}