Skip to content
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

Allow #//apple_ref/… links to expand docs too #1167

Merged
merged 5 commits into from
Apr 2, 2020

Conversation

pcantrell
Copy link
Collaborator

Currently Jazzy generates <a name=…> tags for both USR-style anchors and Dash-style apple_ref anchors:

<a name="/s:6Siesta8ResourceC4loadAA7Request_pyF"></a>
<a name="//apple_ref/swift/Method/load()" class="dashAnchor"></a>
<a class="token token-open" href="#/s:6Siesta8ResourceC4loadAA7Request_pyF">load()</a>

The apple_ref anchors have several advantages: they are human-readable, generally make for shorter links, and (most importantly) are less prone to changes between doc generation cycles and thus make for more stable long-term links from e.g. other documentation.

However, they have a shortcoming in Jazzy: a link of the form Foo.html#//apple_ref/swift/Method/load() currently scrolls to the correct item, but does not expand it.

This PR also expands the item when thus linked, just as Foo.html#/s:6Siesta8ResourceC4loadAA7Request_pyF would.

@pcantrell
Copy link
Collaborator Author

Also, Jazzy should consider symlinking the js files that are identical across the 3 themes instead of copying them.

@johnfairh
Copy link
Collaborator

Thanks for this -- when I try it though I can see that the apple_ref links work nicely but the USR ones don't any more, maybe because the next('.token') business doesn't go anywhere if the a[... element actually is the .token?

OK from me to merge this with a fix for that and a changelog update. (I don't know why circle hasn't rebuilt this after your specs update...)

Derp!
next = immediate sibling
nextAll = all following siblings
@pcantrell
Copy link
Collaborator Author

Ah, indeed, it turns out that I was looking for nextAll() instead of next(). Good catch!

It’s also apparently possible to do this all in one selector:

$(`a[name="${location.hash.substring(1)}”] ~ .token`)

…but that seems to me too clever by half.

@johnfairh
Copy link
Collaborator

Great, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants