-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
[FEATURE] Introduce exchangeable InterlinkParser #791
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this improvement, just a minor request to improve the code a bit.
packages/guides-restructured-text/src/RestructuredText/Parser/InterlinkParser.php
Outdated
Show resolved
Hide resolved
Just sharing an idea I had with intersphinx: I think we should decouple it from the nodes. Intersphinx in Sphinx itself is purely handled in the reference resolver logic. This makes Then, TYPO3 can implement another reference resolver for your custom sign and composer links. By using reference resolver priorities, you can make sure that it's prioritized over other reference resolvers. I started working on this locally (I had it stashed away, that's why the commit is of today) in https://github.com/wouterj/guides/tree/intersphinx-decouple I remember I was fighting with the anchor reducer, I think it should be moved to the render stage somehow (I can also imagine we need a different anchor reducer rendering non-HTML, so it seems to be related more to the render phase I think). Just throwing the idea. If you like it, I'm happy to continue this work (or collaborate on it). But otherwise, I'll give up on the idea of decoupling Intersphinx :) Btw, this is related to this PR as it'll also centralize parsing the intersphinx reference to a single place (the intersphinx reference resolver). We might not need the intersphinx parser abstraction if we decide to go for this other way. |
The thing is the Anchor-Reducer is not nessesaryly related to rendering. It defines weather :ref: |
I would have to have a look at your implementation. However the issue with interlinks is that they can be applied to different kind of links that have different kind of resolvers. Therefore just putting them in one link resolver would not work for all cases. For example if you can also use interlinks to link to a php classs in a different manual with |
The other thing I am wondering: If we have a different Input formal like Markdown or latex or whatever. If we want to introduce interlinks there they might have a different format as the doublepoint syntax might collide with some other language features? So I would see the interlink parsing in the parser, not in the compiler (as the compiler works for all formats. And also it should do no parsing) |
This can work with another reference resolver that checks for a specific php class node. But indeed, this would introduce parsing the
Interesting, I hadn't thought about other input formats. At least in Markdown it can still work ( |
With the introduction of the centralized interlink parser in this PR you should still be able to exchange it according to your needs? |
Let me first explain what I had in mind, this is not how it is implemented currently, but it helps to understand the purpose of the elements we have and might also help you to understand why some steps are taken.
Back to this PR, the issue with interlinks is that any link can be an Visualized:
However we could turn it around:
It becomes more interesting because we have a second layer of deviation, which are domains. Right now domains are modeled as part of a LinkNode, which is not necessarily true. We could have introduced a new layer around the reference.
I think the advantage of having this modeled in objects is that resolvers and compiler passes can be more generic, a php domain reference is still a php reference, and when interlink is added it just tells that the intersphinx handler that it should to a lookup in the source of the interlinks. Next the phpresolver kicks in, which will resolve the link in the given context. So I do agree with Lina that the interlink handling should be part of the parser, as it is depending on the input format. And I agree with Wouter that interlink doesn't have to be part of the core, however I do see this as a core feature of a documentation tool to link between documentation sets. What I do not like about the current implementation is that I would need to implement al kind of logic to support interlinks in my custom link formats. Which could be resolved by splitting the parsing of links to a structure as suggested. And think more about the way to structure this. |
As far as I'm concerned right now, I do not think the structural change should be done directly. We are still learning about what we actually need to support. And new insights are part of what we are doing. In order to keep learning it's more important to iterate, rather than have long discussions about what the best technical way of implementing stuff would be. There are no requirements rather than that we figure out on a daily basis that there are things that need to be improved. |
738079c
to
4cccf02
Compare
In TYPO3 we want to allow additonal special signs, so that interlinks to composer names can be made. Additionally, this also removed duplicate code
4cccf02
to
b1c2e0a
Compare
@jaapio should we stick with the minor improvement and merge this as-is for now? |
I can live with that. 😁 |
I will move the discussion we had here to a issue, so we can find the final solution together |
Thanks for the extensive comment! I can see, if you take into account the "multiple input formats" aspect of guides, how having some sort of "inter project linking" concept makes sense now. Btw, what you say about domains is something that Sphinx also knows for roles and directives (https://www.sphinx-doc.org/en/master/usage/domains/index.html). This refers to coding languages, where e.g. It would be interesting to brainstorm, for the future, if we can somehow find a way to combine the concepts. I think it'll be very useful if you can use e.g. |
@wouterj we have actually already implemented something like that in a standalone guides extension: https://github.com/TYPO3-Documentation/guides-php-domain |
phpDocumentor has this since yesterday 🤓 |
can I interlink to it? |
In TYPO3 we want to allow additonal special signs, so that interlinks to composer names can be made.
Additionally, this also removed duplicate code