-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Relative link syntax for rustdoc #1661
Conversation
Nice RFC, I've wanted that feature for a long time. But like you mention in Drawbacks, this is a temporary fix. I don't like RFCs as temporary fixes. Before adding band-aids, we should rather see how much needs to be done to refactor the necessary tools (rustdoc, in this case) and when the final CommonMark extension proposal is expected. Our RFCs usually have a few month of lifetime before being deployed :) For me, this is not enough of an improvement: The [`Ord`] trait is the grooviest trait there is!
[`Ord`]: ::/std/cmp/trait.Ord.html We should aim for something like The <std::cmp::Ord> trait is the grooviest trait there is! And actually, if we were to specify a URI schema for rust items, we could introduce something like FYI, there has been talk about switching from Hoedown to the pulldown-cmark crate. |
…and the markdown dialect begins to diverge. we’ll end up with somthing that resembles, but isn’t markdown. i predicted that and proposed solving it properly by switching to ASCIIdoc or rST, but nobody listened 😢 |
My take on this is that it's not changing the markdown dialect, it's just adding a post-processing phase to links. It's closer to code pretty printing than something like a new table syntax. |
Context on that: rust-lang/rust#29329 Context on more sweeping markup changes: https://internals.rust-lang.org/t/rustdoc-restructuredtext-vs-markdown |
as i’ve said from the first minute rustdoc was announced: we want a naturally extensible markup format, NOT markdown. what @killercup wants is e.g. trivially possible with rST’s text roles. |
I think discussing the entire markup format used by |
yes, but this RFC is a symptom of the problem i outlined. @killercup’s idea on what more he wants to have further underlines this problem, as it is even more custom syntax. AFAIK this is the first proposed markdown extension. i say we leave this can of worms closed. |
I’ll join other comments in preferring proper cross-referencing (whatever the syntax, even abusing links with something like But if we go with hacks on HTTP(S) URLs, we could have rustdoc rewrite "host-relative" ones (those that start with a single |
@flying-sheep Kinda feeling your frustration, especially when rST was specifically invented to handle Python documentation. That said, can you link to your RFC? Recommend read: Common markup for Markdown and reStructuredText |
Quoting @gankro:
|
I'll take a stab at designing out the First, what do we do when someone runs Second, we'll still need syntax for non-items. Fragments are probably easy, just use |
I like that idea. It transforms what would today be allowed, naive, and wrong into slightly surprising but correct. Folks who thumbs-up'ed @SimonSapin 's comment would you mind voting here if this was an idea you liked? It's not clear which of the two ideas you were nodding at. |
I'd like to see the "rust:" URL scheme as well. This would avoid introducing an extension to markdown, and would allow the use of standard Rust syntax (e.g. That would also make inline links like rust:std::io::stdout easier. |
there is none, due to @gankro’s reply quoted by @louy2. i figured that i need them to at least tell me that the idea has a chance. but @louy2 you forgot to also quote my reply, which IMHO invalidates @gankro’s point:
|
Here are my priorities here:
As such, I'm 👎 on the RFC as written, as it violates 1, and arguably 2. (It's not an improvement on 3, but it's also not worse than the status quo.) The URL idea helps mitigate 1, helps a lot with 3, and isn't bad on 2. But it does mean that some sort of post-processing tool needs to happen to convert our URL scheme into HTTP URLs, which is kind of a violation of the spirit of 1, if not the rule. Historically, my position has been "Let's wait until CommonMark has an extensibility mechanism, and then use it," but it does seem like that might still take some time, and I'm very sympathetic to the pain here today. If we want people to write docs, we need to make it easy; that was the whole reason for Markdown in the first place! I've posted on the commonmark forums to see what they recommend. |
I feel like adopting anything that’s not as good as rST’s text roles will dig us into a hole we cannot get out from. xrefs are probably the most obvious thing that does not fit well to Markdown that would be easily solved by roles. We avoided problem of deprecated/stable/unstable annotation by having language features for them, however that only covers a very limited set of annotations and you cannot annotate different things this way (e.g. version in which the API gets removed). I feel like many more cases will crop up over time for which we won’t have any solution if we adopt anything less than fully extensible version of markdown (i.e. the That being said xreferencing is important and thus what I’d propose is to add support for the |
In this discussion we're ignore non-type relative links like book links. If we're happy saying either "use absolute links for them", or "don't link to them from re-namespaced types", or even "there's not enough to care", then that's fine. Otherwise, it's a corner of the problem that needs a little help even if we solve type linking perfectly. |
That is also something that is sufficiently solved by either using a new URI schema ( |
Maybe that is what this RFC should be narrowed to focus on. Step 1: Design and implement a link That makes the pessimistic assumption that Step 3 is going to take a while. If it looks like there's a smooth path towards true cross-links available to us today, then we can skip the abuse in Step 2. To make my position clear since I'm pushing back a bit: I love the idea of true type links, and I'm happy to spend time making them happen, but there's a pragmatic path to get some nice doc improvements out to rust users that doesn't need to wait. |
How about auto-generating links to all items in module scope (which is what the commonmark people suggest, incidentially)? Admittedly, that list would become rather long & we'd need to weed out things that were already linked manually, but if |
@llogiq That's a nice idea. |
If we used pulldown-cmarks, we could simply prepopulate the |
@steveklabnik given that the current system for linking is "know rustdoc's URL structure by heart" your point 3 means we really do need some system for this. |
To address the "don't fragment the markdown ecosystem": If we want to make a AKA do what intersphinx does for Python/rST. |
crates.fyi is making progress on this. |
Well, the easiest, for doc authors, would automatic linking like doxygen does, i.e. every word followed by Would that be a special syntax to you to conflict with the first point or not? Whatever is done will be specific to rustdoc anyway. So the point is just to make it not conflict with future improvements to commonmark.
I would, perhaps, argue the later makes more sense, because that's how linking to arbitrary targets works in generic commonmark. Either way, one of those, or fully automated linking like doxygen does, should clearly clearly the goal. Advantage of explicit request with
… or adding a callback function. In any case lazy seems better option. Not all code |
@jan-hudec I think commonmark prefers [..] to ≪..> The latter also risks clashes with valid HTML, which creates ambiguities. Apart from that, I fully agree that using lazy lookup would be preferable. |
I'm roughly behind the suggestion of having Rust URLs to handle cross-referencing. However, then adding further custom URLs for the book (and presumable other resource in the future) makes me nervous. Could someone explain in more detail how the suggestion for auto-generating a link for every item would work? I'm not sure I understand the implications nor how it differs from other proposals. I think a pre- or post-processing step for URLs on top of markdown processing is totally fine and seems like a minimally invasive way to extend it to our needs until a proper extensibility mechanism is added. It also makes automatically changing to a new system in the future fairly easy (c.f., adding our own extensions to Markdown). I'd like to see a proper RFC or pre-RFC or whatever for Rust URLs, there are a number of issues that are not trivial to decide upon:
However, I would like to see this, currently Rustdoc URLs are a hell-ish mess. Finally, is there consensus that the motivation for this RFC is best addressed in other ways or are some still in favour of the current proposal? |
Markdown handles a "reference" style of links, written like this: Note that Markdown does not treat those reference names as case-sensitive, so if you have both The other alternative would be to write Either syntax eliminates the |
What's the best way to float a pre-RFC? A post to internals.rust-lang.org? |
@JohnHeitmann yes. Or an issue on this repo (seems to be a bit hit and miss which gets better visibility/discussion). |
@JohnHeitmann and @llogiq I was talking specifically about URLs, if there is enough discussion in that discuss thread, then going straight to RFC would be fine, but it might be worth discussing some of the finer points about URLs ahead of time. |
@nrc Let's postpone or close this RFC. I think there will be a few narrow problems left behind by I'm working on two things in parallel: an RFC for rust links that take the bigger steps everyone is pushing for in this feedback, and a prototype to validate that I'm not missing novice problems. I'll re-start discussion for that new RFC at internals.rust-lang.org on ~Friday once I've gotten far enough prototyping to make sure I'm not going to embarrass myself with glaring design holes. If you want I can overwrite this RFC, but I'd slightly prefer to start fresh. |
@JohnHeitmann sounds good. I've been doing some refactoring to Rustfmt to make the existing URLs better, sounds like we might overlap somewhat? Could you ping me on irc so we can discuss our plans? |
I would also like to point out that the markdown thread has a fantastic response posted to it. On Jul 6, 2016, 15:54 -0400, Nick [email protected], wrote:
|
Something like this (particularly the former) seems right to me. Personally, I always anticipated we would need to extend markdown like this for our own purposes. |
The tools team discussed this recently and we concluded to close in line with @JohnHeitmann's comment. @JohnHeitmann if you need any help starting a new RFC though @nrc is more than willing to help, so feel free to reach out to him (or me)! |
What is the status of the replacement RFC? The deficiencies in the current linking system are currently my biggest pain point when writing docs. |
I'm not the most qualified but if a replacement RFC isn't in the works then I'm happy to take a crack at it. |
Rendered
RFC Summary
The short version is that instead of this:
we should be able to write this:
Feedback Summary (through July 3)
rust:std::cmp::Ord
has a lot of support.