Skip to content

docs: inject dartdoc comments into generated public API#114

Open
ANAMASGARD wants to merge 1 commit into
bitcoindevkit:mainfrom
ANAMASGARD:docs/inject-dartdoc-comments
Open

docs: inject dartdoc comments into generated public API#114
ANAMASGARD wants to merge 1 commit into
bitcoindevkit:mainfrom
ANAMASGARD:docs/inject-dartdoc-comments

Conversation

@ANAMASGARD

Copy link
Copy Markdown

Summary

Fixes #75 by adding dartdoc comments to the generated public API in lib/bdk.dart via a validated post-generation injection step (Option B).

lib/bdk.dart is produced by uniffi-bindgen and must not be edited by hand. This PR introduces a small Dart injector that reads doc content from scripts/dartdoc/entries.yaml, matches exact declaration anchors in the generated file, and inserts /// comments after every bindings regeneration.

Documented in this PR:

  • Core classes: Wallet, Descriptor, Mnemonic, ElectrumClient, EsploraClient, Transaction, Psbt
  • Key methods: wallet lifecycle (create / load / persist / dispose), sync (startSyncWithRevealedSpks, applyUpdate), Electrum/Esplora client setup and sync/broadcast, PSBT build/extract flow
  • All 30 public exception base types (subclasses deferred for follow-up)

Safety guarantees:

  • Exact full-line anchors (not loose regex on class names)
  • scope_after for ambiguous symbols like dispose()
  • Fails loudly when an anchor is missing or duplicated
  • Idempotent re-runs skip anchors that already have docs
  • --check mode used in CI to catch drift after bdk-ffi upgrades

Approach

Upstream doc passthrough in uniffi-dart is still open (uniffi-dart#59), so this keeps documentation in-repo and re-applies it automatically from scripts/generate_bindings.sh.

To change docs, edit scripts/dartdoc/entries.yaml and re-run bash ./scripts/generate_bindings.sh — not lib/bdk.dart directly.

Files changed

File Purpose
scripts/dartdoc/entries.yaml Doc content map keyed by exact anchors
scripts/inject_dartdocs.dart Injector with validation and --check
scripts/generate_bindings.sh Runs injector after uniffi-bindgen
lib/bdk.dart Regenerated bindings with injected docs
test/dartdoc_injection_test.dart Verifies anchors and --check pass
justfile Adds just verify-docs
.github/workflows/ci.yml Verifies docs after binding generation
CONTRIBUTING.md Documents the injection workflow

Test plan

  • dart scripts/inject_dartdocs.dart --check
  • just verify-docs
  • dart test test/dartdoc_injection_test.dart
  • just analyze
  • just test
  • just docs — confirm doc/api/ pages for Wallet, Descriptor, Mnemonic are populated

Notes

  • Exception subclasses (~100+) are intentionally out of scope for v1; base types document the failure families.
  • Happy to coordinate with @as1ndu on follow-up doc wording or additional method coverage.

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.

docs: add dartdoc comments to core public API classes

1 participant