-
Notifications
You must be signed in to change notification settings - Fork 143
Anchors to topics sub-sections #504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I realize that the feature is available on Apple documentation. Example: https://developer.apple.com/documentation/swift/array#splitting-and-joining-elements There is even a 🔗 icon next to the title! Oh I'm so jealous 🤤 Is this feature available to all DocC users? cc @finestructure |
Thanks for the ping, @groue ! I’ve noticed some oddities around anchors as well. I initially thought this wasn’t working but then it started working for one of our own package’s doc when I retested it. I had an issue open at the time: SwiftPackageIndex/SwiftPackageIndex-Server#2091 This here is the doc set: https://swiftpackageindex.com/SwiftPackageIndex/SPIManifest/0.15.0/documentation/spimanifest Clicking on the “Common Use Cases” links gets you “mostly” to the anchor. I say mostly, because while there’s a scrolling offset to bring the topic in view it isn’t top aligned except for the first one in my testing. I can’t make sense of why this is working (sort of) in some cases but not in others 🤔 |
Hi @finestructure, I hope you're doing well :-)
I'm not sure this is the same issue. The "Common Use Cases" is not a
The "regular" sections are already handled by DocC: you can write <h3 id="Common-Use-Cases">Common Use Cases</h3> However, sub-topics sections are not handled by DocC (at least, not in Xcode 14.2). And the rendered HTML does not contain any anchored element (at least , not on the SPI-hosted docs): <h3 data-v-627ab5f4="" class="title">Querying the Database Schema</h3> |
I've recently seen a lot of regressions regarding anchors in Safari: scroll never happens, or is delayed (sometimes by several seconds), or the page content has a wrong scroll offset (maybe due to a wrong synchronization between the scroll and the layout of the content above the anchor). I still don't know if those are actual Safari regressions, or badly coded websites that hijack anchor handling. Anchors in GitHub rendered documents, for example, work flawlessly in Chrome (perfect and fast scroll to the expected page region) but are very flaky on Safari 😒 EDIT: how does one removes the navigation sidebar in GitHub? I'm wondering if it isn't the culprit: |
Anchor icons are there with Xcode 14.3, and on the documentation generated and hosted on http://swiftpackageindex.com. |
Oh, but the issue was about writing links to sub-sections of the |
When I worked on #632, there's clearly a way to tell the documentation site itself to link to a subheading. So it stands to reason that it knows how to make a link to a subheading. I wonder if |
I believe I'm hitting this issue as well… I've created a documentation extension for a particular type and used it to arrange the methods and properties into related sections. These get rendered as an The docc plugin produces a warning:
|
Uh oh!
There was an error while loading. Please reload this page.
Feature Name
Anchors to topics sub-sections
Description
The feature is the ability to embed a direct link to a topics sub-section from any web page, with an URL anchor.
For example, given the documentation structure below, this feature enables a direct link to the "My Section" section with the
#My-Section
anchor:For a practical example: the "Querying the Database Schema" section of this DocC page would be addressable with the
#Querying-the-Database-Schema
anchor.Currently the link "does not work", i.e. the browser does not scroll down to the section: https://swiftpackageindex.com/groue/grdb.swift/v6.9.0/documentation/grdb/databaseschema#Querying-the-Database-Schema
Motivation
The motivation is that one needs to link to a specific part of the documentation, the one that precisely discusses a given topic.
One may need such a link when writing doc that links to other parts of the doc, but also when answering questions, issues, etc. Both use cases exist in the GRDB library, where there exist GitHub-rendered Markdown documents that link to DocC-generated HTML pages hosted on the Swift Package Index, as well as GitHub issues and discussions where I need to give links to users.
Even better, it would be possible to guarantee the stability of those anchors, even if the title of the section is eventually modified (probably addressed by #345).
Importance
"Inner-linkability" is an important feature, yes.
Alternatives Considered
No response
The text was updated successfully, but these errors were encountered: