diff --git a/Changelog.md b/Changelog.md index 4d0e6f2d..6eb23c35 100644 --- a/Changelog.md +++ b/Changelog.md @@ -11,8 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for generating documentation for private symbols. - #266 by @Lukas-Stuehrk - + #266 by @Lukas-Stuehrk. +- Added anchor links to documentation entries for symbols. + #275 by @Lukas-Stuehrk. + ### Fixed - Fixed bug that caused prefix and postfix operators to be omitted diff --git a/Sources/swift-doc/Supporting Types/Components/Members.swift b/Sources/swift-doc/Supporting Types/Components/Members.swift index 95835687..f3aa003a 100644 --- a/Sources/swift-doc/Supporting Types/Components/Members.swift +++ b/Sources/swift-doc/Supporting Types/Components/Members.swift @@ -102,11 +102,12 @@ struct Members: Component { \#(section.members.map { member -> HypertextLiteral.HTML in let descriptor = String(describing: type(of: member.api)).lowercased() + let id = member.id.description.lowercased().replacingOccurrences(of: " ", with: "-") return #""" -
+

- \#(softbreak(member.name)) + \#(softbreak(member.name))

\#(Documentation(for: member, in: module, baseURL: baseURL).html)
diff --git a/Sources/swift-doc/Supporting Types/Components/OperatorImplementations.swift b/Sources/swift-doc/Supporting Types/Components/OperatorImplementations.swift index f28fa761..124acbf4 100644 --- a/Sources/swift-doc/Supporting Types/Components/OperatorImplementations.swift +++ b/Sources/swift-doc/Supporting Types/Components/OperatorImplementations.swift @@ -69,11 +69,13 @@ struct OperatorImplementations: Component { heading = [operand.type, function.name].compactMap { $0 }.joined(separator: " ") } + let id = implementation.id.description.lowercased().replacingOccurrences(of: " ", with: "-") + return #""" -
+

- \#(heading) - \#(unsafeUnescaped: function.genericWhereClause.map({ #"\#($0.escaped)"# }) ?? "") + \#(heading) + \#(unsafeUnescaped: function.genericWhereClause.map({ #"\#($0.escaped)"# }) ?? "")

\#(Documentation(for: implementation, in: module, baseURL: baseURL).html)
diff --git a/Sources/swift-doc/Supporting Types/Pages/ExternalTypePage.swift b/Sources/swift-doc/Supporting Types/Pages/ExternalTypePage.swift index febc3598..dd706669 100644 --- a/Sources/swift-doc/Supporting Types/Pages/ExternalTypePage.swift +++ b/Sources/swift-doc/Supporting Types/Pages/ExternalTypePage.swift @@ -70,10 +70,12 @@ struct ExternalTypePage: Page { \#(section.members.map { member -> HypertextLiteral.HTML in let descriptor = String(describing: type(of: member.api)).lowercased() + let id = member.id.description.lowercased().replacingOccurrences(of: " ", with: "-") + return #""" -
+

- \#(softbreak(member.name)) + \#(softbreak(member.name))

\#(Documentation(for: member, in: module, baseURL: baseURL).html)