Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
docs: compile-check four doctest examples (ignore → no_run/run) (#2743)
Maximilian Roos8e4edf88777f
diff --git a/src/config/user/resolved.rs b/src/config/user/resolved.rsindex 620efac95..98e9075eb 100644--- a/src/config/user/resolved.rs+++ b/src/config/user/resolved.rs@@ -16,13 +16,17 @@ use super::sections::{/// on each config to get values with defaults applied.////// # Example-/// ```ignore-/// let resolved = config.resolved(project);+/// ```+/// use worktrunk::config::UserConfig;+///+/// let config = UserConfig::default();+/// let resolved = config.resolved(None); // or Some(project_id)/// let full = resolved.list.full(); // bool, default applied/// let squash = resolved.merge.squash(); // bool, default applied/// let stage = resolved.commit.stage(); // StageMode, default applied/// let pager = resolved.switch_picker.pager(); // Option<&str>-/// let cd = resolved.switch.cd(); // bool, default applied+/// let cd = resolved.switch.cd(); // bool, default applied+/// # let _ = (full, squash, stage, pager, cd);/// ```#[derive(Debug, Clone, PartialEq)]pub struct ResolvedConfig {diff --git a/src/git/error.rs b/src/git/error.rsindex 6b753271c..de645751b 100644--- a/src/git/error.rs+++ b/src/git/error.rs@@ -366,13 +366,16 @@ impl SwitchSuggestionCtx {////// # Usage///-/// ```ignore-/// // Return a typed error-/// return Err(GitError::DetachedHead { action: Some("merge".into()) }.into());+/// ```+/// use worktrunk::git::GitError;+///+/// // A typed error converts into a type-erased one (in real code, into `anyhow::Error`).+/// let err: Box<dyn std::error::Error> =+/// GitError::DetachedHead { action: Some("merge".into()) }.into();///-/// // Pattern match on errors-/// if let Some(GitError::BranchAlreadyExists { branch }) = err.downcast_ref() {-/// println!("Branch {} exists", branch);+/// // Recover the typed error to branch on the variant.+/// if let Some(GitError::BranchAlreadyExists { branch }) = err.downcast_ref::<GitError>() {+/// println!("branch {branch} already exists");/// }/// ```#[derive(Debug, Clone)]diff --git a/src/git/remote_ref/mod.rs b/src/git/remote_ref/mod.rsindex 0c824f384..8cc6b11f1 100644--- a/src/git/remote_ref/mod.rs+++ b/src/git/remote_ref/mod.rs@@ -10,12 +10,16 @@//!//! # Usage//!-//! ```ignore+//! ```no_run+//! use worktrunk::git::Repository;//! use worktrunk::git::remote_ref::{GitHubProvider, RemoteRefProvider};-//!+//! # fn example() -> Result<(), Box<dyn std::error::Error>> {+//! let repo = Repository::at(".")?;//! let provider = GitHubProvider;//! let info = provider.fetch_info(123, &repo)?;//! println!("PR #{}: {}", info.number, info.title);+//! # Ok(())+//! # }//! ```//!//! # Platform-Specific Notesdiff --git a/src/shell_exec.rs b/src/shell_exec.rsindex 004723caf..2e0606883 100644--- a/src/shell_exec.rs+++ b/src/shell_exec.rs@@ -541,23 +541,31 @@ fn run_with_timeout_impl(/// # Examples////// Capture output:-/// ```ignore+/// ```no_run+/// use worktrunk::shell_exec::Cmd;+/// # fn example(repo_path: std::path::PathBuf) -> Result<(), Box<dyn std::error::Error>> {/// let output = Cmd::new("git")/// .args(["status", "--porcelain"])/// .current_dir(&repo_path)/// .context("my-worktree")/// .run()?;+/// # let _ = output;+/// # Ok(())+/// # }/// ```////// Stream output (hooks, interactive):-/// ```ignore+/// ```no_run/// use std::process::Stdio;-///+/// use worktrunk::shell_exec::Cmd;+/// # fn example(repo_path: std::path::PathBuf) -> Result<(), Box<dyn std::error::Error>> {/// Cmd::shell("npm run build")/// .current_dir(&repo_path)/// .stdout(Stdio::from(std::io::stderr()))/// .forward_signals()/// .stream()?;+/// # Ok(())+/// # }/// ```pub struct Cmd {/// Program name or shell command string (if shell_wrap is true)