Search code examples
xcodeswiftdocumentation-generation

Auto-generate documentation templates for Swift code in XCode 7.2


Is it possible to auto-generate a documentation template for a given method in XCode?

Example of a documentation template:

///  
/// - parameter x: 
/// - parameter y: 
/// - parameter w: 
/// - parameter d: 
/// - returns: T

Corresponding to this method:

func subface(x: CGFloat, y: CGFloat, w: CGFloat, d: Int) -> UIImage{
    // ...
}

Solution

  • Add VVDocumenter-Xcode via Alcatraz Package Manager.

    this is an example after writing /// above the function definition.

         /**
         <#Description#>
    
         - parameter x: <#x description#>
         - parameter y: <#y description#>
         - parameter w: <#w description#>
         - parameter d: <#d description#>
    
         - returns: <#return value description#>
         */
        func subface(x: CGFloat, y: CGFloat, w: CGFloat, d: Int) -> UIImage{
           /*...*/
        }
    

    The <# .. > marked sections are editable with just tapping over them.