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

Symbol hyperlinks #18

Open
temportalflux opened this issue Feb 19, 2022 · 5 comments
Open

Symbol hyperlinks #18

temportalflux opened this issue Feb 19, 2022 · 5 comments

Comments

@temportalflux
Copy link

temportalflux commented Feb 19, 2022

Mermaid has support for interactions on flow-chart nodes and rustdocs can generate links to items by name. I'd be very helpful to be able to use both of these concepts and allow crate users to add links to nodes in mermaid syntax utilizing rustdocs item linkage syntax.
Something like:

graph TD
  Item1["[Shown Text](rustdocs::symbol::path)"]

which would show something like

graph TD
	Item1[Shown Text]
Loading

but where Shown Text is also a hyperlink to wherever the rustdocs hyperlink for rustdocs::symbol::path leads.

This WOULD require specifying securityLevel:'loose' in the mermaid config.

@mersinvald
Copy link
Owner

mersinvald commented Feb 20, 2022

@temportalflux do you think it would be sufficient to set securityLevel: loose as a default, under a hyperlinks feature gate?

I don't want to make it a universal default, partly because it's a breaking change, and also because it is a security issue that I'm not qualified to assess, to be completely honest.

@temportalflux
Copy link
Author

temportalflux commented Feb 21, 2022

Yeah I think exposing that option would be fine, though I suspect it would only get integration halfway there. Since mermaid seems to want full url links, there would need to be some mechanism, enabled by a hyperlinks flag, that converts rustdoc links in a mermaid block into true urls. Perhaps a preprocessor that asks rustdoc to return a hyper link given some rustdoc sybtax that aquamarine detects inside a mermaid-code-block.

@mersinvald
Copy link
Owner

I'll see if I can find some heuristic to do that, but it it's something that requires getting information from rustdoc, then we're pretty much out of luck

@temportalflux
Copy link
Author

temportalflux commented Feb 24, 2022

It looks like resolving hyperlinks via rustdoc might be viable? I just happened upon this tutorial today which seems to do something similar via some unstable/nightly functionality in rustdoc. https://scrabsha.github.io/abcr-issue-0/#the-basic-idea
https://doc.rust-lang.org/rustdoc/unstable-features.html#-w--output-format-output-format

@frehberg
Copy link
Collaborator

Maybe this code snippet might be used to implement some kind of intelligent callback function to redirect to the API doc https://stackoverflow.com/a/73733645

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

No branches or pull requests

3 participants