]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
doc: define command properties using field list 39411/head
authorKefu Chai <kchai@redhat.com>
Fri, 12 Feb 2021 10:00:08 +0000 (18:00 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 13 Feb 2021 02:18:58 +0000 (10:18 +0800)
the rendering is more compacted this way, and the parameters can be
aligned.

Signed-off-by: Kefu Chai <kchai@redhat.com>
doc/_ext/ceph_commands.py

index d52949f17ff177b6ab6bb95f05f9627213846ff8..bafcd1ba084f9363f17f49e11959b13cd0f7a225 100644 (file)
@@ -179,7 +179,7 @@ class Sig:
 
 
 TEMPLATE = '''
-{% set punct_char = '-' %}
+{%- set punct_char = '-' -%}
 {# add a header if we have multiple commands in this section #}
 {% if commands | length > 1 %}
 {{ section }}
@@ -187,38 +187,28 @@ TEMPLATE = '''
 {# and demote the subsection #}
 {% set punct_char = '^' %}
 {% endif %}
-
 {% for command in commands %}
-
 {{ command.prefix }}
 {{ command.prefix | length * punct_char }}
 
-{{ command.help | wordwrap(70)}}
-
-Example command:
-
-.. code-block:: bash
-
-    {{ command.mk_bash_example() }}
-{% if command.params %}
-Parameters:
-
-{% for param in command.params %}* **{{param.name}}**: {{ param.help() | wordwrap(70) | indent(2) }}
-{% endfor %}{% endif %}
-Ceph Module:
+{{ command.help | wordwrap(70) }}
 
-* *{{ command.module }}*
+:Example command:
+    .. code-block:: bash
 
-Required Permissions:
+       {{ command.mk_bash_example() }}
 
-* *{{ command.perm }}*
-
-{% if command.flags %}Command Flags:
-
-* *{{ command.flags }}*
+{%- if command.params %}
+:Parameters:{% for param in command.params -%}
+{{" -" | indent(12, not loop.first) }} **{{param.name}}**: {{ param.help() }}
+{% endfor %}
+{% endif %}
+:Ceph Module: {{ command.module }}
+:Required Permissions: ``{{ command.perm }}``
+{%- if command.flags %}
+:Command Flags: ``{{ command.flags }}``
 {% endif %}
 {% endfor %}
-
 '''
 
 
@@ -244,8 +234,6 @@ def render_commands(commands):
     rendered = io.StringIO()
     for section, grouped in group_by_prefix(commands):
         logger.debug('rendering commands: %s: %d', section, len(grouped))
-        for cmd in grouped:
-            logger.info('%s ==> %s', section, cmd.prefix)
         rendered.write(Template(TEMPLATE).render(
             section=section,
             commands=grouped))