-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Intersphinx support in toctrees #1836
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
Comments
That would be nice. I agree. |
I just ran up against this wall myself - this would be a great feature! |
+1! |
+2! |
interrested as well ! |
+3! |
We missed this feature request's 5 year anniversary! |
I need this also. For my purposes, there is a bit of a workaround though. In conf.py, add:
This will pull down the file to the sphinx build directory whenever sphinx executes. Now in your toctree, just list Not actually using intersphinx at all |
+4! |
I'm interested in this functionality, and might be willing/able to implement it, but would love a quick feasibility check from someone more experienced with Sphinx first. Does anyone have a sense of what this would take to support? Does someone with experience with Sphinx internals and intersphinx think it's doable without sweeping design changes to toctree and/or intersphinx? |
At present, there are no way to fetch toctrees of the external document because the inventory file (that is used to resolve the cross references by intersphinx) does not contain them. And intersphinx is only invoked on the resolving-phase. So there are no chance to insert external toctrees to the local one. So you need to design and implement the whole of features for this issue. Additionally, we need to discuss how external toctrees are represented in non-HTML outputs. So I think it would be better to go to implement this as a 3rd party extension, at first. |
@tk0miya I don't know about other commenters but my original use-case was really just having intersphinx links as part of the toctree, so in the same way you can Though maybe you mean the very structuring of Sphinx' toctrees would require the ability to graft entire toctrees? |
Ah, sorry. I wrongly commented yesterday. If your goal is creating a link to the external document in toctree like |
Good to point out that those two things are separate! I'm interested in both. :-) How do non-HTML outputs handle external links in a toctree already? |
@tk0miya Your summaries are really helpful, thank you! |
Asked too quick, as I just answered my own question. Looks like sphinx.builders.manpage and sphinx.builders.latex for example both use |
It's a completely separate matter, but since latex supports hyperlinks it ought be possible not to skip them no? |
Seems that way to me, yes. Other builders could render them the same way they render other external links too. The source of Lines 397 to 428 in 6d5478b
|
This is a pretty awful hack. We could do this properly after one of the following issues is fixed: * sphinx-doc/sphinx#701 * sphinx-doc/sphinx#1836
My use case is a bit different, I would like to maintain the SDMX Standard's documentation from the various repositories it comprises of under one main documentation site (HTML + PDF downloads). I would like to leave the oportunity and responsability to each "sub-"repository to update their documentation but have only one TOC.
and the TOC has sections that correspond to the main documentation and repositories. This would mean that the sub-section in the TOC would be expanded from the TOC hierarchy of the sub-repositories. |
Yep, I'd like this as well. If you end up implementing it as a Sphinx extension (as suggested by @tk0miya above), would you drop a note here? |
Just a precision, sub-repository here for me is just another repository of my choosing (it happens to be in the same organization in github). |
Are you saying the external links (including intersphinx) are shown only on HTML output? If so, I don't prefer your proposal. I still don't understand the external links are parts of the "table of contents". And I think Sphinx is a document converter that converts single-input into multi-format. But proposed behavior (mark-up) is designed only for HTML. So I feel odd... |
I was describing what Sphinx currently does for most formats (latex, epub, etc… even singlehtml) when rendering toctrees that contain external links. For example, an .. toctree::
one
external <https://sphinx-doc.org>
two will omit the sphinx-doc.org entry in the rendered table of contents and combined output document, except in the HTML output format. I agree having external links in a table of contents is conceptually a little weird, particularly for output formats other than HTML (although even single-page HTML omits them). It's a bit like a section titled "About Y" in a manual that only contains the single sentence "Refer to document X for more information on Y." I do think it'd make more sense conceptually if intersphinx could embed the external toctrees too. |
Indeed. Currently, a toctree directive accepts an external link as its entry, and it is suppressed in non-HTML formats. TBH, I feel that is a bad design. It is surprising behavior to me that Sphinx automatically removes my contents silently on building to some output. I'd not like to add such a similar feature. |
That's very fair. I was surprised to find out it silently dropped some contents too. Your point about not adding to the problem by extending that behaviour make sense. One way to approach it in non-HTML formats might be including a section for the entry using the entry title which contains just "See <url>". Does that feel ok to you? |
What happens with your example?
Is it expanded like this?
I think a collection of hyperlinks (including cross-references) and table-of-contents are different things. So it should be better to separate them if possible. |
I was thinking it would be expanded using the given title for the external link, so:
For an intersphinx (and a new toctree inventory file could even let it include the sub-toctree of the referenced section, if applicable)
Nod. I understand this desire. But since toctree is very special and central to Sphinx, its lack of support for external refs makes it hard to create unified "umbrella" documentation projects which are comprised of several sub-projects. |
I don't know it makes sense to everyone. But I feel interesting. |
This seems very cool to me! |
+1 I just spent the last two hours trying to figure out why intersphinx wasn't working only to find this thread... using intersphinx links in a toctree should be a given. |
same here 😢 couple of hours totally wasted |
Hi there, feeling to be in the same boat like you and others who are discussing similar topics over at 1, you may enjoy to hear we started to work on a more versatile If you would like to join the conversation about it, in order not to hijack this one too much, you are welcome to add your ideas on the issue we just created. With kind regards, Footnotes |
Currently, toctree links can be either internal documents or arbitrary external URLs.
For Sphinx projects which serve as hub of sorts, or to cross-TOC between related projects, it'd be nice if it were possible for toctree to use intersphinx when references are not found locally (and are not URLs)
The text was updated successfully, but these errors were encountered: