Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation comments #108

Merged
merged 3 commits into from
Nov 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions Sources/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public struct Generator: Equatable {

/// Initializes a new password generator with the given parameters.
///
/// - parameter factor: The moving factor
/// - parameter secret: The shared secret
/// - parameter algorithm: The cryptographic hash function
/// - parameter digits: The number of digits in the password
/// - parameter factor: The moving factor.
/// - parameter secret: The shared secret.
/// - parameter algorithm: The cryptographic hash function.
/// - parameter digits: The number of digits in the password.
///
/// - returns: A new password generator with the given parameters, or `nil` if the parameters
/// are invalid.
Expand Down Expand Up @@ -164,13 +164,13 @@ public struct Generator: Equatable {
}

/// A cryptographic hash function used to calculate the HMAC from which a password is derived.
/// The supported algorithms are SHA-1, SHA-256, and SHA-512
/// The supported algorithms are SHA-1, SHA-256, and SHA-512.
public enum Algorithm: Equatable {
/// The SHA-1 hash function
/// The SHA-1 hash function.
case SHA1
/// The SHA-256 hash function
/// The SHA-256 hash function.
case SHA256
/// The SHA-512 hash function
/// The SHA-512 hash function.
case SHA512
}

Expand All @@ -179,7 +179,7 @@ public struct Generator: Equatable {
public enum Error: ErrorType {
/// The requested time is before the epoch date.
case InvalidTime
/// The timer period is not a positive number of seconds
/// The timer period is not a positive number of seconds.
case InvalidPeriod
/// The number of digits is either too short to be secure, or too long to compute.
case InvalidDigits
Expand Down Expand Up @@ -244,6 +244,11 @@ private extension Generator {

private extension String {
/// Prepends the given character to the beginning of `self` until it matches the given length.
///
/// - parameter character: The padding character.
/// - parameter length: The desired length of the padded string.
///
/// - returns: A new string padded to the given length.
func paddedWithCharacter(character: Character, toLength length: Int) -> String {
let paddingCount = length - characters.count
guard paddingCount > 0 else { return self }
Expand Down
2 changes: 1 addition & 1 deletion Sources/Keychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class Keychain {

/// Finds the persistent token with the given identifer, if one exists.
///
/// - parameter token: The persistent identifier for the desired token.
/// - parameter identifier: The persistent identifier for the desired token.
///
/// - throws: A `Keychain.Error` if an error occurred.
/// - returns: The persistent token, or `nil` if no token matched the given identifier.
Expand Down
6 changes: 3 additions & 3 deletions Sources/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public struct Token: Equatable {

/// Initializes a new token with the given parameters.
///
/// - parameter name: The account name for the token (defaults to "")
/// - parameter issuer: The entity which issued the token (defaults to "")
/// - parameter generator: The password generator
/// - parameter name: The account name for the token (defaults to "").
/// - parameter issuer: The entity which issued the token (defaults to "").
/// - parameter generator: The password generator.
///
/// - returns: A new token with the given parameters.
public init(name: String = defaultName, issuer: String = defaultIssuer, generator: Generator) {
Expand Down