Поиск…


Документация класса

Вот пример документации по базовому классу:

/// Class description
class Student {

    // Member description
    var name: String
    
    /// Method description
    ///
    /// - parameter content:   parameter description
    ///
    /// - returns: return value description
    func say(content: String) -> Bool {
        print("\(self.name) say \(content)")
        return true
    }
}

Обратите внимание, что с помощью Xcode 8 вы можете сгенерировать фрагмент документации с помощью команды + option + / .

Это вернет: введите описание изображения здесь

Стили документации

/**
 Adds user to the list of poople which are assigned the tasks.
 
 - Parameter name: The name to add
 - Returns: A boolean value (true/false) to tell if user is added successfully to the people list.
*/
func addMeToList(name: String) -> Bool {
    
    // Do something....
    
    
    return true
}

введите описание изображения здесь

/// This is a single line comment
func singleLineComment() {
    
}

введите описание изображения здесь

/**
 Repeats a string `times` times.
 
 - Parameter str:   The string to repeat.
 - Parameter times: The number of times to repeat `str`.
 
 - Throws: `MyError.InvalidTimes` if the `times` parameter
 is less than zero.
 
 - Returns: A new string with `str` repeated `times` times.
*/
func repeatString(str: String, times: Int) throws -> String {
    guard times >= 0 else { throw MyError.invalidTimes }
    return "Hello, world"
}

введите описание изображения здесь

/**
 # Lists
 
 You can apply *italic*, **bold**, or `code` inline styles.
 
 ## Unordered Lists
 - Lists are great,
 - but perhaps don't nest
 - Sub-list formatting
 - isn't the best.
 
 ## Ordered Lists
 1. Ordered lists, too
 2. for things that are sorted;
 3. Arabic numerals
 4. are the only kind supported.
*/
func complexDocumentation() {
    
}

введите описание изображения здесь

/**
 Frame and construction style.
 
 - Road: For streets or trails.
 - Touring: For long journeys.
 - Cruiser: For casual trips around town.
 - Hybrid: For general-purpose transportation.
*/
enum Style {
    case Road, Touring, Cruiser, Hybrid
}

введите описание изображения здесь



Modified text is an extract of the original Stack Overflow Documentation
Лицензировано согласно CC BY-SA 3.0
Не связан с Stack Overflow