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

Links to same-page section that start with "#" fail. #632

Closed
2 tasks done
d-ronnqvist opened this issue Jun 16, 2023 · 4 comments · Fixed by #652
Closed
2 tasks done

Links to same-page section that start with "#" fail. #632

d-ronnqvist opened this issue Jun 16, 2023 · 4 comments · Fixed by #652
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@d-ronnqvist
Copy link
Contributor

Description

It's possible to link to headings (although not topic sections, but that's unrelated) by adding a # and a heading name to the documentation link. For example, <doc:ArticleName#HeadingName>.

For links to headings on the same page it's possible to omit the article name (or symbol name) and only write <doc:HeadingName>. However, adding the leading # causes the link to fail <doc:#HeadingName>.

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

Both <doc:HeadingName> and <doc:#HeadingName> should link work for linking to a heading on the current page.

Actual behavior

<doc:#HeadingName> result in an error about "" (empty string) not being found at the current page.

Steps To Reproduce

In a project with a documentation catalog; add an article with some heading and write a link to that heading on the same page. For example

# Some article

An article with a heading that it also links to: <doc:#Something>

## Something

Swift-DocC Version Information

5.9

Swift Compiler Version Information

swift-driver version: 1.85 Apple Swift version 5.9 (swiftlang-5.9.0.118.1 clang-1500.0.32.1)
Target: arm64-apple-macosx14.0
@d-ronnqvist d-ronnqvist added bug Something isn't working good first issue Good for newcomers labels Jun 16, 2023
@d-ronnqvist
Copy link
Contributor Author

This is probably a good first issue for anyone wanting to familiarize themselves with how DocC resolves documentation links.

The issue probably exist in static PathHierarchy.parse(path:omittingEmptyComponents:) or in how the parsed path is used.

Don't hesitate to ping me if you want to work on this and have any questions.

@natikgadzhi
Copy link
Contributor

natikgadzhi commented Jun 27, 2023

@d-ronnqvist, I'm just getting started around here, but I would love to work on this. Expect some rough draft on Wednesday night PST.

UPD: Yikes! I'm hooked and I'm looking, but grasping the code took longer than I expected. I'll read through the code for a bit more, walk through / debug it, and submit a rough draft.

@d-ronnqvist
Copy link
Contributor Author

Feel free to ask questions if you’re wondering how something works or why something is done the way it is.

@natikgadzhi
Copy link
Contributor

Got it to work, but I'm not entirely sure about side effects. I'll make a pull request for this, and another one with a little documentation addition, and ask a bunch of questions. Huge thank you for being so supportive of beginners! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants