diff --git a/README.rst b/README.rst index 559b6957..8aa0d8fd 100644 --- a/README.rst +++ b/README.rst @@ -173,6 +173,8 @@ Inspired by `Keepachangelog.com `__. - Unreleased - Breathe v4.21.1 - Fix Read the Docs build (again). #576 + - New boolean `breathe_show_enumvalue_initializer` option specifying + whether value of enumvalue should be displayed. #581 - 2020-09-10 - Breathe v4.21.0 diff --git a/breathe/directives.py b/breathe/directives.py index 97d5394e..40b0dac9 100644 --- a/breathe/directives.py +++ b/breathe/directives.py @@ -586,6 +586,7 @@ def setup(app: Sphinx) -> None: app.add_config_value("breathe_build_directory", '', True) app.add_config_value("breathe_default_members", (), True) app.add_config_value("breathe_show_define_initializer", False, 'env') + app.add_config_value("breathe_show_enumvalue_initializer", False, 'env') app.add_config_value("breathe_implementation_filename_extensions", ['.c', '.cc', '.cpp'], True) app.add_config_value("breathe_doxygen_config_options", {}, True) app.add_config_value("breathe_use_project_refids", False, "env") diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index 0326036d..772304e6 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -1656,7 +1656,10 @@ def content(contentnode): return self.handle_declaration(node, declaration, content_callback=content) def visit_enumvalue(self, node) -> List[Node]: - declaration = node.name + self.make_initializer(node) + if self.app.config.breathe_show_enumvalue_initializer: # type: ignore + declaration = node.name + self.make_initializer(node) + else: + declaration = node.name return self.handle_declaration(node, declaration, obj_type='enumvalue') def visit_typedef(self, node) -> List[Node]: diff --git a/documentation/source/directives.rst b/documentation/source/directives.rst index bfd351eb..dcf24025 100644 --- a/documentation/source/directives.rst +++ b/documentation/source/directives.rst @@ -518,6 +518,13 @@ Config Values For example a define ``MAX_LENGTH 100`` would be shown with the value 100 if this is set to ``True``, and without if it is set to ``False``. +.. confval:: breathe_show_enumvalue_initializer + + A boolean flag which can be set to ``True`` to display the initializer of an enum value in the output. + + For example an enum value ``TWO = 2`` would be shown with the value 2 if this is set to ``True``, + and without if it is set to ``False``. + .. confval:: breathe_use_project_refids True or False setting to control if the refids generated by breathe for doxygen