Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 0cb94c4

Browse files
committed
Merge branch 'swift-5.2'
2 parents f852a14 + aec6b9c commit 0cb94c4

35 files changed

+897
-902
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,23 @@ name: CI
33
on: [push]
44

55
jobs:
6-
macos:
7-
runs-on: macOS-latest
6+
# macos:
7+
# runs-on: macOS-latest
88

9-
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v1
12-
- name: Build and Run
13-
run: swift run swift-doc Sources
9+
# steps:
10+
# - name: Checkout
11+
# uses: actions/checkout@v1
12+
# - name: Build and Test
13+
# run: swift test
1414

1515
linux:
1616
runs-on: ubuntu-latest
1717

18-
strategy:
19-
matrix:
20-
swift: ["5.1"]
21-
2218
container:
23-
image: swift:${{ matrix.swift }}
19+
image: swiftlang/swift:nightly-5.2-xenial
2420

2521
steps:
2622
- name: Checkout
2723
uses: actions/checkout@v1
2824
- name: Build and Run
29-
run: swift run swift-doc Sources
25+
run: swift run swift-doc Sources/SwiftDoc

Package.resolved

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,31 @@ let package = Package(
99
.library(name: "SwiftDoc", targets: ["SwiftDoc"])
1010
],
1111
dependencies: [
12+
.package(url: "https://github.com/apple/swift-syntax.git", .revision("0.50200.0")),
13+
.package(url: "https://github.com/SwiftDocOrg/SwiftSemantics.git", .branch("swift-5.2")),
1214
.package(url: "https://github.com/SwiftDocOrg/CommonMark.git", .branch("master")),
1315
.package(url: "https://github.com/SwiftDocOrg/SwiftMarkup.git", .upToNextMinor(from: "0.0.4")),
14-
.package(url: "https://github.com/SwiftDocOrg/SwiftSemantics.git", .branch("master")),
15-
.package(url: "https://github.com/apple/swift-syntax.git", .exact("0.50100.0")),
16-
.package(url: "https://github.com/kylef/Commander.git", .upToNextMinor(from: "0.9.1")),
16+
.package(url: "https://github.com/SwiftDocOrg/GraphViz.git", .upToNextMinor(from: "0.0.1")),
17+
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.0.2")),
1718
],
1819
targets: [
1920
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
2021
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
2122
.target(
2223
name: "swift-doc",
23-
dependencies: ["SwiftDoc", "SwiftSemantics", "SwiftMarkup", "CommonMarkBuilder", "Commander"]
24+
dependencies: ["ArgumentParser", "SwiftDoc", "SwiftSemantics", "SwiftMarkup", "CommonMarkBuilder", "DCOV", "GraphViz"]
2425
),
2526
.target(
26-
name: "swift-dcov",
27-
dependencies: ["SwiftSyntax", "SwiftSemantics", "SwiftMarkup", "SwiftDoc", "Commander"]
28-
),
29-
.target(
30-
name: "swift-api-diagram",
31-
dependencies: ["SwiftDoc", "SwiftSemantics", "Commander"]
32-
),
33-
.target(
34-
name: "swift-api-inventory",
35-
dependencies: ["SwiftDoc", "SwiftSemantics", "Commander"]
27+
name: "DCOV",
28+
dependencies: []
3629
),
3730
.target(
3831
name: "SwiftDoc",
3932
dependencies: ["SwiftSyntax", "SwiftSemantics", "SwiftMarkup"]
4033
),
34+
.testTarget(
35+
name: "SwiftDocTests",
36+
dependencies: ["SwiftDoc", "SwiftSyntax", "SwiftSemantics", "SwiftMarkup"]
37+
),
4138
]
4239
)

README.md

Lines changed: 60 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -63,89 +63,23 @@ By default,
6363
output files are written to `.build/documentation`,
6464
but you can change that with the `--output` option flag.
6565

66-
## GitHub Action
67-
68-
This repository also hosts a [GitHub Action][github actions]
69-
that you can incorporate into your project's workflow.
70-
71-
The CommonMark files generated by `swift-doc`
72-
are formatted for publication to your project's [GitHub Wiki][github wiki],
73-
which you can do with
74-
[github-wiki-publish-action][github-wiki-publish-action].
75-
Alternatively,
76-
you could publish `swift-doc`-generated documentation to GitHub Pages,
77-
or bundle them into a release artifact.
78-
79-
### Inputs
80-
81-
- `inputs`:
82-
One or more paths to Swift files in your workspace.
83-
(Default: `"./Sources"`)
84-
- `output`:
85-
The path for generated output.
86-
(Default: `"./.build/documentation"`)
87-
88-
### Example Workflow
89-
90-
```yml
91-
# .github/workflows/documentation.yml
92-
name: Documentation
93-
94-
on: [push]
95-
96-
jobs:
97-
build:
98-
runs-on: ubuntu-latest
99-
100-
steps:
101-
- uses: actions/checkout@v1
102-
- name: Generate Documentation
103-
uses: SwiftDocOrg/swift-doc@master
104-
with:
105-
inputs: "Source"
106-
output: "Documentation"
107-
- name: Upload Documentation to Wiki
108-
uses: SwiftDocOrg/github-wiki-publish-action@master
109-
with:
110-
path: "Documentation"
111-
env:
112-
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
113-
```
66+
#### swift-doc coverage
11467

115-
## Experimental Command-Line Tools
116-
117-
In addition to `swift-doc`,
118-
this project currently ships with several, experimental tools
119-
that offer complementary functionality.
120-
It's unclear how everything will ultimately fit together,
121-
but for now,
122-
they're incubating in a shared monorepo
123-
(the intent is for each of them to eventually become
124-
an option, subcommand, or plugin of `swift-doc`).
125-
126-
> **Note**:
127-
> We recommend building and running these tools via `swift run`.
128-
> If you prefer to have compiled binaries,
129-
> you can generate them with the same commands
130-
> used for the `swift-doc` target in `Makefile`.
131-
132-
* * *
133-
134-
### swift-dcov
135-
136-
`swift-dcov` generates documentation coverage statistics for Swift files.
68+
The `coverage` subcommand
69+
generates documentation coverage statistics for Swift files.
13770

13871
```terminal
13972
$ git clone https://github.com/SwiftDocOrg/SwiftSemantics.git
14073
141-
$ swift run swift-dcov SwiftSemantics/Sources/ | jq ".data.totals"
74+
$ swift run swift-doc coverage SwiftSemantics/Sources/ --output "dcov.json"
75+
$ cat dcov.json | jq ".data.totals"
14276
{
14377
"count": 207,
14478
"documented": 199,
14579
"percent": 96.1352657004831
14680
}
14781
148-
$ swift run swift-dcov SwiftSemantics/Sources/ | jq ".data.symbols[] | select(.documented == false)"
82+
$ cat dcov.json | jq ".data.symbols[] | select(.documented == false)"
14983
{
15084
"file": "SwiftSemantics/Supporting Types/GenericRequirement.swift",
15185
"line": 67,
@@ -167,86 +101,14 @@ If you know of an existing standard
167101
that you think might be better suited for this purpose,
168102
please reach out by [opening an Issue][open an issue]!
169103

170-
### swift-api-inventory
171-
172-
`swift-api-inventory` lists the public API symbols of Swift files.
173-
174-
```terminal
175-
$ git clone https://github.com/SwiftDocOrg/SwiftSemantics.git
176-
177-
$ swift run swift-api-inventory SwiftSemantics/Sources | less
178-
struct AssociatedType: Declaration, Hashable, Codable, ExpressibleBySyntax
179-
var AssociatedType.attributes { get }
180-
var AssociatedType.context { get }
181-
var AssociatedType.keyword { get }
182-
var AssociatedType.modifiers { get }
183-
var AssociatedType.name { get }
184-
...
185-
186-
$ swift run swift-api-inventory SwiftSemantics/Sources | wc
187-
207 1023 8993
188-
```
189-
190-
Because each symbol is printed on its own line,
191-
you can feed the output of `swift-api-inventory` to conventional diffing tools
192-
to determine API changes between different releases of a project.
104+
#### swift-doc diagram
193105

194-
For example,
195-
here's an API diff between the first beta and latest release candidate of
196-
[Alamofire 5](https://forums.swift.org/t/alamofire-5-one-year-in-the-making-now-in-beta/18865):
197-
198-
```terminal
199-
$ git clone https://github.com/Alamofire/Alamofire.git
200-
$ (cd Alamofire; git co 5.0.0-beta.1; swift run swift-api-inventory Source > ../Alamofire-5.0.0-beta.1.txt)
201-
$ (cd Alamofire; git co 5.0.0-rc.3; swift run swift-api-inventory Source > ../Alamofire-5.0.0-rc.3.txt)
202-
$ diff -u Alamofire-5.0.0-beta.1.txt Alamofire-5.0.0-rc.3.txt | diffstat
203-
Alamofire-5.0.0-rc.3.txt | 346 ++++++++++++++++++++++++++++++++—————
204-
1 file changed, 238 insertions(+), 108 deletions(-)
205-
```
206-
207-
<details>
208-
209-
<summary>Example diff between Alamofire 5 RC3 and RC1</summary>
210-
211-
```terminal
212-
$ diff -u Alamofire-5.0.0-rc.1.txt Alamofire-5.0.0-rc.3.txt
213-
```
214-
215-
```diff
216-
— Alamofire-5.0.0-rc.1.txt
217-
+++ Alamofire-5.0.0-rc.3.txt
218-
@@ -77,6 +77,7 @@
219-
case AFError.ServerTrustFailureReason.revocationCheckFailed(output: Output, options: RevocationTrustEvaluator.Options)
220-
case AFError.ServerTrustFailureReason.revocationPolicyCreationFailed
221-
case AFError.ServerTrustFailureReason.settingAnchorCertificatesFailed(status: OSStatus, certificates: [SecCertificate])
222-
+case AFError.ServerTrustFailureReason.trustEvaluationFailed(error: Error?)
223-
enum AFError.URLRequestValidationFailureReason
224-
case AFError.URLRequestValidationFailureReason.bodyDataInGETRequest(_: Data)
225-
case AFError.createURLRequestFailed(error: Error)
226-
@@ -613,13 +614,14 @@
227-
case URLEncodedFormEncoder.SpaceEncoding.percentEscaped
228-
case URLEncodedFormEncoder.SpaceEncoding.plusReplaced
229-
var URLEncodedFormEncoder.allowedCharacters { get set }
230-
+var URLEncodedFormEncoder.alphabetizeKeyValuePairs { get }
231-
var URLEncodedFormEncoder.arrayEncoding { get }
232-
var URLEncodedFormEncoder.boolEncoding { get }
233-
var URLEncodedFormEncoder.dataEncoding { get }
234-
var URLEncodedFormEncoder.dateEncoding { get }
235-
func URLEncodedFormEncoder.encode(_: Encodable) throws -> String
236-
func URLEncodedFormEncoder.encode(_: Encodable) throws -> Data
237-
-init URLEncodedFormEncoder(arrayEncoding: ArrayEncoding, boolEncoding: BoolEncoding, dataEncoding: DataEncoding, dateEncoding: DateEncoding, keyEncoding: KeyEncoding, spaceEncoding: SpaceEncoding, allowedCharacters: CharacterSet)
238-
+init URLEncodedFormEncoder(alphabetizeKeyValuePairs: Bool, arrayEncoding: ArrayEncoding, boolEncoding: BoolEncoding, dataEncoding: DataEncoding, dateEncoding: DateEncoding, keyEncoding: KeyEncoding, spaceEncoding: SpaceEncoding, allowedCharacters: CharacterSet)
239-
```
240-
241-
</details>
242-
243-
### swift-api-diagram
244-
245-
`swift-api-diagram` generates a graph of APIs in [DOT format][dot]
106+
The `diagram` subcommand
107+
generates a graph of APIs in [DOT format][dot]
246108
that can be rendered by [GraphViz][graphviz] into a diagram.
247109

248110
```terminal
249-
$ swift run swift-api-diagram Alamofire/Source > graph.dot
111+
$ swift run swift-doc diagram Alamofire/Source > graph.dot
250112
$ head graph.dot
251113
digraph Anonymous {
252114
"Session" [shape=box];
@@ -266,6 +128,56 @@ Here's an excerpt of the graph generated for Alamofire:
266128

267129
![Excerpt of swift-doc-api Diagram for Alamofire](https://user-images.githubusercontent.com/7659/73189318-0db0e880-40d9-11ea-8895-341a75ce873c.png)
268130

131+
## GitHub Action
132+
133+
This repository also hosts a [GitHub Action][github actions]
134+
that you can incorporate into your project's workflow.
135+
136+
The CommonMark files generated by `swift-doc`
137+
are formatted for publication to your project's [GitHub Wiki][github wiki],
138+
which you can do with
139+
[github-wiki-publish-action][github-wiki-publish-action].
140+
Alternatively,
141+
you could publish `swift-doc`-generated documentation to GitHub Pages,
142+
or bundle them into a release artifact.
143+
144+
### Inputs
145+
146+
- `inputs`:
147+
One or more paths to Swift files in your workspace.
148+
(Default: `"./Sources"`)
149+
- `output`:
150+
The path for generated output.
151+
(Default: `"./.build/documentation"`)
152+
153+
### Example Workflow
154+
155+
```yml
156+
# .github/workflows/documentation.yml
157+
name: Documentation
158+
159+
on: [push]
160+
161+
jobs:
162+
build:
163+
runs-on: ubuntu-latest
164+
165+
steps:
166+
- uses: actions/checkout@v1
167+
- name: Generate Documentation
168+
uses: SwiftDocOrg/swift-doc@master
169+
with:
170+
inputs: "Source"
171+
output: "Documentation"
172+
- name: Upload Documentation to Wiki
173+
uses: SwiftDocOrg/github-wiki-publish-action@master
174+
with:
175+
path: "Documentation"
176+
env:
177+
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_PERSONAL_ACCESS_TOKEN }}
178+
```
179+
180+
* * *
269181
270182
## Motivation
271183

0 commit comments

Comments
 (0)