| 1 |
CLI Options and Config File |
| 2 |
=========================== |
| 3 |
|
| 4 |
Command line options |
| 5 |
-------------------- |
| 6 |
|
| 7 |
.. argparse:: |
| 8 |
:ref: pydoctor.options.get_parser |
| 9 |
:prog: pydoctor |
| 10 |
:nodefault: |
| 11 |
|
| 12 |
Configuration file |
| 13 |
------------------ |
| 14 |
|
| 15 |
All arguments can also be set in a config file. |
| 16 |
|
| 17 |
Repeatable arguments must be defined as list. |
| 18 |
|
| 19 |
Positional arguments can be set with option ``add-package``. |
| 20 |
|
| 21 |
By convention, the config file resides on the root of your repository. |
| 22 |
|
| 23 |
Pydoctor automatically integrates with common project files ``./pyproject.toml`` or ``./setup.cfg`` and loads file ``./pydoctor.ini`` if if exists. |
| 24 |
The configuration parser supports `TOML <https://github.com/toml-lang/toml/blob/main/toml.md>`_ and INI formats. |
| 25 |
|
| 26 |
.. note:: No path processing is done to determine the project root directory, pydoctor only looks at the current working directory. |
| 27 |
You can set a different config file path with option ``--config``, this is necessary to load project configuration files from Sphinx's ``conf.py``. |
| 28 |
|
| 29 |
``pydoctor.ini`` |
| 30 |
^^^^^^^^^^^^^^^^ |
| 31 |
|
| 32 |
Declaring section ``[pydoctor]`` is required. |
| 33 |
|
| 34 |
:: |
| 35 |
|
| 36 |
[pydoctor] |
| 37 |
add-package = |
| 38 |
src/mylib |
| 39 |
intersphinx = |
| 40 |
https://docs.python.org/3/objects.inv |
| 41 |
https://twistedmatrix.com/documents/current/api/objects.inv |
| 42 |
docformat = restructuredtext |
| 43 |
verbose = 1 |
| 44 |
warnings-as-errors = true |
| 45 |
privacy = |
| 46 |
HIDDEN:pydoctor.test |
| 47 |
PUBLIC:pydoctor._configparser |
| 48 |
|
| 49 |
``pyproject.toml`` |
| 50 |
^^^^^^^^^^^^^^^^^^ |
| 51 |
|
| 52 |
``pyproject.toml`` are considered for configuration when they contain a ``[tool.pydoctor]`` table. It must use TOML format. |
| 53 |
|
| 54 |
:: |
| 55 |
|
| 56 |
[tool.pydoctor] |
| 57 |
add-package = ["src/mylib"] |
| 58 |
intersphinx = ["https://docs.python.org/3/objects.inv", |
| 59 |
"https://twistedmatrix.com/documents/current/api/objects.inv"] |
| 60 |
docformat = "restructuredtext" |
| 61 |
verbose = 1 |
| 62 |
warnings-as-errors = true |
| 63 |
privacy = ["HIDDEN:pydoctor.test", |
| 64 |
"PUBLIC:pydoctor._configparser",] |
| 65 |
|
| 66 |
Note that the config file fragment above is also valid INI format and could be parsed from a ``setup.cfg`` file successfully. |
| 67 |
|
| 68 |
``setup.cfg`` |
| 69 |
^^^^^^^^^^^^^ |
| 70 |
|
| 71 |
``setup.cfg`` can also be used to hold pydoctor configuration if they have a ``[tool:pydoctor]`` section. It must use ``INI`` format. |
| 72 |
|
| 73 |
:: |
| 74 |
|
| 75 |
[tool:pydoctor] |
| 76 |
add-package = |
| 77 |
src/mylib |
| 78 |
intersphinx = |
| 79 |
https://docs.python.org/3/objects.inv |
| 80 |
https://twistedmatrix.com/documents/current/api/objects.inv |
| 81 |
docformat = restructuredtext |
| 82 |
verbose = 1 |
| 83 |
warnings-as-errors = true |
| 84 |
privacy = |
| 85 |
HIDDEN:pydoctor.test |
| 86 |
PUBLIC:pydoctor._configparser |
| 87 |
|
| 88 |
.. Note:: If an argument is specified in more than one place, |
| 89 |
then command line values override config file values which override defaults. |
| 90 |
If more than one config file exists, ``pydoctor.ini`` overrides values from |
| 91 |
``pyproject.toml`` which overrrides ``setup.cfg``. Repeatable options are not |
| 92 |
merged together, there are overriden as well. |
| 93 |
|
| 94 |
.. Note:: |
| 95 |
The INI parser behaves like :py:class:`configargparse:configargparse.ConfigparserConfigFileParser` in addition that it |
| 96 |
converts plain multiline values to list, each non-empty line will be converted to a list item. |
| 97 |
If for some reason you need newlines in a string value, just tripple quote your string like you would do in python. |
| 98 |
|
| 99 |
Allowed syntax is that for a :py:class:`std:configparser.ConfigParser` with the default options. |
| 100 |
|
| 101 |
.. Note:: |
| 102 |
Last note: pydoctor has always supported a ``--config`` option, but before 2022, the format was undocumentd and rather fragile. |
| 103 |
This new configuration format breaks compatibility with older config file in three main ways: |
| 104 |
|
| 105 |
- Options names are now the same as argument without the leading ``--`` (e.g ``project-name`` and not ``projectname``). |
| 106 |
- Define repeatable options with multiline strings or list literals instead of commas separated string. |