Skip to content

Commit 56a17fb

Browse files
committed
Two new posts.
Docs now point to the docs/ folder which is git ignored. static/docc folder contents removed
1 parent e137156 commit 56a17fb

File tree

5,113 files changed

+86
-78860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,113 files changed

+86
-78860
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
xcuserdata/
44
/.build
55
/www
6+
/static/docs/

src/content/post/posts2024.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In additions to these libraries, the package delivers two command-line tools:
2020
2121
# Improved API examples
2222
23-
As an example of the simplicity of the new APIs here's some code snippets taken from the revamped [documentation](https://swift-bitcoin.github.io/docc/documentation/bitcoin/):
23+
As an example of the simplicity of the new APIs here's some code snippets taken from the revamped [documentation](https://swift-bitcoin.github.io/docs/documentation/bitcoin/):
2424
2525
## Running a simple script
2626

src/content/post/posts2025.swift

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,85 @@
1+
let post08 = Post("/post/2025-01-28-improved-docs-generation", "Improved Docs Generation", "2025-01-28T12:00:00Z", .housekeeping) { """
2+
3+
The [/docs](https://swift-bitcoin.github.io/docs) subfolder on this site is now generated independently from the [main repo](https://github.com/swift-bitcoin/swift-bitcoin) which means more frequent updates and accuracy in regards to the actual source code.
4+
5+
Since the site is generated with Swift using [SwiftySites](https://github.com/swiftysites/swiftysites) it made sense to build the site and the DocC documentation in one go. But this requires the entire documentation site to be placed inside the _static_ folder of the statically generated site which is checked under version control.
6+
7+
With the new architecture the DocC script is run independently and its results deployed straight to the _docs_ subfolder leaving the rest of the site unaffected. Similarly when a new blog post is published the documentation stays intact.
8+
9+
The entire automation is orchestrated with GitHub Actions and GitHub Pages. To achieve the subfolder behavior the main site is hosted directly under the GitHub organization while the [Docs](https://github.com/swift-bitcoin/docs/actions/workflows/docs.yml) repository does the heavy lifting of producing the documentation site and deploying it to its own GitHub Page which is automatically linked to the subfolder.
10+
11+
It is not possible for an action running out of the Swift Bitcoin repository to deploy to a different Pages URL. So the trick here is to use a dedicated docs repo and within the workflow checkout a different repository – in this case `swift-bitcoin`.
12+
13+
```yaml
14+
15+
# Build documentation job
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
repository: swift-bitcoin/swift-bitcoin
23+
24+
25+
# Deployment job
26+
deploy:
27+
environment:
28+
name: github-pages
29+
url: ${{ steps.deployment.outputs.page_url }}
30+
runs-on: ubuntu-latest
31+
needs: build
32+
steps:
33+
- name: Deploy to GitHub Pages
34+
id: deployment
35+
uses: actions/deploy-pages@v4
36+
```
37+
38+
For more details check out the workflow's [source](https://github.com/swift-bitcoin/docs/blob/release/.github/workflows/docs.yml). Swift Bitcoin's website and docs is completely open source.
39+
40+
Hopefully this change will lead to better quality documentation.
41+
""" }
42+
43+
let post07 = Post("/post/2025-01-27-new-binarycodable-framework", "New BinaryCodable Framework", "2025-01-27T12:00:00Z", .implementation) { """
44+
45+
The new [BinaryCodable](/docs/crypto/documentation/bitcoincrypto/binarycodable) framework adds simplicity, performance and stability to the way Bitcoin types are parsed and serialized from binary streams.
46+
47+
The idea of a `BinaryCodable` protocol is inspired by Swift's own `Codable` protocol. While it is possible to encode/decode binary formats using Apple's framework, the requirement to define keys for all fields hints at a different use case.
48+
49+
To make a type binary decodable just define an initializer:
50+
51+
```swift
52+
init(from decoder: inout BinaryDecoder) throws(BinaryDecodingError)
53+
```
54+
55+
Use `BinaryDecoder` to decode each field, like in the case of a non-witness Bitcoin transaction:
56+
57+
```swift
58+
version = try decoder.decode()
59+
ins = try decoder.decode()
60+
outs = try decoder.decode()
61+
locktime = try decoder.decode()
62+
```
63+
64+
To encode simply implement the `encode(to:)` method and use the provided `BinaryEncoder` instance to encode each value.
65+
66+
```swift
67+
public func encode(to encoder: inout BinaryEncoder) {
68+
encoder.encode(version)
69+
encoder.encode(ins)
70+
encoder.encode(outs)
71+
encoder.encode(locktime)
72+
}
73+
```
74+
75+
Notice how because `TxIn` and `TxOut` are themselves binary codable, a collection of inputs and outputs can be trivially handled by the encoder and decoder. The framework is tailored for Bitcoin development so the variable integer prefix is handled automatically.
76+
77+
This will greatly improve all serialization logic across the Swift Bitcoin codebase both in readability as well as speed.
78+
79+
The Binary Codable API is public so you can also use it independently by simply importing `BitcoinCrypto`.
80+
81+
""" }
82+
183
let post06 = Post("/post/2025-01-16-testing-transport-layer", "Testing the Transport Layer", "2025-01-16T12:00:00Z", .testing) { """
284
385
Creating meaningful unit tests can be difficult – even more when the system under test is a transport layer protocol like the [Bitcoin wire protocol](https://en.bitcoin.it/wiki/Protocol_documentation).

src/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import SwiftySites
22

33
let posts = [
4-
post01, post02, post03, post04, post05, post06
4+
post01, post02, post03, post04, post05, post06, post07, post08
55
]
66

77
let site = Site(

src/partials/navigationPartial.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func navigationPartial(_ page: Page?) -> String { """
1616
"""
1717
})
1818
<li>
19-
<a href="/docc/documentation/bitcoin/">Docs</a>
19+
<a href="/docs/documentation/bitcoin/">Docs</a>
2020
</li>
2121
\(/* External link */"")<li>
2222
<a href="https://github.com/swift-bitcoin/swift-bitcoin">Code</a>

static/docc/base/css/866.60f074fd.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

static/docc/base/css/989.4f123103.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

static/docc/base/css/documentation-topic.99224ad2.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

static/docc/base/css/index.3a335429.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

static/docc/base/css/topic.4be8f56d.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)