-
Notifications
You must be signed in to change notification settings - Fork 134
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: Alternative equivalent syntaxes for hyperlinks #70
Comments
The quick answer is that the TSDoc parser library does not yet support Markdown links at all. Probably it would be counterintuitive not to, however I would hesitate to mix declaration references into this requirement, because the CommonMark link destination is already a pretty complex structure (see below).
It's important to recognize that Markdown takes an exact opposite "everything but the kitchen sink" philosophy: Even strict CommonMark will accept all sorts of obscure notations that rarely occur in the wild. I spent a lot of time thinking about this difference of philosophy, and will probably include a small essay about it in the TSDoc spec document. :-) But basically I believe Markdown's design is optimized for fairly different requirements: It doesn't need to be interoperable (i.e. a Markdown scanner can usually assume that it's the only tool that needs to process an input, which is why its extensions can get away with having proprietary grammars). It also doesn't need to be predictable (i.e. we can assume an interactive editor will render the result in realtime). Whereas TSDoc clearly needs to be interoperable and predictable to be successful. So the way TSDoc is framed today, people would expect three different ways of making a link: JSDoc styleThe notation I'm working on supporting in my current PR:
...but not the other redundant JSDoc notations that I've been trying to avoid incorporating:
HTML styleJust like CommonMark, TSDoc allows HTML tags and will also support HTML character references as an escaping mechanism.
It would be reasonable to support declaration references, in which case I would suggest a custom tag such as
CommonMark styleOkay, strap in folks... Let's now take a look at the hyperlink notations that a strict CommonMark parser would accept:
The CommonMark spec doesn't say very much about the link destination itself except that it is a "URI." The spec makes it clear that all sorts of relative URIs are supported, e.g. Whereas so far with TSDoc we have been assuming that ConclusionIt seems that TSDoc must support some form of By contrast, Markdown links bring along a lot of complexity, but without contributing any new capabilities. So I'm somewhat undecided to what extent we want to pursue that. What do people think? |
@pgonzal It would be great to be able to specify a Markdown link using the most frequently used Markdown practices:
I agree with the "one obvious way" approach from Python. Looking at the reality, in many open source projects, the software developer will be writing the docstrings. To encourage documentation of code, it's helpful to have syntax that devs are familiar with from GitHub: markdown. It would be great for TSDoc to be able to support something like:
which is familiar and easy to type and let developers decide whether to use vanilla JSDoc {@link} or |
@willingc I have some questions about this: If you specify Do you expect the Markdown-style URL to support declaration references? For example, TSDoc allows something like this: /**
* {@link @scope/package/path1/path2#core.MyClass.("constructor":static) | some link text}
*/ So would your Markdown notation need to support something like this? /**
* [some link text](@scope/package/path1/path2#core.MyClass.("constructor":static))
*/ |
A simple and intuitive way to integrate Markdown links and TSDoc links: This method is part of the [Statistics subsystem]({@link core-library#Statistics}). The regular TSDoc equivilent (taken from the README):
Justification:
|
The syntax @vassudanagunta proposes looks clean and readable and TSDoc should support this 👍 . It makes more sense to name the thing first and then provide the link implementation in quotes. |
@brandonkal Thank you.
You mean "in the link destination parenthesis" right? I just now clarified my reasoning in the first justification point I gave. |
@vassudanagunta Yes, I mean the destination. |
In a separate issue @yume-chan asked:
Let's discuss this as a separate issue, since it's unrelated to the declaration references topic.
The text was updated successfully, but these errors were encountered: