Skip to content

Commit 2b111cf

Browse files
committed
update guides
1 parent 94912dc commit 2b111cf

File tree

6 files changed

+69
-18
lines changed

6 files changed

+69
-18
lines changed

Guides/docs.docc/GeneratingCertificates.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Generating TLS certificates
22

3-
To simplify the implementation and facilitate testing, Unidoc uses TLS (HTTPS) everywhere, even when running locally.
4-
53
For a seamless development experience, we recommend using [mkcert](https://github.com/FiloSottile/mkcert) to generate a local certificate authority (CA) for your development environment.
64

5+
> Note:
6+
> Most Unidoc users do not need to generate their own certificates. As of Unidoc 0.17.0, the preview server can run locally in insecure mode.
7+
8+
79
## Installing mkcert
810

911
### Linux

Guides/docs.docc/Quickstart.md

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,57 @@ This guide walks through how to use the `unidoc preview` tool to preview documen
55
In this guide, you will:
66

77
1. Launch and initialize a `mongod` instance in a Docker container,
8-
2. Build and run an instance of `unidoc preview` on the macOS host,
9-
3. Build the `unidoc local` tool,
8+
2. Build or install Unidoc on the macOS host,
9+
3. Run an instance of `unidoc preview` on the macOS host,
1010
4. Generate documentation for the standard library, and
1111
5. Generate documentation for two SwiftPM packages, one of which depends on the other.
1212

13-
Before you begin, clone the Unidoc repository and navigate to the root of the repository:
14-
15-
```bash
16-
git clone https://github.com/tayloraswift/swift-unidoc
17-
cd swift-unidoc
18-
```
1913

2014
## 1. Install Docker
2115

2216
The easiest way by far to preview documentation locally is to use Docker. You can download Docker Desktop for macOS from the [official website](https://www.docker.com/products/docker-desktop).
2317

2418

25-
## 2. Launching a `mongod` instance
19+
## 2. Install Unidoc
20+
21+
Today, there are two main ways to install Unidoc — building it from source or downloading a pre-built binary.
22+
23+
### Downloading a pre-built binary
24+
25+
Pre-built binaries are available for a limited set of platforms.
26+
27+
| Platform | Download |
28+
|----------|----------|
29+
| macOS | [`macOS-ARM64/unidoc.gz`](https://static.swiftinit.org/unidoc/0.19.0/macOS-ARM64/unidoc.gz) |
30+
| Linux | [`Linux-X64/unidoc.gz`](https://static.swiftinit.org/unidoc/0.19.0/Linux-X64/unidoc.gz) |
31+
32+
33+
You can download and install the binary in your home directory like this:
34+
35+
@Code(file: unidoc-install.sh, title: unidoc-install.sh)
36+
37+
38+
### Building Unidoc from source
39+
40+
Unidoc is an ordinary SwiftPM executable product. You can build it for your macOS host like this:
41+
42+
@Code(file: unidoc-from-source.sh, title: unidoc-from-source.sh)
43+
44+
Please note that the executable as built by SwiftPM is named `unidoc-tools`, which you should rename to `unidoc` when installing it.
45+
46+
47+
> Important:
48+
> The rest of this guide assumes you have installed Unidoc somewhere on your macOS host that is visible in your `PATH` and allows you to invoke it as `unidoc`.
49+
50+
51+
## 3. Launching a `mongod` instance
52+
53+
If you have not already done so, clone the Unidoc project and navigate to the root of the repository:
54+
55+
```bash
56+
git clone https://github.com/tayloraswift/swift-unidoc
57+
cd swift-unidoc
58+
```
2659

2760
Use Docker Compose to launch a `mongod` instance in a container. This container is named `unidoc-mongod-container`. It has persistent state which `mongod` stores in a directory called `.mongod` at the root of the repository.
2861

@@ -46,10 +79,10 @@ docker exec -t unidoc-mongod-container /bin/mongosh --file /unidoc-rs-init.js
4679

4780
## 3. Running `unidoc preview`
4881

49-
The `unidoc preview` tool is an ordinary SwiftPM executable product. You can build and run it directly from your macOS host like this:
82+
The `unidoc preview` tool is a simple web server that links and serves documentation for local Swift packages. Run it directly from your macOS host like this:
5083

5184
```bash
52-
swift run -c release unidoc-tools preview
85+
unidoc preview
5386
```
5487

5588
The `unidoc preview` tool will start a web server on [`http://localhost:8080`](http://localhost:8080).
@@ -62,7 +95,9 @@ The `unidoc preview` tool will start a web server on [`http://localhost:8080`](h
6295

6396
Generate local documentation using the `unidoc local` subcommand. To start off, open a third terminal and generate the documentation for the standard library (`swift`).
6497

65-
@Code(file: load-standard-library.sh, title: load-standard-library.sh)
98+
```bash
99+
unidoc local swift
100+
```
66101

67102
You should be able to view the symbol graph and its documentation at [`http://localhost:8080/tags/swift`](http://localhost:8080/tags/swift).
68103

@@ -84,7 +119,7 @@ cd -
84119
Generating documentation for a package is similar to generating documentation for the standard library, except you need to specify a search path to a directory containing the project. Because you downloaded the `swift-collections` repository to a sibling directory, you can use `..` for the search path.
85120

86121
```bash
87-
swift run -c release unidoc-tools local swift-collections -I ..
122+
unidoc local swift-collections -I ..
88123
```
89124

90125
You should be able to view the symbol graph and its documentation at [`http://localhost:8080/tags/swift-collections`](http://localhost:8080/tags/swift-collections).
@@ -99,7 +134,7 @@ Finally, let’s generate documentation for a package that depends on `swift-col
99134
cd ..
100135
git clone https://github.com/apple/swift-async-algorithms
101136
cd -
102-
swift run -c release unidoc-tools local swift-async-algorithms -I ..
137+
unidoc local swift-async-algorithms -I ..
103138
```
104139

105140

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
swift run -c release unidoc-tools build local swift
1+
swift run -c release unidoc-tools local swift
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
swift run -c release unidoc-tools build local swift-nio -I /swift
1+
swift run -c release unidoc-tools local swift-nio -I /swift
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mkdir -p ~/unidoc/bin
2+
git clone https://github.com/tayloraswift/swift-unidoc
3+
cd swift-unidoc
4+
swift build -c release --product unidoc-tools
5+
mv .build/release/unidoc-tools ~/unidoc/bin/unidoc
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
UNIDOC_MIRROR=https://static.swiftinit.org/unidoc
2+
UNIDOC_VERSION=0.19.0
3+
UNIDOC_PLATFORM=macOS-ARM64
4+
5+
mkdir -p ~/unidoc/bin
6+
curl -L $UNIDOC_MIRROR/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc.gz \
7+
-o ~/unidoc/bin/unidoc.gz
8+
gzip -fdk ~/unidoc/bin/unidoc.gz
9+
chmod +x ~/unidoc/bin/unidoc

0 commit comments

Comments
 (0)