Some mocks needs some attributes defined (instead of having them returning a
mock object). Introduce a MOCK_MODULES_MAPPING mapping that defines these
attributes. This gets rid of a special handling for psutil.
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
Importing `doc/conf.py` fails with Python 3.7:
```
>>> from conf import Mock
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "doc/conf.py", line 454
''',
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 5-6: truncated \uXXXX escape
```
Therefore mark the string as raw due to the backslashes.
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
sphinx shows a warning:
doc/topics/development/modules/index.rst:133: WARNING: undefined label:
all-salt_executors (if the link has no caption the label must precede a section
header)
The executors reference is called all-salt.executors (with a dot instead of an
underscore).
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
Creating the documentation produces a warning:
```
doc/topics/targeting/index.rst:90: WARNING: Could not lex literal_block as "yaml". Highlighting skipped.
```
Therefore replace the non-breaking spaces \xa0 by normal spaces.
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
Building the documentation for salt.modules.snapper fails with Python 3:
```
$ make -C doc html
[...]
WARNING: [autosummary] failed to import 'salt.modules.snapper': no module named salt.modules.snapper
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 109 source files that are out of date
updating environment: [config changed] 1608 added, 17 changed, 0 removed
reading sources... [100%] topics/yaml/index
doc/ref/modules/all/index.rst:20: WARNING: failed to import snapper
doc/ref/modules/all/index.rst:20: WARNING: toctree references unknown document 'ref/modules/all/snapper'
WARNING: autodoc: failed to import module 'salt.modules.snapper'; the following exception was raised:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 152, in import_module
__import__(modname)
File "salt/modules/snapper.py", line 72, in <module>
if SNAPPER_DBUS_OBJECT in bus.list_activatable_names():
TypeError: argument of type 'Mock' is not iterable
```
Fix the Mock object to be iterable (as it was intended to).
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
Building the documentation with the Python 3.7 version of sphinx fails:
```
$ make -C doc html SPHINXBUILD="python3.7 /usr/bin/sphinx-build"
[...]
WARNING: autodoc: failed to import module 'salt.states.pkg'; the following exception was raised:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc/importer.py", line 152, in import_module
__import__(modname)
File "salt/states/pkg.py", line 84, in <module>
import salt.utils.pkg
File "salt/utils/pkg/__init__.py", line 13, in <module>
import salt.utils.data
File "salt/utils/data.py", line 23, in <module>
import salt.utils.yaml
File "salt/utils/yaml.py", line 9, in <module>
from salt.utils.yamldumper import *
File "salt/utils/yamldumper.py", line 34, in <module>
class IndentMixin(Dumper):
TypeError: __mro_entries__ must return a tuple
```
Instead of returning a Mock object for the `__mro_entries__` attribute, raise
an AttributeError instead.
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
Building the documentation on Debian unstable with Python 3.7 fails:
```
debian-unstable$ HTML_THEME=saltstack make -C doc html
make: Entering directory 'doc'
No need to update translations. Skipping...
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.7.9
loading translations [en]... done
Exception occurred:
File "/usr/lib/python3/dist-packages/sphinx/util/jsonimpl.py", line 22, in <module>
class SphinxJSONEncoder(json.JSONEncoder):
TypeError: __mro_entries__ must return a tuple
The full traceback has been saved in /tmp/sphinx-err-wzl9_n0k.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make: *** [Makefile:72: html] Error 2
make: Leaving directory 'doc'
debian-unstable$ cat /tmp/sphinx-err-wzl9_n0k.log
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/sphinx/cmdline.py", line 303, in main
args.warningiserror, args.tags, args.verbosity, args.jobs)
File "/usr/lib/python3/dist-packages/sphinx/application.py", line 187, in __init__
self.setup_extension(extension)
File "/usr/lib/python3/dist-packages/sphinx/application.py", line 411, in setup_extension
self.registry.load_extension(self, extname)
File "/usr/lib/python3/dist-packages/sphinx/registry.py", line 315, in load_extension
mod = __import__(extname, None, None, ['setup'])
File "/usr/lib/python3/dist-packages/sphinx/builders/applehelp.py", line 20, in <module>
from sphinx.builders.html import StandaloneHTMLBuilder
File "/usr/lib/python3/dist-packages/sphinx/builders/html.py", line 43, in <module>
from sphinx.util import jsonimpl, logging, status_iterator
File "/usr/lib/python3/dist-packages/sphinx/util/jsonimpl.py", line 22, in <module>
class SphinxJSONEncoder(json.JSONEncoder):
TypeError: __mro_entries__ must return a tuple
```
The json module is a standard module. I is always present. So do not mock it.
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
This is fix errors like the following when building docs:
WARNING: autodoc: failed to import module 'salt.states.saltmod'; the following exception was raised:
Traceback (most recent call last):
File "/public/src/salt/env/lib/python3.6/site-packages/sphinx/ext/autodoc/importer.py", line 140, in import_module
__import__(modname)
File "/public/src/salt/salt/states/saltmod.py", line 36, in <module>
import salt.output
File "/public/src/salt/salt/output/__init__.py", line 19, in <module>
import salt.loader
File "/public/src/salt/salt/loader.py", line 23, in <module>
import salt.config
File "/public/src/salt/salt/config/__init__.py", line 27, in <module>
import salt.utils.network
File "/public/src/salt/salt/utils/network.py", line 35, in <module>
import salt.utils.zeromq
File "/public/src/salt/salt/utils/zeromq.py", line 39, in <module>
if tornado.version_info < (5,):
TypeError: '<' not supported between instances of 'Mock' and 'tuple'
(cherry picked from commit 8199700fdb)