Skip to content

Commit

Permalink
Improve DocC
Browse files Browse the repository at this point in the history
  • Loading branch information
fpseverino committed Aug 19, 2024
1 parent f59dbc0 commit 29f4c1d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Use the SPM string to easily include the dependendency in your `Package.swift` f

### Quick functions

The easiest way to use Zip is through quick functions. Both take local file paths as NSURLs, throw if an error is encountered and return an NSURL to the destination if successful.
The easiest way to use Zip is through quick functions. Both take local file paths as `URL`s, throw if an error is encountered and return an `URL` to the destination if successful.

```swift
import Zip
Expand All @@ -48,7 +48,7 @@ do {

### Advanced Zip

For more advanced usage, Zip has functions that let you set custom destination paths, work with password protected zips and use a progress handling closure. These functions throw if there is an error but don't return.
For more advanced usage, Zip has functions that let you set custom destination paths, work with password protected zips and use a progress handling closure. These functions throw if there is an error but don't return.

```swift
import Zip
Expand All @@ -71,7 +71,7 @@ do {

### Custom File Extensions

Zip supports '.zip' and '.cbz' files out of the box. To support additional zip-derivative file extensions:
Zip supports `.zip` and `.cbz` files out of the box. To support additional zip-derivative file extensions:

```swift
Zip.addCustomFileExtension("file-extension-here")
Expand Down
20 changes: 16 additions & 4 deletions Zip/ArchiveFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@
import Foundation
@_implementationOnly import Minizip

/// Data in memory that will be archived as a file.
/// Defines data saved in memory that will be archived as a file.
public struct ArchiveFile {
var filename: String
var data: Data
var modifiedTime: Date?

/// Creates an ``ArchiveFile`` instance.
///
/// - Parameters:
/// - filename: The name of the file represented by the data.
/// - data: The `Data` to be archived.
/// - modifiedTime: The last modification date of the file. Optional.
public init(filename: String, data: Data, modifiedTime: Date? = nil) {
self.filename = filename
self.data = data
self.modifiedTime = modifiedTime
}

/// Creates an ``ArchiveFile`` instance.
///
/// - Parameters:
/// - filename: The name of the file represented by the data.
/// - data: The `NSData` to be archived.
/// - modifiedTime: The last modification date of the file. Optional.
@available(*, deprecated, message: "Use the initializer that takes Foundation's `Data` instead.")
public init(filename: String, data: NSData, modifiedTime: Date? = nil) {
self.filename = filename
Expand All @@ -30,11 +42,11 @@ public struct ArchiveFile {

extension Zip {
/**
Zips data in memory.
Creates a zip file from an array of ``ArchiveFile``s

- Parameters:
- archiveFiles: Array of Archive Files.
- zipFilePath: Destination NSURL, should lead to a .zip filepath.
- archiveFiles: Array of ``ArchiveFile``.
- zipFilePath: Destination `URL`, should lead to a `.zip` filepath.
- password: Password string. Optional.
- compression: Compression strategy
- progress: A progress closure called after unzipping each file in the archive. Double value betweem 0 and 1.
Expand Down
20 changes: 10 additions & 10 deletions Zip/Zip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
@_implementationOnly import Minizip

/// Zip class
/// Main class that handles zipping and unzipping of files.
public class Zip {
/**
Set of vaild file extensions
Expand All @@ -27,11 +27,11 @@ public class Zip {
Unzips a file.

- Parameters:
- zipFilePath: Local file path of zipped file. NSURL.
- destination: Local file path to unzip to. NSURL.
- overwrite: Overwrite bool.
- zipFilePath: Local file path of zipped file.
- destination: Local file path to unzip to.
- overwrite: Overwrite `bool`.
- password: Optional password if file is protected.
- progress: A progress closure called after unzipping each file in the archive. Double value betweem 0 and 1.
- progress: A progress closure called after unzipping each file in the archive. `Double` value between 0 and 1.

- Throws: `ZipError.unzipFail` if unzipping fails or if fail is not found.

Expand Down Expand Up @@ -217,11 +217,11 @@ public class Zip {
Zips a group of files.

- Parameters:
- paths: Array of NSURL filepaths.
- zipFilePath: Destination NSURL, should lead to a .zip filepath.
- paths: Array of `URL` filepaths.
- zipFilePath: Destination `URL`, should lead to a `.zip` filepath.
- password: Password string. Optional.
- compression: Compression strategy
- progress: A progress closure called after unzipping each file in the archive. Double value betweem 0 and 1.
- progress: A progress closure called after unzipping each file in the archive. `Double` value between 0 and 1.

- Throws: `ZipError.zipFail` if zipping fails.

Expand Down Expand Up @@ -332,7 +332,7 @@ public class Zip {

- parameter fileExtension: A file extension.

- returns: false if the extension is a valid file extension, otherwise true.
- returns: `false` if the extension is a valid file extension, otherwise `true`.
*/
internal class func fileExtensionIsInvalid(_ fileExtension: String?) -> Bool {
guard let fileExtension = fileExtension else { return true }
Expand Down Expand Up @@ -360,7 +360,7 @@ public class Zip {
/**
Checks if a specific file extension is valid.

- Parameter fileExtension: A file extension.
- Parameter fileExtension: A file extension to check.

- Returns: `true` if the extension valid, otherwise `false`.
*/
Expand Down

0 comments on commit 29f4c1d

Please sign in to comment.