Okay, in such case, you actually write Sphinx extension. For example, to
modify copyright option from extension:

copyright = "acme inc."

def setup(app: Sphinx):
    def change(app, config):
         config.copyright = "foo bar inc."

    app.connect('config-inited', change)

End value of copyright option will be "foo bar inc".

Matt
https://blog.documatt.com

On Fri, Aug 28, 2020 at 10:14 AM Nicolas Dechesne <
nicolas.deche...@linaro.org> wrote:

> hi Matt,
>
>
> On Fri, Aug 28, 2020 at 10:03 AM Matt from Documatt <m...@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()?
>
> >
> > Matt
> > https://blog.documatt.com
> >
> >
> > On Fri, Aug 28, 2020 at 8:38 AM Nicolas Dechesne <
> nicolas.deche...@linaro.org> wrote:
> >>
> >> hey,
> >>
> >> I would like to read the value of srcdir from inside conf.py. My
> documentation folder is organized such that I need to set the version tag
> based on the srcdir.
> >>
> >> is that possible?
> >>
> >> thanks!
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "sphinx-users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to sphinx-users+unsubscr...@googlegroups.com.
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sphinx-users/60d57327-ceb7-47ed-a6ec-4bf3803f73e4n%40googlegroups.com
> .
> >
> > --
> > 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+unsubscr...@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
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sphinx-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sphinx-users/CAP71WjyXmFsxd6qkWZPTpw%2Bn1dukxANWAKA_nBLPeVPXa%3DGeyA%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sphinx-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/CAOGNDW-prVhkNZ0OkuuWwfMfw5wCt0pZfO5uteTJimuRjdd-QA%40mail.gmail.com.

Reply via email to