kayobe/tools/sphinx8
Mark Goddard 611111b8bd Use unittest.mock instead of PyPI mock
Now that py2 is gone, oslotest dropped dependency on mock and will
soon affect Ussuri CI [1], let's use unittest.mock built in py3.

This also fixes py38 jobs and proactively prevents py36 and py37
failing due to [1]. This is because we never included mock in
test-requirements and instead relied on oslotest to bring it in.

[1] https://review.opendev.org/716322

Change-Id: I0c18b13c4e1fbaa9db41da4e2039ad908c28caa6
2020-04-03 10:22:39 +01:00

36 lines
886 B
Python
Executable File

#!/usr/bin/env python
"""
Sphinx documentation style checker.
This is a very thin wrapper around doc8, that adds support for sphinx-specific
RST directives.
NOTE: We require sphinx>1.5 in order to avoid automatically registering all
directives when any of the directives modules are imported.
"""
import sys
from unittest import mock
import doc8.main
import sphinx.directives
import sphinx.directives.code
import sphinx.directives.patches
def main():
# NOTE: Registering sphinx.directives.other causes a failure in parsing
# later.
# Sphinx expects an 'app' argument to these functions. Use a mock since we
# don't need to use the application object.
app = mock.Mock()
sphinx.directives.setup(app)
sphinx.directives.code.setup(app)
sphinx.directives.patches.setup(app)
return doc8.main.main()
if __name__ == "__main__":
sys.exit(main())