Skip to content

Commit

Permalink
Get out documentation %age up
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Jul 22, 2019
1 parent af091cc commit dfad736
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/Path+ls.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import Foundation

public extension Path {
/// The builder for `Path.find()`
class Finder {
fileprivate init(path: Path) {
self.path = path
}

/// The `path` find operations operate on.
public let path: Path
/// The maximum directory depth find operations will dip. Zero means no subdirectories.
fileprivate(set) public var maxDepth: Int? = nil
/// The kinds of filesystem entries find operations will return.
fileprivate(set) public var kinds: Set<Path.Kind>?
/// The file extensions find operations will return. Files *and* directories unless you filter for `kinds`.
fileprivate(set) public var extensions: Set<String>?
}
}
Expand Down Expand Up @@ -83,9 +88,7 @@ public extension Path.Finder {
}
}

public extension Pathish {
//MARK: Directory Listings

public extension Pathish {
/**
Same as the `ls` command ∴ output is ”shallow” and unsorted.
- Note: as per `ls`, by default we do *not* return hidden files. Specify `.a` for hidden files.
Expand All @@ -105,6 +108,7 @@ public extension Pathish {
}
}

/// Recursively find files under this path. If the path is a file, no files will be found.
func find() -> Path.Finder {
return .init(path: Path(self))
}
Expand All @@ -128,7 +132,7 @@ public extension Array where Element == Path {
}
}

/// Options for `Path.mkdir(_:)`
/// Options for `Path.ls(_:)`
public enum ListDirectoryOptions {
/// Creates intermediary directories; works the same as `mkdir -p`.
case a
Expand Down
1 change: 1 addition & 0 deletions Sources/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let _realpath = Glibc.realpath
to the anti-pattern where Path.swift suddenly feels like Javascript otherwise.
- Note: A `Path` does not necessarily represent an actual filesystem entry.
- SeeAlso: `Pathish` for most methods you will use on `Path` instances.
*/
public struct Path: Pathish {

Expand Down
3 changes: 3 additions & 0 deletions Sources/Pathish.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ public protocol Pathish: Hashable, Comparable {
}

public extension Pathish {
/// Two `Path`s are equal if their strings are identical. Strings are normalized upon construction, yet
/// if the files are different symlinks to the same file the equality check will not succeed. Use `realpath`
/// in such circumstances.
static func ==<P: Pathish> (lhs: Self, rhs: P) -> Bool {
return lhs.string == rhs.string
}
Expand Down

0 comments on commit dfad736

Please sign in to comment.