diff --git a/docs/tools/dump_format_style.py b/docs/tools/dump_format_style.py
index 42e957044fd2b0015658351f1b25e3b19d152ad8..6e149394981553879f5e325fe7cf467d88573c7f 100755
--- a/docs/tools/dump_format_style.py
+++ b/docs/tools/dump_format_style.py
@@ -79,7 +79,7 @@ class Enum:
 class EnumValue:
   def __init__(self, name, comment):
     self.name = name
-    self.comment = comment.strip()
+    self.comment = comment
 
   def __str__(self):
     return '* ``%s`` (in configuration: ``%s``)\n%s' % (
@@ -88,8 +88,12 @@ class EnumValue:
         doxygen2rst(indent(self.comment, 2)))
 
 def clean_comment_line(line):
-  if line == '/// \\code':
-    return '\n.. code-block:: c++\n\n'
+  match = re.match(r'^/// \\code(\{.(\w+)\})?$', line)
+  if match:
+    lang = match.groups()[1]
+    if not lang:
+      lang = 'c++'
+    return '\n.. code-block:: %s\n\n' % lang
   if line == '/// \\endcode':
     return ''
   return line[4:] + '\n'