SwiftMarkup

CI Documentation

SwiftMarkup 将文档注释中的 Swift Markup 解析为结构化的文档实体。

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?.description // "Creates a new bicycle with the provided parts and specifications."

documentation.discussionParts.count // 2

if case .callout(let remark) = documentation.discussionParts[0] {
    _ = remark.content // "Satisfaction guaranteed\\!"
}

if case .paragraph(let paragraph) = documentation.discussionParts[1] {
    _ = paragraph.description // "The word *bicycle* first appeared in English print in 1868 [ ... ]"
}

documentation.parameters[0].name // "style"
documentation.parameters[0]?.content.description // "The style of the bicycle"

documentation.returns?.description // A beautiful, brand-new bicycle, custom-built just for you.

此包被 swift-doc 使用,并与 CommonMarkSwiftSemantics 协同工作,以生成 Swift 项目的文档。

要求

安装

Swift 包管理器

在您的 Package.swift 文件中,将 SwiftMarkup 包添加到您的目标依赖项中

import PackageDescription

let package = Package(
  name: "YourProject",
  dependencies: [
    .package(
        url: "https://github.com/SwiftDocOrg/SwiftMarkup",
        from: "0.3.0"
    ),
  ]
)

然后运行 swift build 命令来构建您的项目。

许可

MIT

联系方式

Mattt (@mattt)