Ask Your Question
1

How does sphinx-autodoc disregard the default configurations specified in conf.py?

asked 2023-07-05 19:12:46 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-05 19:13:01 +0000

plato gravatar image

By default, Sphinx uses the values specified in the conf.py file to configure the documentation. However, if you want to modify these settings and use your own configurations, you can pass them directly to the autodoc extension.

To do this, you need to create a separate configuration file (e.g., autodoc_conf.py) where you can override the default configurations. In this file, you can import the values from conf.py and modify or add new ones. For example:

# autodoc_conf.py

# Import the values from conf.py
from conf import *

# Override the default configurations
autodoc_member_order = 'bysource'
autodoc_default_options = {
    'members': True,
    'undoc-members': True,
    'private-members': True,
}

Then, when you run Sphinx, you can specify the autodoc_conf.py file as the configuration file instead of conf.py. For example:

sphinx-build -b html -c /path/to/autodoc_conf.py source_dir build_dir

This will use the configurations specified in autodoc_conf.py instead of conf.py. Note that any settings not overridden in autodoc_conf.py will still use the values defined in conf.py.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-05 19:12:46 +0000

Seen: 9 times

Last updated: Jul 05 '23