Hi all,
I'm using sphinx and rst for a while now but now I am trying to build a more complex set of documentation and I find that the include directive is biting me. I was a bit surprised that this hasn't bitten me before.
I am trying to build a kind of hub where it's documentation is in one directory. I would like to pull in documentation from other project directories but I don't want to set up a separate sphinx doc set for each of these projects (there will be many small projects).
The fact that sphinx relative references will be resolved relative to the main sphinx directory looks like a serious blocker.
Example:
[hub/index.rst]
.. include:: ../projects/a/index.rst
[../projects/a/index.rst]
Hello I am project A
.. include:: foo.py
[../projects/a/foo.py]
print "I am project A too"
Note that ../ can be any relative path (as rst include doesn't deal with abs paths at all)
I've googled a bit and found what I thought might offer a solution in a blog post by Reinout van Rees
This seems to work but not really. Whenever the rst from the external project also uses an include then this still works with the original, hub directory as base directory.
I've looked at intersphinx but this mechanism seems to be aimed at linking and not including/embedding.
Compare this to how includes usually work in XML tools. Whenever I resolve relative paths in XSLT they resolve relative to the xml:base URI of the document that contains the link. Even when embedding. This behaviour seems natural to me and from the XML perspective the rst include semantics feel wrong to me.
So I guess I have two questions now.
a) is there a way to get what I need without needing to deal with symlinks (... windows, you know, don't ask ;-)
b) wouldn't it be better to use the latter semantics (or maybe there's a need for a new directive .. xinclude:: that uses it?)
... or maybe someone can explain what the rationale is to have the current semantics as I fail to see it (apart maybe from a security standpoint)
The only solution I can see now is to introduce an extra build step which gathers all documentation and copies it under the hub directory.
I hope I've explained myself well enough.
Thanks,
--Marc