MCPcopy Create free account
hub / github.com/csskit/csskit / write_spec_module

Function write_spec_module

crates/csskit_spec_generator/src/main.rs:172–184  ·  view source on GitHub ↗

Writes the generated spec module to the appropriate file

(name: &str, code: &str)

Source from the content-addressed store, hash-verified

170
171/// Writes the generated spec module to the appropriate file
172fn write_spec_module(name: &str, code: &str) -> Result<()> {
173 let workspace_root = find_workspace_root()?;
174 let spec_snake = strip_css_prefix(name).to_snake_case();
175 let output_dir = workspace_root.join("crates").join("css_ast").join("src").join("values").join(&spec_snake);
176
177 create_dir_all(&output_dir)?;
178
179 let file_path = output_dir.join("mod.rs");
180 write(&file_path, code)?;
181 println!(" Wrote to {}", file_path.display());
182
183 Ok(())
184}
185
186/// Finds the workspace root by searching for Cargo.toml upward from the current directory
187fn find_workspace_root() -> Result<PathBuf> {

Callers 2

generate_single_specFunction · 0.85
mainFunction · 0.85

Calls 2

find_workspace_rootFunction · 0.70
strip_css_prefixFunction · 0.70

Tested by

no test coverage detected