Skip to content

docs(shepherd-sdk): add 6 doctests covering Host trait + helper API (COW-1067)#29

Open
brunota20 wants to merge 1 commit into
feat/ci-rustdoc-gate-cow-1069from
feat/sdk-doctests-cow-1067
Open

docs(shepherd-sdk): add 6 doctests covering Host trait + helper API (COW-1067)#29
brunota20 wants to merge 1 commit into
feat/ci-rustdoc-gate-cow-1069from
feat/sdk-doctests-cow-1067

Conversation

@brunota20

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds 6 runnable doctests to `crates/shepherd-sdk/` covering the load-bearing public surface. shepherd-sdk had 27 public items and 0 doctests; renames or signature changes broke silently.

Why

Surfaced by the COW-1063 QA pass. BLEU-844 (COW-1045) promised "rustdoc polish + landing" but did not require runnable examples. Without doctests:

  • Renaming `ChainHost::request` does not break anything until a downstream module fails to compile.
  • Signature changes on `eth_call_params` / `parse_eth_call_result` are silently allowed.
  • The Host trait usage pattern is documented in the tutorial but never compile-checked.

Changes

Doctests added:

Item Demonstrates
`chain::eth_call_params` encodes JSON-RPC params with proper hex shape
`chain::parse_eth_call_result` round-trips a JSON-quoted hex blob; rejects malformed input
`chain::decode_revert_hex` OrderNotValid revert -> `PollOutcome::DontTryAgain`
`cow::classify_api_error` InsufficientFee -> TryNextBlock; InvalidSignature -> Drop; None -> TryNextBlock default
`cow::gpv2_to_order_data` zero-receiver normalisation
`host::Host` strategy fn generic over `&impl Host` + hidden hand-rolled stub so the doctest is self-contained (avoids shepherd-sdk-test dev-dep cycle)

`#![warn(missing_docs)]` already lives on the crate root; the COW-1069 CI gate enforces the rustdoc warning surface.

Breaking changes

None. Doc-only additions.

Testing

  • `cargo test --doc -p shepherd-sdk` -> 6 passed.
  • `cargo test --workspace` -> 145 host tests + 7 doctests passing.
  • `cargo clippy --all-targets --workspace -- -D warnings` clean.
  • `cargo fmt --all --check` clean.
  • 0 em-dashes in new examples.

AI assistance disclosure

AI Assistance: this change + description was produced by a Claude Code agent (Claude Opus 4.7 1M context). A human (Bruno) reviewed and is accountable for the result.

Linear: COW-1067. Stacks on #28 (COW-1069 rustdoc gate) -> #27 (COW-1066 CI matrix) -> #26 (COW-1063 QA cleanup).

…COW-1067)

shepherd-sdk had 27 public items and 0 doctests, so renames or
signature changes on the SDK surface broke silently. Adds runnable
usage examples on the load-bearing public items.

Doctests landed:

  chain::eth_call_params         (encode JSON-RPC params)
  chain::parse_eth_call_result   (decode hex result)
  chain::decode_revert_hex       (OrderNotValid -> DontTryAgain)
  cow::classify_api_error        (InsufficientFee -> TryNextBlock;
                                  InvalidSignature -> Drop;
                                  None -> TryNextBlock default)
  cow::gpv2_to_order_data        (zero-receiver normalised to None)
  host::Host                     (strategy fn generic over &impl Host;
                                  hidden hand-rolled stub impl in the
                                  example so the doctest is self-
                                  contained and avoids the
                                  shepherd-sdk-test dev-dep cycle)

`#![warn(missing_docs)]` already on the crate root; the new gate from
COW-1069 (PR #28) enforces the rustdoc warning surface in CI.

Verified locally:

  cargo test --doc -p shepherd-sdk            -> 6 passed
  cargo test --workspace                       -> 145 host tests + 7
                                                  doctests passing
  cargo clippy --all-targets --workspace      -> clean
  cargo fmt --all --check                      -> clean
  grep -rn '—' crates/shepherd-sdk/src/        -> 0

Linear: COW-1067. Stacks on COW-1066 + COW-1069.
@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

COW-1067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant