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

Commit 75108dd

Browse files
Lukas-Stuehrkmattt
andauthored
Display a warning if an input directory does not exist. (#242)
* Display a warning for users if an input directory does not exist. * Clarify that a path should lead to a directory, not a Swift file. * Update Sources/swift-doc/Subcommands/Generate.swift * Add changelog entry for #242 Co-authored-by: Mattt <mattt@me.com>
1 parent 0ecb3fc commit 75108dd

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- Changed serialization of `Symbol` to encode and decode `sourceRange` key
3333
instead of `sourceLocation` key.
3434
#237 by @mattt.
35+
- Changed commands to warn when invalid paths are passed.
36+
#242 by @Lukas-Stuehrk.
3537

3638
### Deprecated
3739

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ $ apt-get install -y libxml2-dev graphviz
9292
USAGE: swift doc generate [<inputs> ...] --module-name <module-name> [--output <output>] [--format <format>] [--base-url <base-url>]
9393

9494
ARGUMENTS:
95-
<inputs> One or more paths to Swift files
95+
<inputs> One or more paths to a directory containing Swift files.
9696

9797
OPTIONS:
9898
-n, --module-name <module-name>
@@ -150,7 +150,7 @@ pass the `--minimum-access-level` flag with the specified access level.
150150
USAGE: swift doc coverage [<inputs> ...] [--output <output>]
151151

152152
ARGUMENTS:
153-
<inputs> One or more paths to Swift files
153+
<inputs> One or more paths to a directory containing Swift files.
154154

155155
OPTIONS:
156156
-o, --output <output> The path for generated report
@@ -202,7 +202,7 @@ please reach out by [opening an Issue][open an issue]!
202202
USAGE: swift doc diagram [<inputs> ...]
203203

204204
ARGUMENTS:
205-
<inputs> One or more paths to Swift files
205+
<inputs> One or more paths to a directory containing Swift files.
206206

207207
OPTIONS:
208208
--minimum-access-level <minimum-access-level>

Sources/swift-doc/Subcommands/Coverage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SwiftDoc
66
extension SwiftDoc {
77
struct Coverage: ParsableCommand {
88
struct Options: ParsableArguments {
9-
@Argument(help: "One or more paths to Swift files")
9+
@Argument(help: "One or more paths to a directory containing Swift files.")
1010
var inputs: [String]
1111

1212
@Option(name: .shortAndLong,

Sources/swift-doc/Subcommands/Diagram.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import GraphViz
77
extension SwiftDoc {
88
struct Diagram: ParsableCommand {
99
struct Options: ParsableArguments {
10-
@Argument(help: "One or more paths to Swift files")
10+
@Argument(help: "One or more paths to a directory containing Swift files.")
1111
var inputs: [String]
1212

1313
@Option(name: .long,

Sources/swift-doc/Subcommands/Generate.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension SwiftDoc {
1717
}
1818

1919
struct Options: ParsableArguments {
20-
@Argument(help: "One or more paths to Swift files")
20+
@Argument(help: "One or more paths to a directory containing Swift files.")
2121
var inputs: [String]
2222

2323
@Option(name: [.long, .customShort("n")],
@@ -47,6 +47,15 @@ extension SwiftDoc {
4747
var options: Options
4848

4949
func run() throws {
50+
for directory in options.inputs {
51+
var isDirectory: ObjCBool = false
52+
if !FileManager.default.fileExists(atPath: directory, isDirectory: &isDirectory) {
53+
logger.warning("Input path \(directory) does not exist.")
54+
} else if !isDirectory.boolValue {
55+
logger.warning("Input path \(directory) is not a directory.")
56+
}
57+
}
58+
5059
let module = try Module(name: options.moduleName, paths: options.inputs)
5160
let baseURL = options.baseURL
5261

0 commit comments

Comments
 (0)