Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Expose deeplinks. (#275)
Browse files Browse the repository at this point in the history
* Expose deeplinks.

* Add changelog entry for #275

Co-authored-by: Mattt <[email protected]>
  • Loading branch information
Lukas-Stuehrk and mattt authored May 18, 2021
1 parent 4491f5b commit cc45688
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
6 changes: 4 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Sources/swift-doc/Supporting Types/Components/Members.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 #"""
<div role="article" class="\#(descriptor)" id=\#(member.id.description.lowercased().replacingOccurrences(of: " ", with: "-"))>
<div role="article" class="\#(descriptor)" id=\#(id)>
<h3>
<code>\#(softbreak(member.name))</code>
<code><a href=\#("#\(id)")>\#(softbreak(member.name))</a></code>
</h3>
\#(Documentation(for: member, in: module, baseURL: baseURL).html)
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 #"""
<div role="article" class="function" id=\#(implementation.id.description.lowercased().replacingOccurrences(of: " ", with: "-"))>
<div role="article" class="function" id=\#(id)>
<h3>
\#(heading)
\#(unsafeUnescaped: function.genericWhereClause.map({ #"<small>\#($0.escaped)</small>"# }) ?? "")
<a href=\#("#\(id)")>\#(heading)
\#(unsafeUnescaped: function.genericWhereClause.map({ #"<small>\#($0.escaped)</small>"# }) ?? "")</a>
</h3>
\#(Documentation(for: implementation, in: module, baseURL: baseURL).html)
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 #"""
<div role="article" class="\#(descriptor)" id=\#(member.id.description.lowercased().replacingOccurrences(of: " ", with: "-"))>
<div role="article" class="\#(descriptor)" id=\#(id)>
<h3>
<code>\#(softbreak(member.name))</code>
<code><a href=\#("#\(id)")>\#(softbreak(member.name))</a></code>
</h3>
\#(Documentation(for: member, in: module, baseURL: baseURL).html)
</div>
Expand Down

0 comments on commit cc45688

Please sign in to comment.