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

Expose deeplinks. #275

Merged
merged 2 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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