diff --git a/oslo_config/sphinxext.py b/oslo_config/sphinxext.py index 33128665..7f3ca188 100644 --- a/oslo_config/sphinxext.py +++ b/oslo_config/sphinxext.py @@ -108,9 +108,9 @@ def _format_group(app, namespace, group_name, group_obj, opt_list): if default: default = '``' + default + '``' yield _indent(':Default: %s' % default) - if getattr(opt.type, 'min', None): + if getattr(opt.type, 'min', None) is not None: yield _indent(':Minimum Value: %s' % opt.type.min) - if getattr(opt.type, 'max', None): + if getattr(opt.type, 'max', None) is not None: yield _indent(':Maximum Value: %s' % opt.type.max) if getattr(opt.type, 'choices', None): choices_text = ', '.join([_get_choice_text(choice) diff --git a/oslo_config/tests/test_sphinxext.py b/oslo_config/tests/test_sphinxext.py index d584943a..0ad56c47 100644 --- a/oslo_config/tests/test_sphinxext.py +++ b/oslo_config/tests/test_sphinxext.py @@ -91,6 +91,28 @@ class FormatGroupTest(base.BaseTestCase): ''').lstrip(), results) + def test_with_min_0(self): + results = '\n'.join(list(sphinxext._format_group( + app=mock.Mock(), + namespace=None, + group_name=None, + group_obj=None, + opt_list=[ + cfg.IntOpt('opt_name', + min=0), + ], + ))) + self.assertEqual(textwrap.dedent(''' + .. oslo.config:group:: DEFAULT + + .. oslo.config:option:: opt_name + + :Type: integer + :Default: ```` + :Minimum Value: 0 + + ''').lstrip(), results) + def test_with_max(self): results = '\n'.join(list(sphinxext._format_group( app=mock.Mock(), @@ -113,6 +135,28 @@ class FormatGroupTest(base.BaseTestCase): ''').lstrip(), results) + def test_with_max_0(self): + results = '\n'.join(list(sphinxext._format_group( + app=mock.Mock(), + namespace=None, + group_name=None, + group_obj=None, + opt_list=[ + cfg.IntOpt('opt_name', + max=0), + ], + ))) + self.assertEqual(textwrap.dedent(''' + .. oslo.config:group:: DEFAULT + + .. oslo.config:option:: opt_name + + :Type: integer + :Default: ```` + :Maximum Value: 0 + + ''').lstrip(), results) + def test_with_choices(self): results = '\n'.join(list(sphinxext._format_group( app=mock.Mock(),