Skip to content

Commit 08e9abe

Browse files
authored
Merge pull request #119 from amartini51/doc_comment_placement
Fix doc comment placement
2 parents a2bf0d5 + 2c2a831 commit 08e9abe

File tree

7 files changed

+20
-46
lines changed

7 files changed

+20
-46
lines changed

Sources/System/FilePath/FilePath.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10+
// TODO(docs): Section on all the new syntactic operations, lexical normalization, decomposition,
11+
// components, etc.
12+
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
1013
/// Represents a location in the file system.
1114
///
1215
/// This structure recognizes directory separators (e.g. `/`), roots, and
@@ -37,10 +40,6 @@
3740
/// However, the rules for path equivalence
3841
/// are file-system–specific and have additional considerations
3942
/// like case insensitivity, Unicode normalization, and symbolic links.
40-
///
41-
// TODO(docs): Section on all the new syntactic operations, lexical normalization, decomposition,
42-
// components, etc.
43-
/*System 0.0.1, @available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)*/
4443
public struct FilePath {
4544
internal var _storage: SystemString
4645

Sources/System/FilePath/FilePathComponentView.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ extension FilePath {
2828
///
2929
/// path.components.removeAll { $0.kind == .currentDirectory }
3030
/// // path is "/home/username/bin/scripts/tree"
31-
///
3231
public struct ComponentView {
3332
internal var _path: FilePath
3433
internal var _start: SystemString.Index

Sources/System/FilePath/FilePathComponents.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ extension FilePath {
5454
/// file.kind == .regular // true
5555
/// file.extension // "txt"
5656
/// path.append(file) // path is "/tmp/foo.txt"
57-
///
5857
public struct Component {
5958
internal var _path: FilePath
6059
internal var _range: Range<SystemString.Index>

Sources/System/FilePath/FilePathString.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ extension FilePath.Component {
9898
///
9999
/// - Parameter platformString: A pointer to a null-terminated platform
100100
/// string.
101-
///
102101
public init?(platformString: UnsafePointer<CInterop.PlatformChar>) {
103102
self.init(_platformString: platformString)
104103
}
@@ -187,7 +186,6 @@ extension FilePath.Root {
187186
///
188187
/// - Parameter platformString: A pointer to a null-terminated platform
189188
/// string.
190-
///
191189
public init?(platformString: UnsafePointer<CInterop.PlatformChar>) {
192190
self.init(_platformString: platformString)
193191
}

Sources/System/FilePath/FilePathSyntax.swift

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ extension FilePath {
5252
/// * `\Users`
5353
public var isRelative: Bool { !isAbsolute }
5454

55+
// TODO(Windows docs): examples with roots, such as whether `\foo\bar`
56+
// starts with `C:\foo`
5557
/// Returns whether `other` is a prefix of `self`, only considering
5658
/// whole path components.
5759
///
@@ -63,15 +65,14 @@ extension FilePath {
6365
/// path.starts(with: "/usr/bin/ls") // true
6466
/// path.starts(with: "/usr/bin/ls///") // true
6567
/// path.starts(with: "/us") // false
66-
///
67-
// TODO(Windows docs): examples with roots, such as whether `\foo\bar`
68-
// starts with `C:\foo`
6968
public func starts(with other: FilePath) -> Bool {
7069
guard !other.isEmpty else { return true }
7170
return self.root == other.root && components.starts(
7271
with: other.components)
7372
}
7473

74+
// TODO(Windows docs): examples with roots, such as whether `C:\foo\bar`
75+
// ends with `C:bar`
7576
/// Returns whether `other` is a suffix of `self`, only considering
7677
/// whole path components.
7778
///
@@ -83,9 +84,6 @@ extension FilePath {
8384
/// path.ends(with: "usr/bin/ls") // true
8485
/// path.ends(with: "/usr/bin/ls///") // true
8586
/// path.ends(with: "/ls") // false
86-
///
87-
// TODO(Windows docs): examples with roots, such as whether `C:\foo\bar`
88-
// ends with `C:bar`
8987
public func ends(with other: FilePath) -> Bool {
9088
if other.root != nil {
9189
// TODO: anything tricky here for Windows?
@@ -145,7 +143,6 @@ extension FilePath {
145143
/// path.root = nil // path is #"foo\bar"#
146144
/// path.root = "C:" // path is #"C:foo\bar"#
147145
/// path.root = #"C:\"# // path is #"C:\foo\bar"#
148-
///
149146
public var root: FilePath.Root? {
150147
get {
151148
guard _hasRoot else { return nil }
@@ -178,7 +175,6 @@ extension FilePath {
178175
/// * `\\?\device\folder\file.exe => folder\file.exe`
179176
/// * `\\server\share\file => file`
180177
/// * `\ => ""`
181-
///
182178
public __consuming func removingRoot() -> FilePath {
183179
var copy = self
184180
copy.root = nil
@@ -209,7 +205,6 @@ extension FilePath {
209205
/// * `\\?\UNC\server\share\bar.exe => bar.exe`
210206
/// * `\\server\share => nil`
211207
/// * `\\?\UNC\server\share\ => nil`
212-
///
213208
public var lastComponent: Component? { components.last }
214209

215210
/// Creates a new path with everything up to but not including
@@ -247,7 +242,6 @@ extension FilePath {
247242
/// path.removeLastComponent() == true // path is "/usr"
248243
/// path.removeLastComponent() == true // path is "/"
249244
/// path.removeLastComponent() == false // path is "/"
250-
///
251245
@discardableResult
252246
public mutating func removeLastComponent() -> Bool {
253247
defer { _invariantCheck() }
@@ -271,7 +265,6 @@ extension FilePath.Component {
271265
/// * `Foo.app => app`
272266
/// * `.hidden => nil`
273267
/// * `.. => nil`
274-
///
275268
public var `extension`: String? {
276269
guard let range = _extensionRange() else { return nil }
277270
return _slice[range].string
@@ -285,7 +278,6 @@ extension FilePath.Component {
285278
/// * `Foo.app => Foo`
286279
/// * `.hidden => .hidden`
287280
/// * `.. => ..`
288-
///
289281
public var stem: String {
290282
_slice[_stemRange()].string
291283
}
@@ -322,7 +314,6 @@ extension FilePath {
322314
/// path.extension = "o" // path is "/tmp/file.o"
323315
/// path.extension = nil // path is "/tmp/file"
324316
/// path.extension = "" // path is "/tmp/file."
325-
///
326317
public var `extension`: String? {
327318
get { lastComponent?.extension }
328319
set {
@@ -441,6 +432,7 @@ extension FilePath {
441432
// Modification and concatenation API
442433
/*System 0.0.2, @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)*/
443434
extension FilePath {
435+
// TODO(Windows docs): example with roots
444436
/// If `prefix` is a prefix of `self`, removes it and returns `true`.
445437
/// Otherwise returns `false`.
446438
///
@@ -450,8 +442,6 @@ extension FilePath {
450442
/// path.removePrefix("/usr/bin") // false
451443
/// path.removePrefix("/us") // false
452444
/// path.removePrefix("/usr/local") // true, path is "bin"
453-
///
454-
// TODO(Windows docs): example with roots
455445
public mutating func removePrefix(_ prefix: FilePath) -> Bool {
456446
defer { _invariantCheck() }
457447
// FIXME: Should Windows have more nuanced semantics?
@@ -462,6 +452,7 @@ extension FilePath {
462452
return true
463453
}
464454

455+
// TODO(Windows docs): example with roots
465456
/// Append a `component` on to the end of this path.
466457
///
467458
/// Example:
@@ -472,13 +463,12 @@ extension FilePath {
472463
/// path.append(comp)
473464
/// }
474465
/// // path is "/tmp/foo/bar/../baz"
475-
///
476-
// TODO(Windows docs): example with roots
477466
public mutating func append(_ component: __owned FilePath.Component) {
478467
defer { _invariantCheck() }
479468
_append(unchecked: component._slice)
480469
}
481470

471+
// TODO(Windows docs): example with roots
482472
/// Append `components` on to the end of this path.
483473
///
484474
/// Example:
@@ -487,8 +477,6 @@ extension FilePath {
487477
/// path.append(["usr", "local"]) // path is "/usr/local"
488478
/// let otherPath: FilePath = "/bin/ls"
489479
/// path.append(otherPath.components) // path is "/usr/local/bin/ls"
490-
///
491-
// TODO(Windows docs): example with roots
492480
public mutating func append<C: Collection>(
493481
_ components: __owned C
494482
) where C.Element == FilePath.Component {
@@ -498,6 +486,8 @@ extension FilePath {
498486
}
499487
}
500488

489+
// TODO(Windows docs): example with roots, should we rephrase this "spurious
490+
// roots"?
501491
/// Append the contents of `other`, ignoring any spurious leading separators.
502492
///
503493
/// A leading separator is spurious if `self` is non-empty.
@@ -508,9 +498,6 @@ extension FilePath {
508498
/// path.append("/var/www/website") // "/var/www/website"
509499
/// path.append("static/assets") // "/var/www/website/static/assets"
510500
/// path.append("/main.css") // "/var/www/website/static/assets/main.css"
511-
///
512-
// TODO(Windows docs): example with roots, should we rephrase this "spurious
513-
// roots"?
514501
public mutating func append(_ other: __owned String) {
515502
defer { _invariantCheck() }
516503
guard !other.utf8.isEmpty else { return }
@@ -522,18 +509,16 @@ extension FilePath {
522509
_append(unchecked: otherPath._storage[otherPath._relativeStart...])
523510
}
524511

525-
/// Non-mutating version of `append(_:Component)`.
526-
///
527512
// TODO(Windows docs): example with roots
513+
/// Non-mutating version of `append(_:Component)`.
528514
public __consuming func appending(_ other: __owned Component) -> FilePath {
529515
var copy = self
530516
copy.append(other)
531517
return copy
532518
}
533519

534-
/// Non-mutating version of `append(_:C)`.
535-
///
536520
// TODO(Windows docs): example with roots
521+
/// Non-mutating version of `append(_:C)`.
537522
public __consuming func appending<C: Collection>(
538523
_ components: __owned C
539524
) -> FilePath where C.Element == FilePath.Component {
@@ -542,15 +527,16 @@ extension FilePath {
542527
return copy
543528
}
544529

545-
/// Non-mutating version of `append(_:String)`.
546-
///
547530
// TODO(Windows docs): example with roots
531+
/// Non-mutating version of `append(_:String)`.
548532
public __consuming func appending(_ other: __owned String) -> FilePath {
549533
var copy = self
550534
copy.append(other)
551535
return copy
552536
}
553537

538+
// TODO(Windows docs): examples and docs with roots, update/generalize doc
539+
// comment
554540
/// If `other` does not have a root, append each component of `other`. If
555541
/// `other` has a root, replaces `self` with other.
556542
///
@@ -564,9 +550,6 @@ extension FilePath {
564550
/// var path: FilePath = "/tmp"
565551
/// path.push("dir/file.txt") // path is "/tmp/dir/file.txt"
566552
/// path.push("/bin") // path is "/bin"
567-
///
568-
// TODO(Windows docs): examples and docs with roots, update/generalize doc
569-
// comment
570553
public mutating func push(_ other: __owned FilePath) {
571554
defer { _invariantCheck() }
572555
guard other.root == nil else {
@@ -577,9 +560,8 @@ extension FilePath {
577560
_append(unchecked: other._storage[...])
578561
}
579562

580-
/// Non-mutating version of `push()`.
581-
///
582563
// TODO(Windows docs): examples and docs with roots
564+
/// Non-mutating version of `push()`.
583565
public __consuming func pushing(_ other: __owned FilePath) -> FilePath {
584566
var copy = self
585567
copy.push(other)

Sources/System/FilePath/FilePathWindows.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,21 +150,19 @@ internal struct WindowsRootInfo {
150150
/// * Omitted volume from other forms: `\\.\`, `\\.\UNC\server\\`, `\\server\\`
151151
case empty
152152

153+
// TODO: NT paths? Admin paths using `$`?
153154
/// A specified drive.
154155
///
155156
/// * Traditional disk: `C:\`, `C:`
156157
/// * Device disk: `\\.\C:\`, `\\?\C:\`
157158
/// * UNC: `\\server\e:\`, `\\?\UNC\server\e:\`
158-
///
159-
// TODO: NT paths? Admin paths using `$`?
160159
case drive(Character)
161160

161+
// TODO: GUID type?
162162
/// A volume with a GUID in a non-traditional path
163163
///
164164
/// * UNC: `\\host\Volume{0000-...}\`, `\\.\UNC\host\Volume{0000-...}\`
165165
/// * Device roots: `\\.\Volume{0000-...}\`, `\\?\Volume{000-...}\`
166-
///
167-
// TODO: GUID type?
168166
case guid(String)
169167

170168
// TODO: Legacy DOS devices, such as COM1?

Tests/SystemTests/FilePathTests/FilePathExtras.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ extension FilePath {
5151

5252
/// Whether a lexically-normalized `self` contains a lexically-normalized
5353
/// `other`.
54-
///
5554
public func lexicallyContains(_ other: FilePath) -> Bool {
5655
guard !other.isEmpty else { return true }
5756
guard !isEmpty else { return false }

0 commit comments

Comments
 (0)