summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-08 18:00:51 +0000
committerGerrit Code Review <review@openstack.org>2018-10-08 18:00:51 +0000
commitfeac3dcbfeef8e1d28ff40e2c3df9bf36d88bc9f (patch)
tree5cf1bbf57e0fda0614acbd624954436ab05239ea
parentcef105744d80023eed5ec7392f31e073f38ea765 (diff)
parent6fc8c8287a178cedbeb42e256f60f3bcaa66e195 (diff)
downloadoslo-policy-feac3dcbfeef8e1d28ff40e2c3df9bf36d88bc9f.tar.gz
Merge "sphinxext: Start parsing 'DocumentedRuleDefault.description' as rST"1.40.0
-rw-r--r--oslo_policy/sphinxext.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/oslo_policy/sphinxext.py b/oslo_policy/sphinxext.py
index c5c8897..d8b8ce0 100644
--- a/oslo_policy/sphinxext.py
+++ b/oslo_policy/sphinxext.py
@@ -21,6 +21,7 @@ from docutils.parsers import rst
from docutils.parsers.rst import directives
from docutils import statemachine
from oslo_config import cfg
+from sphinx.util import logging
from sphinx.util.nodes import nested_parse_with_titles
from oslo_policy import generator
@@ -40,7 +41,7 @@ def _indent(text):
def _format_policy_rule(rule):
"""Output a definition list-style rule.
- For example:
+ For example::
``os_compute_api:servers:create``
:Default: ``rule:admin_or_owner``
@@ -70,10 +71,8 @@ def _format_policy_rule(rule):
yield ''
if rule.description:
- for line in statemachine.string2lines(
- rule.description, tab_width=4, convert_whitespace=True):
- if line:
- yield _indent(line)
+ for line in rule.description.strip().splitlines():
+ yield _indent(line.rstrip())
else:
yield _indent('(no description provided)')
@@ -151,7 +150,15 @@ class ShowPolicyDirective(rst.Directive):
node = nodes.section()
node.document = self.state.document
- nested_parse_with_titles(self.state, result, node)
+
+ # With the resolution for bug #1788183, we now parse the
+ # 'DocumentedRuleDefault.description' attribute as rST. Unfortunately,
+ # there are a lot of broken option descriptions out there and we don't
+ # want to break peoples' builds suddenly. As a result, we disable
+ # 'warning-is-error' temporarily. Users will still see the warnings but
+ # the build will continue.
+ with logging.skip_warningiserror():
+ nested_parse_with_titles(self.state, result, node)
return node.children