buhtz
buhtz

Reputation: 12200

How do I configure a sphinx extension?

In the documentation about sphinx extensions are some "config values". e.g. in sphinx.ext.autodoc.

But I do not know how to set these values. Is it a parameter on the shell I have to set?

Upvotes: 1

Views: 1134

Answers (1)

Alexander Santos
Alexander Santos

Reputation: 1701

There's a page on the docs that teaches how to use extensions. The page is here: https://www.sphinx-doc.org/en/master/usage/extensions/index.html

In this page you have the following description:

A list of strings that are module names of extensions. These can be extensions coming with Sphinx (named sphinx.ext.*) or custom ones.

This tells you that sphinx.ext.* are the built-ins extensions (You can confirm that from here)

Basically when it states some kind of configuration, it refers to the conf.py file that is generated when you run sphinx-quickstart, which is a quick-setup command for sphinx in general (Might be a good read: https://www.sphinx-doc.org/en/master/usage/quickstart.html)

The root directory of a Sphinx collection of plain-text document sources is called the source directory. This directory also contains the Sphinx configuration file conf.py, where you can configure all aspects of how Sphinx reads your sources and builds your documentation.

Sphinx comes with a script called sphinx-quickstart that sets up a source directory and creates a default conf.py with the most useful configuration values from a few questions it asks you.

Note that, as it's built-in, it's already setupped with your sphinx project. But if you want to customize it somehow, you can use conf.py file with autodoc_* configurations (As listed here)

There are also some notes that might be useful for your case

For Sphinx (actually, the Python interpreter that executes Sphinx) to find your module, it must be importable. That means that the module or the package must be in one of the directories on sys.path – adapt your sys.path in the configuration file accordingly.

Upvotes: 1

Related Questions