Skip to content

Commit

Permalink
more docs tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Nov 18, 2020
1 parent caac79f commit e678632
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
38 changes: 23 additions & 15 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,35 @@ The name can be seem from ``doit help`` output::
pyproject.toml
--------------

If one of:
`doit` configuration can be read from `pyproject.toml <https://www.python.org/dev/peps/pep-0518/>`_
under the `tool.doit` namespace. In the future, especially if a TOML parser becomes
part of the python standard library, this will become the preferred configuration source,
and may gain features not available in the legacy `doit.cfg`.

- `toml <https://pypi.org/project/toml/>`_
- `tomlkit <https://pypi.org/project/tomlkit/>`_
.. note::

are installed, `doit` configuration can be read from `pyproject.toml <https://www.python.org/dev/peps/pep-0518/>`_
under the `tool.doit` namespace.
As a TOML parser is _not_ yet part of the standard library, a third-party package is
required, one of:

.. note::
- `toml <https://pypi.org/project/toml/>`_
- `tomlkit <https://pypi.org/project/tomlkit/>`_
- `pytoml <https://pypi.org/project/pytoml/>`_


TOML vs INI
^^^^^^^^^^^

While mostly similar, `TOML <https://toml.io>`_ differs from the INI format
in a few ways:
While mostly similar, `TOML <https://toml.io>`_ differs from the INI format
in a few ways:

- all strings must be quoted with `'` or `"`
- triple-quoted strings may contain new line characters (`\n`) and quotes
- must be saved as UTF-8
- integers and floating point numbers can be written without quotes
- boolean values can be written unquoted and lower-cased, as `true` and `false`
- all strings must be quoted with `'` or `"`
- triple-quoted strings may contain new line characters (`\n`) and quotes
- must be saved as UTF-8
- integers and floating point numbers can be written without quotes
- boolean values can be written unquoted and lower-cased, as `true` and `false`

`doit` will parse pythonic strings into their correct types, e.g. `"True"`,
`"False"`, `"3"`, but using "native" TOML types may be preferable.
Unlike "plain" TOML, `doit` will parse pythonic strings into their correct types,
e.g. `"True"`, `"False"`, `"3"`, but using "native" TOML types may be preferable.


tool.doit
Expand Down
1 change: 1 addition & 0 deletions doc/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ pyinotify
pylogo
pypi
pytest
pytoml
python2
python3
pythonic
Expand Down
17 changes: 6 additions & 11 deletions doit/doit_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,12 @@ def _toml_loads(text): # pragma: no cover
:param text: str
"""
try:
import toml
return toml.loads(text)
except ImportError:
pass

try:
import tomlkit
return tomlkit.loads(text)
except ImportError:
pass

for toml_lib in ["toml", "tomlkit", "pytoml"]:
try:
return __import__(toml_lib).loads(text)
except (ImportError, AttributeError):
pass


class DoitMain(object):
Expand Down

0 comments on commit e678632

Please sign in to comment.