Coverage for adhoc-cicd-odoo-odoo / odoo / _monkeypatches / docutils.py: 86%
10 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:22 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:22 +0000
1"""
2The docstrings can use many more roles and directives than the one
3present natively in docutils. That's because we use Sphinx to render
4them in the documentation, and Sphinx defines the "Python Domain", a set
5of additional rules and directive to understand the python language.
7It is not desirable to add a dependency on Sphinx in community, as it is
8a *too big* dependency.
10The following code adds a bunch of dummy elements for the missing roles
11and directives, so docutils is able to parse them with no warning.
12"""
14import docutils.nodes
15import docutils.parsers.rst.directives.admonitions
18def _role_literal(name, rawtext, text, lineno, inliner, options=None, content=None):
19 literal = docutils.nodes.literal(rawtext, text)
20 return [literal], []
23def patch_module():
24 for role in ('attr', 'class', 'func', 'meth', 'ref', 'const', 'samp', 'term'):
25 docutils.parsers.rst.roles.register_local_role(role, _role_literal)
27 for directive in ('attribute', 'deprecated'):
28 docutils.parsers.rst.directives.register_directive(
29 directive, docutils.parsers.rst.directives.admonitions.Note)