hi Matt,
On Fri, Aug 28, 2020 at 10:03 AM Matt from Documatt <
ma...@documatt.com> wrote:
>
> Hello,
> in 99,9% cases is scrdir, a directory of conf.py. Conf.py is executed, so you can use builtin __file__ variable:
>
> import os
>
> print(__file__) # /home/matt/foo/conf.py
> print(os.path.dirname(__file__)) # /home/matt/foo
yes, I am aware of that. But it doesn't work for me. Let me give more details.
I have the following structure:
.
|-- conf.py
|-- user-manual
|-- test-manual
|-- legacy
I also have a bunch of local static files (extensions, theme, ...).
the 'legacy' folder contains rst files that points to our
documentation *before* the conversion to Sphinx (e.g. old docs).
So I need to run sphinx-build twice, but I want to be able to reuse
the same config file, so I use the '-c' option:
sphinx-build . _build
and
sphinx-build legacy _build/legacy -c .
in conf.py I would like to know 'srcdir' so that I know if I am
building our docs, or in 'legacy' mode.
>
> If you really want to know srcdir value, you need to "hook" into Sphinx using setup() function inside conf.py:
>
> def setup(app):
> print(app.srcdir) # /home/matt/foo
That works, and i get the right srcdir value, but then, how do I set
project variables, such as version or release , from the context of
setup()?
> You received this message because you are subscribed to a topic in the Google Groups "sphinx-users" group.
> To unsubscribe from this topic, visit
https://groups.google.com/d/topic/sphinx-users/PxeQeuzxS3k/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
sphinx-users...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/CAOGNDW8oQptD%3D8V6ddutsY8vjgKA%3D8sOoEo%2BUK2oCN9_et0HzA%40mail.gmail.com.