SwiftMarkup parses Swift Markup from documentation comments into structured documentation entities.
import SwiftMarkup let markdown = #""" Creates a new bicycle with the provided parts and specifications. - Remark: Satisfaction guaranteed! The word *bicycle* first appeared in English print in 1868 to describe "Bysicles and trysicles" on the "Champs Elysées and Bois de Boulogne". - Parameters: - style: The style of the bicycle - gearing: The gearing of the bicycle - handlebar: The handlebar of the bicycle - frameSize: The frame size of the bicycle, in centimeters - Returns: A beautiful, brand-new bicycle, custom-built just for you. """# let documentation = try Documentation.parse(markdown) documentation.summary // "Creates a new bicycle with the provided parts and specifications." documentation.discussionParts.count // 2 let remark = documentation.discussionParts as! Callout remark.content // "Satisfaction guaranteed\\!" let paragraph = documentation.discussionParts as! String paragraph.content // "The word *bicycle* first appeared in English print in 1868 [ ... ]" documentation.parameters.name // "style" documentation.parameters.description // "The style of the bicycle" documentation.returns // A beautiful, brand-new bicycle, custom-built just for you.
- Swift 5.1+
Swift Package Manager
Add the SwiftMarkup package to your target dependencies in
import PackageDescription let package = Package( name: "YourProject", dependencies: [ .package( url: "https://github.com/SwiftDocOrg/SwiftMarkup", from: "0.0.4" ), ] )
Then run the
swift build command to build your project.