Browse Source

docs: no third level toc on command usage pages ("Description", "Examples")

Marian Beermann 8 năm trước cách đây
mục cha
commit
f6c3d1d2cc
2 tập tin đã thay đổi với 11 bổ sung3 xóa
  1. 11 1
      docs/_templates/globaltoc.html
  2. 0 2
      docs/usage.rst

+ 11 - 1
docs/_templates/globaltoc.html

@@ -1,6 +1,16 @@
 <div class="sidebar-block">
   <div class="sidebar-toc">
-    {% set toctree = toctree(maxdepth=3, collapse=True, includehidden=True) %}
+    {# Restrict the sidebar toc depth to two levels while generating command usage pages.
+       This avoids superfluous entries for each "Description" and "Examples" heading. #}
+    {% if pagename.startswith("usage/") and pagename not in (
+      "usage/general", "usage/help", "usage/debug", "usage/notes",
+    ) %}
+      {% set maxdepth = 2 %}
+    {% else %}
+      {% set maxdepth = 3 %}
+    {% endif %}
+
+    {% set toctree = toctree(maxdepth=maxdepth, collapse=True) %}
     {% if toctree %}
       {{ toctree }}
     {% else %}

+ 0 - 2
docs/usage.rst

@@ -31,8 +31,6 @@ Usage
    </script>
 
 .. toctree::
-   :hidden:
-
    usage/general
 
    usage/init