Skip to content

Commit db10ef7

Browse files
docs: enable building rust API docs
1 parent 3460d98 commit db10ef7

4 files changed

Lines changed: 51 additions & 7 deletions

File tree

.github/ISSUE_TEMPLATE/release.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ git push upstream v0.6.0
5151
```
5252
14. - [ ] Trigger manual releases for both libraries (for Swift, go to the [bdk-swift](https://github.com/bitcoindevkit/bdk-swift) repository and trigger the workflow using `master`. Simply add the version number and tag name in the text fields when running the workflow manually. Note that the version number must not contain the `v`, i.e. `0.26.0`, but the tag will have it, i.e. `v0.26.0`). For Android, trigger the release workflow using the tag (not a branch).
5353
15. - [ ] Make sure the released libraries work and contain the artifacts you would expect.
54-
16. - [ ] Aggregate all the changelog notices from the PRs and add them to the changelog file. PR that.
55-
17. - [ ] Bump the version on master from `1.1.0-SNAPSHOT` to `1.2.0-SNAPSHOT` (Android) and `1.1.0-alpha.0` to `1.2.0-alpha.0` (Rust).
56-
18. - [ ] Apply changes to the release issue template if needed.
57-
19. - [ ] Make release on GitHub (generate auto release notes between the previous tag and the new one).
58-
20. - [ ] Build API docs for Android locally and PR the website to the bitcoindevkit.org repo.
59-
21. - [ ] Post in the announcement channel.
60-
22. - [ ] Tweet about the new release!
54+
16. - [ ] Build the Rust API docs and publish them to the repo's GitHub Pages.
55+
```shell
56+
cd bdk-ffi/
57+
just docs
58+
```
59+
17. - [ ] Aggregate all the changelog notices from the PRs and add them to the changelog file. PR that.
60+
18. - [ ] Bump the version on master from `1.1.0-SNAPSHOT` to `1.2.0-SNAPSHOT` (Android) and `1.1.0-alpha.0` to `1.2.0-alpha.0` (Rust).
61+
19. - [ ] Apply changes to the release issue template if needed.
62+
20. - [ ] Make release on GitHub (generate auto release notes between the previous tag and the new one).
63+
21. - [ ] Build API docs for Android locally and PR the website to the bitcoindevkit.org repo.
64+
22. - [ ] Post in the announcement channel.
65+
23. - [ ] Tweet about the new release!

bdk-ffi/justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ check:
1313

1414
test:
1515
cargo test
16+
17+
# Build API documentation for gh-pages or local browsing
18+
docs:
19+
bash scripts/build-docs.sh && bash scripts/deploy-docs.sh

bdk-ffi/scripts/build-docs.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Rustdoc only emits module pages for publicly reachable modules. For the docs to
6+
# build correctly, we temporarily rewrite the top-level `mod foo;` lines into `pub mod foo;`.
7+
sed -i '' -E 's/^mod (bitcoin|descriptor|electrum|error|esplora|keys|kyoto|macros|store|tx_builder|types|wallet);$/pub mod \1;/' src/lib.rs
8+
9+
# We always restore the original `src/lib.rs` on exit so the temporary visibility
10+
# change never sticks around after the docs build finishes.
11+
cleanup() {
12+
sed -i '' -E 's/^pub mod (bitcoin|descriptor|electrum|error|esplora|keys|kyoto|macros|store|tx_builder|types|wallet);$/mod \1;/' src/lib.rs
13+
}
14+
trap cleanup EXIT
15+
16+
# Build the docs
17+
rm -rf target/doc
18+
cargo doc --no-deps
19+
printf '%s\n' '<meta http-equiv="refresh" content="0; url=bdkffi/index.html">' > target/doc/index.html
20+
printf 'Documentation built at target/doc/\n'

bdk-ffi/scripts/deploy-docs.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# Build the docs site and publish it to the gh-pages branch, which GitHub Pages
4+
# serves at https://bitcoindevkit.github.io/bdk-ffi/.
5+
6+
set -euo pipefail
7+
8+
cd ./target/doc/
9+
git init .
10+
git switch --create gh-pages
11+
git add .
12+
git commit --message "Deploy $(date +"%Y-%m-%d")"
13+
git remote add upstream git@github.com:bitcoindevkit/bdk-ffi.git
14+
git push upstream gh-pages --force
15+
cd ..

0 commit comments

Comments
 (0)