Minor documentation fixes

[ci skip]
This commit is contained in:
Max Howell
2019-01-26 18:00:16 +00:00
parent 3beba13677
commit 99b948f9c1
5 changed files with 31 additions and 32 deletions

View File

@@ -28,7 +28,7 @@ print(bar) // => /bar
print(bar.isFile) // => true
// careful API considerations so as to avoid common bugs
let foo = try Path.root.join("foo").copy(into: Path.root.mkdir("bar"))
let foo = try Path.root.join("foo").copy(into: Path.root.join("bar").mkdir())
print(foo) // => /bar/foo
print(foo.isFile) // => true

View File

@@ -3,7 +3,7 @@ import Foundation
extension Path {
//MARK: Common Directories
/// Returns a `Path` containing ``FileManager.default.currentDirectoryPath`.
/// Returns a `Path` containing `FileManager.default.currentDirectoryPath`.
public static var cwd: Path {
return Path(string: FileManager.default.currentDirectoryPath)
}
@@ -74,7 +74,7 @@ extension Path {
/**
The root for cache files.
- Note: On Linux this is 'XDG_CACHE_HOME'.
- Note: On Linux this is `XDG_CACHE_HOME`.
- Note: You should create a subdirectory before creating any files.
*/
public static var caches: Path {

View File

@@ -147,7 +147,6 @@ public extension Path {
/**
Creates the directory at this path.
- Note: Does not create any intermediary directories.
- Parameter options: Specify `mkdir(.p)` to create intermediary directories.
- Note: We do not error if the directory already exists (even without `.p`)
because *Path.swift* noops if the desired end result preexists.
@@ -174,8 +173,8 @@ public extension Path {
}
}
/// Options for `Path.mkdir`
/// Options for `Path.mkdir(_:)`
public enum MakeDirectoryOptions {
/// Creates intermediary directories. Works the same as mkdir -p.
/// Creates intermediary directories; works the same as `mkdir -p`.
case p
}

View File

@@ -1,8 +1,26 @@
import Foundation
public extension Path {
/**
A file entry from a directory listing.
- SeeAlso: `ls()`
*/
public struct Entry {
/// The kind of this directory entry.
public enum Kind {
/// The path is a file.
case file
/// The path is a directory.
case directory
}
/// The kind of this entry.
public let kind: Kind
/// The path of this entry.
public let path: Path
}
public extension Path {
//MARK: Directory Listings
/**
Same as the `ls -a` command output is shallow and unsorted.
- Parameter includeHiddenFiles: If `true`, hidden files are included in the results. Defaults to `true`.
@@ -25,7 +43,7 @@ public extension Path {
}
/// Convenience functions for the array return value of `Path.ls()`
public extension Array where Element == Path.Entry {
public extension Array where Element == Entry {
/// Filters the list of entries to be a list of Paths that are directories.
var directories: [Path] {
return compactMap {

View File

@@ -1,14 +1,16 @@
import Foundation
/**
Represents a platform filesystem absolute path.
Represents a filesystem absolute path.
`Path` supports `Codable`, and can be configured to
[encode paths *relatively*](https://github.com/mxcl/Path.swift/#codable).
Sorting a `Sequence` of `Path`s will return the locale-aware sort order, which
will give you the same order as Finder, (though folders will not be sorted
first).
will give you the same order as Finder.
All functions on `Path` are chainable and short to facilitate doing sequences
of file operations in a concise manner.
Converting from a `String` is a common first step, here are the recommended
ways to do that:
@@ -168,24 +170,4 @@ public struct Path: Equatable, Hashable, Comparable {
public static func <(lhs: Path, rhs: Path) -> Bool {
return lhs.string.compare(rhs.string, locale: .current) == .orderedAscending
}
//MARK: Entry
/**
A file entry from a directory listing.
- SeeAlso: `ls()`
*/
public struct Entry {
/// The kind of this directory entry.
public enum Kind {
/// The path is a file.
case file
/// The path is a directory.
case directory
}
/// The kind of this entry.
public let kind: Kind
/// The path of this entry.
public let path: Path
}
}