Skip to content

Commit 9ca89e9

Browse files
📝 Add docstrings to audit/language-safety-20260907
Docstrings generation was requested by @hyperpolymath. * #64 (comment) The following files were modified: * `setup.sh` * `src/codegen/mod.rs` * `src/main.rs` * `tests/build_process.rs`
1 parent be2ccd8 commit 9ca89e9

4 files changed

Lines changed: 56 additions & 8 deletions

File tree

‎setup.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ detect_shell() {
7676
printf "%s" "$CURRENT_SHELL"
7777
}
7878

79-
# ── Platform Detection ──
79+
# detect_platform identifies the operating system, distribution, architecture, and available package manager, storing the results in global variables.
8080
detect_platform() {
8181
OS="unknown"
8282
DISTRO="unknown"
@@ -127,7 +127,7 @@ detect_platform() {
127127
esac
128128
}
129129

130-
# install_just installs the `just` task runner using the detected package manager, or reports failure when it is unavailable.
130+
# install_just installs the `just` task runner using the detected package manager and reports whether installation succeeded.
131131
install_just() {
132132
if command -v just >/dev/null 2>&1; then
133133
ok "just already installed: $(just --version 2>/dev/null | head -1)"

‎src/codegen/mod.rs‎

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,28 @@ use std::path::Path;
1818

1919
use crate::manifest::Manifest;
2020

21-
/// Generate all artifacts: Halide C++ source, schedule, and CMakeLists.txt.
21+
/// Generates the Halide generator source, runner source, and CMake configuration files.
2222
///
23-
/// Output directory structure:
24-
/// <output_dir>/
25-
/// <name>_generator.cpp — Halide generator (algorithm + schedule)
26-
/// <name>_runner.cpp — Runner that loads input, runs pipeline, writes output
27-
/// CMakeLists.txt — Build configuration for Halide
23+
/// The files are written to `output_dir` using the project name from the manifest:
24+
/// `<name>_generator.cpp`, `<name>_runner.cpp`, and `CMakeLists.txt`.
25+
///
26+
/// # Arguments
27+
///
28+
/// * `manifest` - Project manifest containing the pipeline and generation settings.
29+
/// * `output_dir` - Directory in which to write the generated files.
30+
///
31+
/// # Errors
32+
///
33+
/// Returns an error if the pipeline is invalid, the output directory cannot be created,
34+
/// or any generated file cannot be written.
35+
///
36+
/// # Examples
37+
///
38+
/// ```no_run
39+
/// # let manifest: Manifest = todo!();
40+
/// generate_all(&manifest, "generated")?;
41+
/// # Ok::<(), anyhow::Error>(())
42+
/// ```
2843
pub fn generate_all(manifest: &Manifest, output_dir: &str) -> Result<()> {
2944
let out = Path::new(output_dir);
3045
fs::create_dir_all(out).context("Failed to create output directory")?;
@@ -137,6 +152,23 @@ pub fn build(manifest: &Manifest, release: bool) -> Result<()> {
137152
/// # }
138153
/// ```
139154
pub fn run(manifest: &Manifest, args: &[String]) -> Result<()> {
155+
/// Runs the generated pipeline using the debug configuration.
156+
///
157+
/// # Arguments
158+
///
159+
/// * `args` - Arguments passed to the generated runner.
160+
///
161+
/// # Returns
162+
///
163+
/// `Ok(())` if the pipeline completes successfully; otherwise, an error.
164+
///
165+
/// # Examples
166+
///
167+
/// ```no_run
168+
/// let manifest = Manifest::default();
169+
/// run(&manifest, &[])?;
170+
/// # Ok::<(), _>(())
171+
/// ```
140172
pub fn run(manifest: &Manifest, args: &[String]) -> Result<()> {
141173
run_configuration(manifest, false, args)
142174
}

‎src/main.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ enum Commands {
9696
/// let command = "halideiser info --manifest halideiser.toml";
9797
/// assert!(command.starts_with("halideiser "));
9898
/// ```
99+
///
100+
/// # Errors
101+
///
102+
/// Returns an error if the selected subcommand cannot complete successfully.
99103
fn main() -> Result<()> {
100104
let cli = Cli::parse();
101105
match cli.command {

‎tests/build_process.rs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ fn fixture() -> tempfile::TempDir {
3535
///
3636
/// Panics if the process cannot be started.
3737
fn invoke(doc?)
38+
/// Runs the `halideiser` binary in the specified directory with the given arguments.
39+
///
40+
/// # Examples
41+
///
42+
/// ```no_run
43+
/// let output = invoke(std::path::Path::new("."), &["build"]);
44+
/// assert!(output.status.success());
45+
/// ```
46+
///
47+
/// # Panics
48+
///
49+
/// Panics if the process cannot be started.
3850
fn invoke(dir: &std::path::Path, args: &[&str]) -> std::process::Output {
3951
Command::new(env!("CARGO_BIN_EXE_halideiser"))
4052
.current_dir(dir)

0 commit comments

Comments
 (0)