@@ -11,27 +11,44 @@ for each class, structure, enumeration, and protocol
11
11
as well as top-level type aliases, functions, and variables.
12
12
13
13
For an example of generated documentation,
14
- [ check out the Uncyclo for our fork of Alamofire] [ alamofire wiki ] .
14
+ [ check out the Uncyclo for our fork of Alamofire] [ alamofire wiki ] .
15
15
16
16
> ** Note** :
17
17
> Output is currently limited to CommonMark,
18
18
> but the plan is to support HTML and other formats as well.
19
19
20
- ## Usage
20
+ ## Command-Line Utility
21
21
22
- ` swift-doc ` can be used from the command-line
23
- or in a [ GitHub Actions] [ github actions ] workflow.
22
+ ` swift-doc ` can be used from the command-line on macOS and Linux.
24
23
25
- ### Command-Line Utility
24
+ ### Installation
26
25
27
- To run ` swift-doc ` from the command-line,
28
- clone the repository
29
- and do ` swift run swift-doc ` from within the project directory.
26
+ #### Homebrew
27
+
28
+ Run the following command to install using [ Homebrew] ( https://brew.sh/ ) :
29
+
30
+ ``` terminal
31
+ $ brew install swiftdocorg/formulae/swift-doc
32
+ ```
33
+
34
+ #### Manually
35
+
36
+ Run the following commands to build and install manually:
30
37
31
38
``` terminal
32
- $ git clone https://github.com/SwiftDocOrg/swift-doc.git
39
+ $ git clone https://github.com/SwiftDocOrg/swift-doc
33
40
$ cd swift-doc
34
- $ swift run swift-doc path/to/SwiftProject/Sources --output Documentation
41
+ $ make install
42
+ ```
43
+
44
+ ### Usage
45
+
46
+ ` swift-doc ` takes one or more paths and enumerates them recursively,
47
+ collecting all Swift files into a single "module"
48
+ and generating documentation accordingly.
49
+
50
+ ``` terminal
51
+ $ swift doc path/to/SwiftProject/Sources --output Documentation
35
52
$ tree Documentation
36
53
$ Documentation/
37
54
├── Home
@@ -40,36 +57,33 @@ $ Documentation/
40
57
└── _Sidebar.md
41
58
```
42
59
43
- ` swift-doc ` takes one or more paths and enumerates them recursively,
44
- collecting all Swift files into a single "module"
45
- and generating documentation accordingly.
46
60
By default,
47
61
output files are written to ` .build/documentation ` ,
48
62
but you can change that with the ` --output ` option flag.
49
63
50
- ### GitHub Action
64
+ ## GitHub Action
51
65
52
66
This repository also hosts a [ GitHub Action] [ github actions ]
53
67
that you can incorporate into your project's workflow.
54
68
55
- The CommonMark files generated by ` swift-doc `
69
+ The CommonMark files generated by ` swift-doc `
56
70
are formatted for publication to your project's [ GitHub Uncyclo] [ github wiki ] ,
57
- which you can do with
71
+ which you can do with
58
72
[ github-wiki-publish-action] [ github-wiki-publish-action ] .
59
73
Alternatively,
60
74
you could publish ` swift-doc ` -generated documentation to GitHub Pages,
61
75
or bundle them into a release artifact.
62
76
63
- #### Inputs
77
+ ### Inputs
64
78
65
- - ` inputs ` :
66
- One or more paths to Swift files in your workspace.
79
+ - ` inputs ` :
80
+ One or more paths to Swift files in your workspace.
67
81
(Default: ` "./Sources" ` )
68
82
- ` output ` :
69
- The path for generated output.
83
+ The path for generated output.
70
84
(Default: ` "./.build/documentation" ` )
71
85
72
- #### Example Workflow
86
+ ### Example Workflow
73
87
74
88
``` yml
75
89
name : Documentation
@@ -95,15 +109,15 @@ jobs:
95
109
GITHUB_PERSONAL_ACCESS_TOKEN : ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
96
110
` ` `
97
111
98
- * * *
112
+ ## Experimental Command-Line Tools
99
113
100
114
In addition to ` swift-doc`,
101
- this project currently ships with several, experimental executables
115
+ this project currently ships with several, experimental tools
102
116
that offer complementary functionality.
103
117
It's unclear how everything will ultimately fit together,
104
- but for now,
118
+ but for now,
105
119
they're incubating in a shared monorepo
106
- (the intent is for each of them to eventually become
120
+ (the intent is for each of them to eventually become
107
121
an option, subcommand, or plugin of `swift-doc`).
108
122
109
123
* * *
@@ -137,10 +151,10 @@ $ swift run swift-dcov SwiftSemantics/Sources/ | jq ".data.symbols[] | select(.d
137
151
While there are plenty of tools for assessing test coverage for code,
138
152
we weren't able to find anything analogous for documentation coverage.
139
153
To this end,
140
- we've contrived a simple JSON format
154
+ we've contrived a simple JSON format
141
155
[inspired by llvm-cov](https://reviews.llvm.org/D22651#change-xdePaVfBugps).
142
156
143
- If you know of an existing standard
157
+ If you know of an existing standard
144
158
that you think might be better suited for this purpose,
145
159
please reach out by [opening an Issue][open an issue]!
146
160
@@ -169,7 +183,7 @@ you can feed the output of `swift-api-inventory` to conventional diffing tools
169
183
to determine API changes between different releases of a project.
170
184
171
185
For example,
172
- here's an API diff between the first beta and latest release candidate of
186
+ here's an API diff between the first beta and latest release candidate of
173
187
[Alamofire 5](https://forums.swift.org/t/alamofire-5-one-year-in-the-making-now-in-beta/18865) :
174
188
175
189
` ` ` terminal
@@ -231,7 +245,7 @@ digraph Anonymous {
231
245
"URLEncodedFormEncoder" [shape=box,peripheries=2];
232
246
"ServerTrustManager" [shape=box];
233
247
"MultipartFormData" [shape=box];
234
-
248
+
235
249
subgraph cluster_Request {
236
250
"DataRequest" [shape=box];
237
251
"Request" [shape=box];
@@ -253,13 +267,13 @@ for both Swift and Objective-C projects.
253
267
Over time, however,
254
268
the way we write Swift code —
255
269
and indeed the language itself —
256
- has evolved to incorporate patterns and features
257
- that are difficult to understand using
270
+ has evolved to incorporate patterns and features
271
+ that are difficult to understand using
258
272
the same documentation standards that served us well for Objective-C.
259
273
260
274
Whereas in Objective-C,
261
275
you could get a complete view of a type's functionality from its class hierarchy,
262
- Swift code today tends to layer and distribute functionality across
276
+ Swift code today tends to layer and distribute functionality across
263
277
[a network of types][swift number protocols diagram].
264
278
While adopting a
265
279
[protocol-oriented paradigm][protocol-oriented programming]
@@ -271,7 +285,7 @@ is to make Swift documentation more useful
271
285
by surfacing the information you need to understand how an API works
272
286
and presenting it in a way that can be easily searched and accessed.
273
287
We want developers to be empowered to use Swift packages to their full extent,
274
- without being reliant on (often outdated) blog posts or Stack Overflow threads.
288
+ without being reliant on (often outdated) blog posts or Stack Overflow threads.
275
289
We want documentation coverage to become as important as test coverage :
276
290
a valuable metric for code quality,
277
291
and an expected part of first-rate open source projects.
@@ -294,8 +308,10 @@ having instead focused on perceived cosmetic issues.)
294
308
Without much in the way of strong design guidance,
295
309
we're not entirely sure what Swift documentation _should_ look like.
296
310
But we do think plain text is a good place to start.
297
- We look forward to soliciting feedback and ideas from everyone
298
- to identify what those needs are and coming up with the best ways to meet them.
311
+ We look forward to
312
+ soliciting feedback and ideas from everyone
313
+ so that we can identify those needs
314
+ and figure out the best ways to meet them.
299
315
300
316
In the meantime,
301
317
we've set ourselves up for success
@@ -320,7 +336,7 @@ Because it relies only on a syntactic reading of Swift source code,
320
336
without needing code first to be compiled,
321
337
` swift-doc` is quite fast.
322
338
As a baseline,
323
- compare its performance to Jazzy
339
+ compare its performance to Jazzy
324
340
when generating documentation for [SwiftSemantics][swiftsemantics] :
325
341
326
342
` ` ` terminal
@@ -347,17 +363,19 @@ to [a GitHub wiki generated with `swift-doc`][swift-doc swiftsemantics].
347
363
348
364
## What About [ SwiftDoc.org] [ swiftdoc.org ] ?
349
365
350
- ** tl;dr:**
351
- We're currently working on updating SwiftDoc.org for Swift 5,
352
- and hope to have it released later this week.
366
+ ** tl;dr:**
367
+ SwiftDoc.org is now updated for Swift 5.1,
368
+ but we're still working to migrate over a few missing parts
369
+ (notably, the beloved
370
+ [ type inheritance graphs] ( https://swiftdoc.org/v4.2/protocol/expressiblebyfloatliteral/hierarchy/ ) ).
353
371
354
372
SwiftDoc.org,
355
373
[ originally "Swifter"] ( http://natecook.com/blog/2014/09/introducing-swifter/ ) ,
356
- was created by Nate Cook ([ @natecook1000 ] [ @natecook1000 ] )
374
+ was created by Nate Cook ([ @natecook1000 ] [ @natecook1000 ] )
357
375
in September 2014.
358
376
At the time,
359
377
Swift tooling was still in its infancy,
360
- so Nate actually
378
+ so Nate actually
361
379
[ wrote a parser (from scratch!)] ( https://github.com/SwiftDocOrg/swiftdoc-parser )
362
380
to pull symbols and documentation from the Swift standard library.
363
381
Nate became managing editor of [ NSHipster] [ nshipster ] in 2015,
@@ -369,9 +387,9 @@ After the hand-off,
369
387
we were able to get the site updated for Swift 4.2 without too much trouble.
370
388
But when it came time to regenerate the site for Swift 5,
371
389
we found ourselves deep in [ "dependency hell"] [ dependency hell ]
372
- (something to do with the [ regular expression] [ pcre ] library
390
+ (something to do with the [ regular expression] [ pcre ] library
373
391
that Nate had used for the parser).
374
- After begging and pleading with
392
+ After begging and pleading with
375
393
the spirits possessing our ` node_modules ` directory to no avail,
376
394
we decided to roll up our sleeves and get started on a long-term replacement —
377
395
this time, written in Swift.
0 commit comments