@@ -63,89 +63,23 @@ By default,
6363output files are written to ` .build/documentation ` ,
6464but 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
167101that you think might be better suited for this purpose,
168102please 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 ]
246108that 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
251113digraph 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