-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
relative links in toctree #701
Comments
From Anonymous on 2012-04-18 14:10:29+00:00 I would also like to use relative document locations that are not within the directory tree housing conf.py. For instance, see my stack overflow question: |
From rdburns on 2012-04-18 14:12:13+00:00 That previous comment was me, forgot to login. |
From Mac Ryan on 2012-08-02 10:26:08+00:00 I second this request (just in case the number of people requesting this feature influences the priority queue...). :) |
From Dmitriy Kruglov on 2012-09-13 09:35:01+00:00 One more vote to have the feature. |
From Marcus Lindblom Sonestedt on 2012-10-17 10:50:22+00:00 We'd like this too! :) |
From Gringo Suave on 2012-12-14 03:35:35+00:00 Bitbucket demands I keep my readme in the root, sphinx demands I keep it in ./docs ... what to do? I'd use a filesystem link but project needs to be able to work under Windows and hg doesn't support links there. |
From Thibault Kruse on 2013-01-30 12:25:54+00:00 +1 |
From Georg Brandl on 2013-01-31 07:37:34+00:00 You can put it in the root and use ".. include:: ../README" from a file in "docs", like Sphinx does with CHANGES. |
From mears on 2013-08-27 06:48:18+00:00 I'd like to see this implemented as well |
From Adam Siembida on 2014-04-01 22:06:49+00:00 This would be great to have. I know you can use symlinks to files shared between projects, but Windows doesn't have the greatest support for that. |
I wish there was a way to put a relative link in a toctree entry too! I have some plain files (they happen to be javadocs, but could be anything generated by some non-sphinx system). I place files in the build directory with
Also tried with Reading through the source, the simplest change might be to start treating Just want a relative anchor tag at the end of the day :( |
Basically me too. I've tried:
which didn't work of course. |
You can't use
One more rule is exist. |
+1 for relative links in toctree. Sometimes I have custom named anchors in text I want to link to from the toctree, but they don't auto-render because they're not headings, and putting headings near them would severely uglify the documentation. |
+1. Edit: Later, I found that the entries in the toctree-s are not file paths, but names of documents. So relative includes might not be possible here (as those aren't file paths). We need to create a separate document (an RST file inside the docs dir), to hold the contents, which need to be indexed. And include the name of the document in a toctree. Example: In new_doc.rst: .. include:: ../rel_include_1.rst
.. include:: ../some_dir/rel_include.rst An in index.rst .. toctree::a
:maxdepth: 2
new_doc I also suppose that, it might be hard to have relative includes, without creating new documents. As, sphinx has to render the docs in other formats, which might not have the concept of relative includes. |
I have solved this issue with a workaround using a custom role and CSS. Described in detail here. |
+1 for this feature :/ |
+1 Is the issue here primarily technical or philosophical? |
Now we have two pull requests to improve this; #1800 and #2354. If we add relative links or internal references to toctree, how should they be represented in PDF? How about epub and other formats? Now we can use URLs in toctree directive like following:
But these URLs are ignored by some builders; singlehtml, latex, man, texinfo and so on. I wonder these are really a part of "Table of Contents". If true, there might be a good representation for each formats. |
#2354 internally uses a generic Node object and builds a compact_paragraph when constructing the TOC structure. There's nothing builder-specific about it and I should hope that the builders continue to render compact_paragraphs as they usually do. #1800 explicitly constructs a reference object, as it is limited to such. The URL issue is orthogonal and happens with the existing implementation; do these problematic builders not understand URLs in general and so delete them throughout or something? In any case, please do not make these builders blockers for merging one of #1800 or #2354, which seem to me strict improvements on the existing implementation. (I'd prefer the latter, as I wrote it and it's a smaller patch providing a more generic mechanism, but I won't complain if it's the former.) |
Did you try to build latex, singlehtml or others? In addition, these builders does not call |
It's genuinely annoying that there's no way to create or consume relative links in |
I worked around this today by creating a symlink inside my rst sources via cd doc/source
ln -s ../../somedir somedir .. toctree::
somedir/README be aware that you can commit symlinks in git. |
Note that that probably won't work on Windows. |
For the LaTeX builder, I think LaTeX's \addcontentsline command could be coerced into service, though it would have to be emitted at the correct point in the resulting document. I have no idea how singlehtml does its thing, but I assume the mechanism for getting the LaTeX builder to emit \addcontentsline could be ported over. |
@nwf I have read the thread and don't quite get if for LaTeX the matter is to include in the produced PDF a link, from the TOC, to some external resource. If that is what is at stake, it can be achieved using a suitable Using Anyway to sum up, if some kind of node is provided to the LaTeX writer of the type "put at the corresponding location of the PDF TOC an hyperlink to this external ressource", then yes this can be done with some amount of fiddling with I forgot to say that the LaTeX builder does not emit |
I would like to have this functionality too. |
So long modular docs! 😭 Please, this would open world of possibilities 🙏 TY |
The invalid anchor in the RST is a hack that's required in order to get relative links working with sphinx (see sphinx-doc/sphinx#701 (comment) )
The invalid anchor in the RST is a hack that's required in order to get relative links working with sphinx (see sphinx-doc/sphinx#701 (comment) ) cc #3208
I'd like to use relative URLs in toctrees, but can't figure out how.
It seems right now I have the choice between either internal links (where the target is another document), or an (absolute) URL. The latter is identified by means of a sphinx.util.url_re.
Is there a way to have a toctree entry use a relative link, such that the generated html contains 'href=".../some/path.html"' ?
(If it isn't yet supported, perhaps a new pseudo-schema would work, such as 'relative:.../some/path.html', from which the 'relative:' would then be stripped off during html generation ?)
The text was updated successfully, but these errors were encountered: