Repository navigation
docs: document every public contract function - #68
Merged
codemagician1949 merged 4 commits intoAug 25, 2026
Merged
codemagician1949 merged 4 commits into
codemagician1949 merged 4 commits into
Conversation
Adds `///` documentation to the public items that were missing it across all four crates - 47 of the 182 public items - and makes cargo doc warning-free, which it was not before this change. Every added comment states what the function returns, what its arguments mean where it takes any, and whether it can fail. For the view helpers that make up most of the gap, the part worth writing down is what the zero value means, because in almost every case it is ambiguous: - buyer_limit_bps, sme_limit_bps, min_deposit, max_deposit and reserve_ratio_bps return 0 when create_pool has not run. That is "unconfigured", not "a limit of zero", and a caller that reads it as the latter draws exactly the wrong conclusion. - withdraw_util_threshold defaults to BPS_SCALE rather than 0, because the permissive default is the one where utilisation never blocks a withdrawal. - nav defaults to NAV_SCALE, ie parity, not zero. - is_upgrade_paused being true does not mean nothing is pending; queueing and cancelling still work while paused and only the Wasm swap is held back. - invoice_due_at returning None means the grace-period clock has never started, so the invoice cannot be defaulted at all. cargo doc was emitting 10 unresolved-link warnings before this change, all of them [`Self::foo`] references inside #[contractimpl] blocks. The macro expands each function into its own __foo module, so Self does not resolve to the contract type from inside the generated docs and every such link silently breaks. Rewriting them as fully-qualified paths (PoolManager::foo, InvoiceRegistry::foo, and so on) resolves them against the contract struct, so the links now work rather than being dropped. New doc comments use the same form for the same reason. Public struct fields on WaterfallTier, WaterfallResult and QueuedUpgrade are documented too, and QueuedUpgrade's `//` header became `///` so it actually reaches the docs. No behaviour changes: comments, plus one doc comment split so that two storage constants each carry their own rather than sharing one. Closes IntensifierLab#3
Contributor
|
@definurse13 please fix failing ci |
The WASM size job was failing with pool_manager.wasm at 68,161 bytes against the 65,536-byte ceiling. The cause is not obvious from the diff, so worth stating: Soroban's #[contractimpl] embeds `///` doc comments into the contract spec that ships inside the .wasm. Documentation added to entrypoints is therefore paid for in on-chain artifact size. Confirmed directly - the added text is greppable in the built binary. That alone did not create the problem. There was no [profile.release] in the workspace at all, so contracts were built with the default release profile: optimised for speed, symbols retained. On pristine main pool_manager was 65,502 bytes, i.e. 34 bytes under the limit. Any change to that crate, documentation or code, would have broken the size check. Adding the standard Soroban contract profile fixes it with room to spare: governance 30,005 -> 27,074 invoice_registry 53,565 -> 47,563 pool_manager 65,502 -> 61,041 (was 68,161 on this branch) repayment_waterfall 45,385 -> 41,145 pool_manager now has ~4.5KB of headroom rather than 34 bytes, and that is with this branch's documentation included. overflow-checks stays on deliberately: silent wrapping in financial arithmetic is worth more than the bytes it costs. Two further fixes for regressions that arrived with main and would fail this PR's own acceptance criteria: - cargo fmt --all --check was failing on tests/create_invoice.rs and tests/events.rs. Neither is touched by this PR; both arrived in recent merges and main's own CI is currently red for this reason. Applied cargo fmt to them. - Two new [`Self::foo`] doc links in invoice-registry reintroduced the unresolved-link warnings this PR exists to remove. Rewritten as qualified paths like the rest, so cargo doc is warning-free again.
The Formatting and Clippy job was still failing, now on Clippy rather than rustfmt: tests/events.rs imports Symbol without using it, and the repo runs clippy --all-targets -D warnings. The error is not new. That job previously exited at the formatting step, so Clippy never ran on this file; fixing the formatting in the previous commit let the job get far enough to reach it. Neither the import nor the file belongs to this PR - both arrived with recent merges to main - but the job cannot go green while it is there. Verified with the exact CI invocations this time rather than a filtered subset: cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace --no-fail-fast, cargo doc (0 warnings), and the release wasm build with per-crate sizes checked against the 64KB ceiling.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3
Adds
///documentation to the public items that were missing it across all four crates — 47 of the 182 public items — and makescargo docwarning-free, which it was not before this change.Every added comment states what the function returns, what its arguments mean where it takes any, and whether it can fail.
The part worth reviewing: what zero means
Most of the gap was view helpers, and for nearly all of them the ambiguous case is the zero value. Documenting "returns the buyer limit" would have been useless; documenting what
0means is the thing a caller actually needs:buyer_limit_bps,sme_limit_bps,min_deposit,max_deposit,reserve_ratio_bpsreturn0whencreate_poolhas not run. That is unconfigured, not a limit of zero — a caller reading it as the latter draws exactly the wrong conclusion.withdraw_util_thresholddefaults toBPS_SCALE, not0, because the permissive default is the one where utilisation never blocks a withdrawal.navdefaults toNAV_SCALE— parity — not zero.is_upgrade_pausedreturningtruedoes not mean nothing is pending: queueing and cancelling still work while paused, and only the Wasm swap is held back.invoice_due_atreturningNonemeans the grace-period clock has never started, so the invoice cannot be defaulted at all — a materially different state from "due, but not yet".Fixing
cargo doc(acceptance criterion 3)cargo docwas emitting 10 unresolved-link warnings before this change, so the criterion could not be met just by adding comments.All ten were
[`Self::foo`]references inside#[contractimpl]blocks. The macro expands each function into its own__foomodule, soSelfdoes not resolve to the contract type from inside the generated docs, and every such link silently breaks — they render as plain text rather than links, which is why this went unnoticed.Rewriting them as fully-qualified paths (
PoolManager::foo,InvoiceRegistry::foo, and so on) resolves them against the contract struct, so the links now actually work rather than being dropped. New doc comments use the same form for the same reason.cargo doc --workspace --no-depsis now clean: 0 warnings.Also
Public struct fields on
WaterfallTier,WaterfallResultandQueuedUpgradeare documented, andQueuedUpgrade's header was//rather than///— so it never reached the docs at all. That is now fixed.Acceptance criteria
cargo docwarning-free (was 10 warnings, now 0)No behaviour change
Comments only, plus one doc comment split so two storage constants each carry their own rather than sharing one. No signature, no logic, no manifest touched.
Verification
cargo check --workspace,cargo test --workspace,cargo doc --workspace --no-deps(0 warnings), andcargo build --release --target wasm32-unknown-unknown --workspaceall pass.This PR and #7 are conflict-free in either merge order. They touch disjoint file sets by construction — this one only
.rsfiles, #7 onlyCargo.tomlfiles. I merged them both ways locally againstmainto confirm rather than assume: zero conflicts each way, both orders produce an identical tree, and the merged result passes the full gate. Whichever you merge first, the other needs no rebase.