Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve snippets #25

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
/.DS_Store
/.swiftpm
/.vscode
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ check:

format:
./scripts/run-swift-format.sh --fix

unidoc:
unidoc compile -I .. \
--ci fail-on-errors \
--package-name articles \
--define DARWIN

unidoc-local:
unidoc local -i .

14 changes: 7 additions & 7 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "39ee378a5452b7ecbf42ffb8e850cc3bb68bdddb2394e39ac26615ba789f3c5c",
"originHash" : "1e7038e38f57c124171d09107eef07a450c94d04865a9ad003a9d06b87a76bff",
"pins" : [
{
"identity" : "async-http-client",
Expand Down Expand Up @@ -42,26 +42,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift.git",
"state" : {
"revision" : "432c955d9781bfb4c20c813de042bc098d2277cf",
"version" : "2.0.0-alpha.1"
"revision" : "0696e0adf7e081ba7a757a4c87242a1aab524078",
"version" : "2.0.0-beta.2"
}
},
{
"identity" : "grpc-swift-nio-transport",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift-nio-transport",
"state" : {
"revision" : "0d1c61a501683a2acf5810b1ce1230e993c87b3f",
"version" : "1.0.0-alpha.1"
"revision" : "e97f97e399f62dbedadfa4e55e962577c313907d",
"version" : "1.0.0-beta.2"
}
},
{
"identity" : "grpc-swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/grpc/grpc-swift-protobuf",
"state" : {
"revision" : "424a4d8bd6f0c97500517b827a9d0e2c6a1df924",
"version" : "1.0.0-alpha.1"
"revision" : "3ed26dad8d43d7a11f0c6784a93db900e3cd4281",
"version" : "1.0.0-beta.2"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import PackageDescription

let package = Package(
name: "swiftonserver-articles",
name: "articles",
platforms: [
.macOS(.v15),
],
Expand All @@ -13,7 +13,7 @@ let package = Package(
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird-auth.git", from: "2.0.2"),
.package(url: "https://github.com/hummingbird-project/hummingbird-websocket.git", from: "2.0.0"),
.package(url: "https://github.com/hummingbird-project/swift-mustache.git", from: "2.0.0-beta.3"),
.package(url: "https://github.com/hummingbird-project/swift-mustache.git", from: "2.0.0"),
.package(url: "https://github.com/hummingbird-project/swift-jobs.git", from: "1.0.0-beta.6"),
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.21.1"),
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.5.0"),
Expand All @@ -22,8 +22,8 @@ let package = Package(
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.0.0"),
.package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.5.0"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf", exact: "1.0.0-alpha.1"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport", exact: "1.0.0-alpha.1"),
.package(url: "https://github.com/grpc/grpc-swift-protobuf.git", exact: "1.0.0-beta.2"),
.package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", exact: "1.0.0-beta.2"),
.package(url: "https://github.com/orlandos-nl/MongoKitten.git", from: "7.0.0"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "5.0.0"),
],
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ If a tutorial uses multiple snippets, you can create a folder with your tutorial
DocC uses the following format to locate a snippet:

```
@Snippet(path: "site/Snippets/hummingbird-2")
@Snippet(
path: "articles/Snippets/2025/introduction-to-jwts-in-swift/jwt-kit"
)
```

- `site/` is mandatory, and refers to the current Swift package by package name.
- `Snippets/` is the folder where we store our snippets
- Optionally, and subfolders of `Snippets/` can be added in between
- `hummingbird-2` refers to the snippet file. Do not put a `.swift` extensionh ere.
- `articles` is mandatory, and refers to the current Swift package by package name.
- The next part is the location where we store our snippet. It is mandatory to start the location with `Snippets`.
- `jwt-kit` refers to the actual snippet file. Do not use the `.swift` extension here.

If you _don't_ want to render certain example code in the tutorial, you can mark the start of hidden lines of code as such:

Expand Down Expand Up @@ -88,7 +89,9 @@ And you can end that labeled block as such:
You can refer to a labeled block (called a "slice") in your tutorial's code:

```
@Snippet(path: "site/Snippets/building-swiftnio-clients-01", slice: "imports")
@Snippet(
path: "articles/Snippets/2025/introduction-to-jwts-in-swift/jwt-kit", slice: "key_collection_add_hmac"
)
```

### Planning an Article (recommended)
Expand Down
File renamed without changes.
File renamed without changes.
Loading
Loading