Skip to main content

read_doc

Function read_doc 

Source
pub fn read_doc(
    repo_root: &Path,
    gov: &GovernanceConfig,
    rel_path: &str,
) -> Result<Option<String>, PawError>
Expand description

Reads one document confined to the configured documentation directory.

The requested rel_path is resolved under the configured documentation directory, then canonicalised and checked to still lie within that directory. Any path that escapes the directory (.., an absolute path, a symlink target outside the tree) is refused with Ok(None) — no file outside the directory is ever read.

  • [governance].docs unset → Ok(None).
  • requested document absent → Ok(None).
  • traversal/escape → Ok(None) (refused; the tool layer attaches a message).
  • confined + readable → Ok(Some(content)).
  • confined + present-but-unreadable → Err.