Skip to content

Commit 1c6200f

Browse files
committed
update guides
1 parent 6c47275 commit 1c6200f

File tree

5 files changed

+41
-32
lines changed

5 files changed

+41
-32
lines changed

Guides/docs.docc/Getting started.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,23 @@ You need to have [Docker](https://www.docker.com/) installed on your development
1111
It is theoretically possible to run Unidoc without Docker, but Docker makes it much easier to do so, because you will not need to (directly) manage a local [MongoDB](https://mongodb.com) deployment.
1212

1313

14-
## Setting up a local database
14+
## Installing Unidoc
15+
16+
The examples in this tutorial assume you are building Unidoc from source. However, you can also download [pre-built binaries](/Quickstart) for a select set of platforms.
17+
18+
19+
## Setting up a local database automatically
20+
21+
Unidoc can set up a `mongod` instance for you automatically through the `unidoc init` command. This tool takes a directory path as an argument, which it uses to persist the state of the database. In the example below, we will create the documentation database in a directory named `unidoc` in your home directory.
22+
23+
@Code(file: init-server.sh, title: init-server.sh)
24+
25+
26+
## Setting up a local database manually
27+
28+
> Note:
29+
> The steps in this section are provided for educational purposes, to help you understand how Unidoc works. If you have set up the database automatically, you can skip this section.
30+
1531

1632
A Unidoc server is a server that talks to a second server, a MongoDB server. Therefore, before you can start a Unidoc server, you need to set up and launch a local [MongoDB](https://github.com/tayloraswift/swift-mongodb) deployment.
1733

@@ -49,7 +65,7 @@ This file:
4965
The `unidoc-test` network is helpful for testing, but for the purposes of this tutorial, you will mostly be accessing the `mongod` process through `localhost:27017`.
5066

5167

52-
## Initializing the database
68+
### Initializing the database
5369

5470
The mongod instance will create a `.mongod` directory at the root of the cloned repository. This directory contains the state of the deployment, and like all database deployments, it can outlive the mongod process. This means you can kill (or crash) the mongod instance but it will not lose data unless you clear or delete its data directory.
5571

@@ -62,24 +78,13 @@ docker exec -t unidoc-mongod-container /bin/mongosh --file /unidoc-rs-init.js
6278
This only needs to be done **once** per deployment lifecycle. (For example, after clearing the `.mongod` data directory.)
6379

6480

65-
### Connecting to the database
81+
## Connecting to the database
6682

67-
Once you have a `unidoc-mongod-container` running in the background, you can start a documentation server. There are many ways to run a documentation server, but if you are developing in a Docker container, the easiest way is compile Unidoc and run the server as a normal process.
83+
Once you have a `unidoc-mongod-container` running in the background, you can start a documentation server by running `unidoc preview`.
6884

6985
@Code(file: start-server.sh, title: start-server.sh)
7086

7187

72-
### Generating certificates
73-
74-
#### Unidoc < 0.17.0
75-
76-
If you are starting the server for the first time, you likely need to populate the `Assets/certificates/` directory with TLS certificates. See <doc:GeneratingCertificates> for instructions on how to do this.
77-
78-
#### Unidoc ≥ 0.17.0
79-
80-
You do not need to generate certificates, as Unidoc 0.17.0 can run locally in insecure mode.
81-
82-
8388
## Populating a local documentation server
8489

8590
If you did all of the previous steps correctly, you should be able to navigate to [`localhost:8080/`](http://localhost:8080/) and view a blank homepage.
@@ -111,26 +116,24 @@ Uploading symbol graph...
111116
Successfully uploaded symbol graph!
112117
```
113118

114-
Because you built these docs “abnormally” (meaning: not from a GitHub repository), they won’t show up in the homepage, but you can view them by navigating directly to [`localhost:8080/docs/swift`](http://localhost:8080/docs/swift).
119+
You can view the docs by navigating to [`localhost:8080/docs/swift`](http://localhost:8080/docs/swift).
115120

116121
> Note:
117122
You may see a lot of compiler errors when building the standard library. This is expected, as the documentation for the standard library contains many errors.
118123

119124

120125
### Building documentation for a local project
121126

122-
Building documentation for a local project is similar to building documentation for the standard library, except you need to provide a path to a directory containing the project.
127+
Building documentation for a local project is similar to building documentation for the standard library, except you need to provide a path to the project directory.
123128

124-
Let’s try building documentation for [`swift-nio`](https://github.com/apple/swift-nio). First, we need to clone the repository.
129+
Let’s try building documentation for [`swift-nio`](https://github.com/apple/swift-nio). First, let’s clone the repository to a directory in `/swift`, which is a plausible place to store Git repositories in a devcontainer.
125130

126131
```bash
127132
cd /swift
128133
git clone https://github.com/apple/swift-nio
129134
```
130135

131-
**Where** you clone the repository is important, because you will need to tell Unidoc where to find the project. In this example, we cloned the repository inside a directory called `/swift`, which is a plausible place to store Git repositories in a devcontainer.
132-
133-
Next, you can try building `swift-nio` with `unidoc local`, specifying the path to the search directory (`/swift`) with the `-I` option.
136+
Next, you can try building `swift-nio` with `unidoc local`, specifying the path to the project (`/swift/swift-nio`) with the `-i` option.
134137

135138
@Code(file: load-swift-nio.sh, title: load-swift-nio.sh)
136139

Guides/docs.docc/Quickstart.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,24 @@ You should be able to view the symbol graph and its documentation at [`http://lo
9090

9191
## 5. Generating documentation for SwiftPM packages
9292

93-
Now, let’s generate documentation for [swift-collections](https://github.com/apple/swift-collections), a popular SwiftPM package. Download the library’s source code to a sibling directory.
93+
Now, let’s generate documentation for [swift-collections](https://github.com/apple/swift-collections), a popular SwiftPM package. Download the library’s source code using Git.
9494

9595
```bash
96-
cd ..
9796
git clone https://github.com/apple/swift-collections
98-
cd -
9997
```
10098

101-
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.
99+
To generate documentation for a package, you need to tell Unidoc where to find the project. Because you downloaded the `swift-collections` repository to a child directory, you can use `-i swift-collections` for the project path.
102100

103101
```bash
104-
unidoc local swift-collections -I ..
102+
unidoc local -i swift-collections
103+
```
104+
105+
The default value for the project path is the current working directory (`.`), so alternatively, you could navigate to the `swift-collections` directory and run `unidoc local` without any arguments.
106+
107+
```bash
108+
cd swift-collections
109+
unidoc local
110+
cd -
105111
```
106112

107113
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).
@@ -110,13 +116,11 @@ You should be able to view the symbol graph and its documentation at [`http://lo
110116
> The `swift-collections` documentation.
111117
}
112118

113-
Finally, let’s generate documentation for a package that depends on `swift-collections`. Download the source code for [swift-async-algorithms](https://github.com/apple/swift-async-algorithms) to another sibling directory.
119+
Finally, let’s generate documentation for a package that depends on `swift-collections`. Download the source code for [swift-async-algorithms](https://github.com/apple/swift-async-algorithms) to a sibling directory of `swift-collections`.
114120

115121
```bash
116-
cd ..
117122
git clone https://github.com/apple/swift-async-algorithms
118-
cd -
119-
unidoc local swift-async-algorithms -I ..
123+
unidoc local -i swift-async-algorithms
120124
```
121125

122126

Guides/docs.docc/local/init-server.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
swift --version
2+
swift run -c release unidoc init ~/unidoc
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
swift run -c release unidoc local swift-nio -I /swift
1+
swift run -c release unidoc local -i /swift/swift-nio

Guides/docs.docc/local/unidoc-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
UNIDOC_MIRROR=https://static.swiftinit.org/unidoc
2-
UNIDOC_VERSION=0.19.4
2+
UNIDOC_VERSION=0.19.6
33
UNIDOC_PLATFORM=macOS-ARM64
44

55
curl -L $UNIDOC_MIRROR/$UNIDOC_VERSION/$UNIDOC_PLATFORM/unidoc.tar.gz \

0 commit comments

Comments
 (0)