Skip to content

Commit

Permalink
Add support for DocC Markdown links.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhx committed Apr 28, 2024
1 parent 255e20f commit dda6030
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Sources/libgir2swift/emitting/gtk2swiftdoc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ fileprivate enum State: Equatable {
case backtickedIdentifier
/// inside an `@` or `#` symbol to be converted for DocC
case docCSymbol
/// Inside a markdown link (e.g. to an external http/https page).
case link
/// inside a list of function arguments
case functionArguments
/// at the beginning of a language block to be quoted
Expand Down Expand Up @@ -106,6 +108,10 @@ public func gtkDoc2SwiftDoc(for thing: GIR.Thing, _ gtkDoc: String, linePrefix:
state = .docCSymbol
case "(":
let previous = gtkDoc[p]
if previous == "]" {
state = .link
continue
}
guard previous == "_" || previous.isLetter || previous.isNumber else {
flush() ; continue
}
Expand Down Expand Up @@ -185,6 +191,10 @@ public func gtkDoc2SwiftDoc(for thing: GIR.Thing, _ gtkDoc: String, linePrefix:
output.append("`")
state = .passThrough
continue
case .link:
guard c == ")" else { break }
flush()
state = .passThrough
case .quotedLanguagePreamble:
guard !c.isWhitespace else { break }
guard c == "<" && j < e && gtkDoc[j] == "!" else {
Expand Down

0 comments on commit dda6030

Please sign in to comment.