Browse Source

Help: Theme improvements

* Push the footer to the bottom of the page (for short pages).
* Remove the link from the sidebar "Table of Contents" header.
* Remove text justification from TOCs and tables.
* Adjust logo position in the header.
* Restructure the navigation bar from
    CMake >> [version] Documentation >> Page
  to
    CMake [version] >> Documentation >> Page
Nikita Nemkin 10 months ago
parent
commit
bf9ccc8427

+ 28 - 1
Utilities/Sphinx/static/cmake.css

@@ -1,6 +1,28 @@
 /* Import the Sphinx theme style.  */
 @import url("default.css");
 
+/* Navbar logo */
+li.rootlink > img {
+  vertical-align: middle;
+  margin-top: -5px;
+}
+
+/* Push the footer to the bottom of the page. */
+body {
+  display: flex;
+  flex-direction: column;
+  min-height: 100svh;
+}
+
+div.document {
+  flex-grow: 1;
+}
+
+div.bodywrapper,
+div.body {
+  height: 100%;
+}
+
 /* Wrap sidebar content even within words so that long
    document names do not escape sidebar borders.  */
 div.sphinxsidebarwrapper {
@@ -17,6 +39,12 @@ div.sphinxsidebarwrapper {
   background-color: #dfdfdf;
 }
 
+/* Un-justify some elements. */
+div.body table.docutils p,
+div.body nav.contents p {
+  text-align: left;
+}
+
 /* Apply <pre> style (from classic.css) to signature directive argument. */
 .signature .sig {
   padding: 5px;
@@ -73,7 +101,6 @@ div.outdated {
   padding-right: 2px;
   padding-top: 5px;
   text-align: center;
-  width: 100%;
 }
 
 /* Revert style to the inherited (normal text) for `:guide:` links */

+ 8 - 11
Utilities/Sphinx/templates/layout.html

@@ -1,19 +1,16 @@
 {% extends "!layout.html" %}
 {% block rootrellink %}
-  <li>
-    <img src="{{ pathto('_static/cmake-logo-16.png', 1) }}" alt=""
-         style="vertical-align: middle; margin-top: -2px" />
-  </li>
-  <li>
-    <a href="https://cmake.org/">CMake</a>{{ reldelim1 }}
+  <li class="rootlink">
+    <img src="{{ pathto('_static/cmake-logo-16.png', 1) }}" width="16" height="16" alt=""/>
+  {%- if versionswitch is defined %}
+    <a href="https://cmake.org/">CMake</a> <span class="version_switch">{{ release }}</span>
+  {%- else %}
+    <a href="https://cmake.org/">CMake {{ release }}</a>
+  {%- endif %}
+    {{ reldelim1 }}
   </li>
   <li>
-    {%- if versionswitch is defined %}
-    <span class="version_switch">{{ release }}</span>
     <a href="{{ pathto(master_doc) }}">{% trans %}Documentation{% endtrans %}</a>{{ reldelim1 }}
-    {%- else %}
-    <a href="{{ pathto(master_doc) }}">{{ shorttitle|e }}</a>{{ reldelim1 }}
-    {%- endif %}
   </li>
 {% endblock %}
 

+ 8 - 0
Utilities/Sphinx/templates/localtoc.html

@@ -0,0 +1,8 @@
+{# Sphinx sidebar template: local table of contents.
+   Overridden to remove the "#" link from the "Table of Contents". #}
+{%- if display_toc %}
+  <div>
+    <h3>{{ _('Table of Contents') }}</h3>
+    {{ toc }}
+  </div>
+{%- endif %}