summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-07-13 11:41:44 +0000
committerGerrit Code Review <review@openstack.org>2017-07-13 11:41:44 +0000
commitf7741521ac5056fe54bff1f04a5c7e45bf88fa6b (patch)
tree59579052a1a8c74a4421e3c9b0b9c592cb0d49ed
parent6d43226d919adf7155cf096d67c21fff4c8b0a66 (diff)
parent9697fede88b629e6865b21a7671bc04febb2ef15 (diff)
downloadoslo-policy-f7741521ac5056fe54bff1f04a5c7e45bf88fa6b.tar.gz
Merge "sphinxext: Use field lists in output"
-rw-r--r--oslo_policy/sphinxext.py36
-rw-r--r--oslo_policy/tests/test_sphinxext.py24
2 files changed, 24 insertions, 36 deletions
diff --git a/oslo_policy/sphinxext.py b/oslo_policy/sphinxext.py
index f685640..e3d7e1e 100644
--- a/oslo_policy/sphinxext.py
+++ b/oslo_policy/sphinxext.py
@@ -43,37 +43,31 @@ def _format_policy_rule(rule):
For example:
``os_compute_api:servers:create``
- Create a server
+ :Default: ``rule:admin_or_owner``
+ :Operations:
+ - **POST** ``/servers``
- Default::
+ Create a server
+ """
+ yield '``{}``'.format(rule.name)
- rule:admin_or_owner
+ yield _indent(':Default: ``{}``'.format(rule.check_str))
- Operations:
+ if hasattr(rule, 'operations'):
+ yield _indent(':Operations:')
+ for operation in rule.operations:
+ yield _indent(_indent('- **{}** ``{}``'.format(
+ operation['method'], operation['path'])))
- - **POST** ``/servers``
- """
- yield '``{}``'.format(rule.name)
+ yield ''
if rule.description:
for line in statemachine.string2lines(
rule.description, tab_width=4, convert_whitespace=True):
if line:
yield _indent(line)
-
- yield ''
-
- yield _indent('Default::')
- yield ''
- yield _indent(_indent(rule.check_str))
-
- if hasattr(rule, 'operations'):
- yield ''
- yield _indent('Operations:')
- yield ''
- for operation in rule.operations:
- yield _indent('- **{}** ``{}``'.format(operation['method'],
- operation['path']))
+ else:
+ yield _indent('(no description provided)')
yield ''
diff --git a/oslo_policy/tests/test_sphinxext.py b/oslo_policy/tests/test_sphinxext.py
index 101eae3..7834b35 100644
--- a/oslo_policy/tests/test_sphinxext.py
+++ b/oslo_policy/tests/test_sphinxext.py
@@ -31,9 +31,9 @@ class FormatPolicyTest(base.BaseTestCase):
===
``rule_a``
- Default::
+ :Default: ``@``
- @
+ (no description provided)
""").lstrip(), results)
def test_with_description(self):
@@ -46,11 +46,9 @@ class FormatPolicyTest(base.BaseTestCase):
===
``rule_a``
- My sample rule
-
- Default::
+ :Default: ``@``
- @
+ My sample rule
""").lstrip(), results)
def test_with_operations(self):
@@ -66,14 +64,10 @@ class FormatPolicyTest(base.BaseTestCase):
===
``rule_a``
- My sample rule
+ :Default: ``@``
+ :Operations:
+ - **GET** ``/foo``
+ - **POST** ``/some``
- Default::
-
- @
-
- Operations:
-
- - **GET** ``/foo``
- - **POST** ``/some``
+ My sample rule
""").lstrip(), results)