Skip to content

Commit 2ad068a

Browse files
committed
Add documentation for links to source declarations
Added documentation to configure DocC's new functionality that emits links to symbols' declaration in the project's source repository, which was implemented in #256.
1 parent a5fff32 commit 2ad068a

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed
82.6 KB
Loading
84 KB
Loading

Sources/DocCDocumentation/DocCDocumentation.docc/distributing-documentation-to-other-developers.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,65 @@ Distributing your documentation involves the following steps:
2424

2525
### Generate a Publishable Archive of Your Documentation
2626

27-
To create a documentation archive, use the `docc` command-line tool.
27+
To create a documentation archive for a Swift package, use the [SwiftPM DocC
28+
Plugin](https://apple.github.io/swift-docc-plugin/documentation/swiftdoccplugin/)
29+
or use Xcode's _Build Documentation_ command.
2830

29-
To export the documentation archive from the command line, run `docc` in Terminal.
30-
31-
For example, to build a documentation archive, use a command similar to the
32-
following:
31+
Alternatively, use the `docc` command-line tool directly, for example:
3332

3433
```shell
35-
docc convert MyNewPackage.docc --fallback-display-name MyNewPackage --fallback-bundle-identifier com.example.MyNewPackage --fallback-bundle-version 1 --additional-symbol-graph-dir .build --output-dir MyNewPackage.doccarchive
34+
docc convert MyNewPackage.docc \
35+
--fallback-display-name MyNewPackage \
36+
--fallback-bundle-identifier com.example.MyNewPackage \
37+
--fallback-bundle-version 1 \
38+
--additional-symbol-graph-dir .build \
39+
--output-dir MyNewPackage.doccarchive
40+
```
41+
42+
#### Include links to your project's sources
43+
44+
When publishing documentation to an audience that has access to your project's
45+
sources, e.g., for an open-source project hosted on GitHub, consider configuring
46+
DocC to automatically include links to the declarations of your project's symbols.
47+
48+
For example, in the following screenshot, the "ParsableCommand.swift" link
49+
below the declaration navigates to the `ParsableCommand` declaration in the
50+
project's GitHub repository.
51+
52+
![A DocC documentation page showing the title and declaration of a symbol
53+
called ParsableCommand. Under the declaration, there is a link with a Swift
54+
icon and the file name ParsableCommand.swift](link-to-source.png)
55+
56+
To configure DocC to generate links to your project's sources, use the source
57+
service configuration flags like so:
58+
59+
**GitHub**
60+
```bash
61+
docc convert […] \
62+
--source-service github \
63+
--source-service-base-url https://github.com/<org>/<repo>/blob/<branch> \
64+
--checkout-path <path to local checkout>
65+
```
66+
67+
**GitLab**
68+
```bash
69+
docc convert […] \
70+
--source-service gitlab \
71+
--source-service-base-url https://gitlab.com/<org>/<repo>/-/tree/<branch> \
72+
--checkout-path <path to local checkout>
73+
```
74+
75+
**BitBucket**
76+
```bash
77+
docc convert […] \
78+
--source-service bitbucket \
79+
--source-service-base-url https://bitbucket.org/<org>/<repo>/src/<branch> \
80+
--checkout-path <path to local checkout>
3681
```
3782

83+
These arguments can also be provided to `swift package generate-documentation`
84+
if you're using the SwiftPM DocC Plugin or via the `OTHER_DOCC_FLAGS` build
85+
setting when building in Xcode.
3886

3987
### Send a Documentation Archive Directly to Developers
4088

0 commit comments

Comments
 (0)