Skip to content

Commit cc9bf00

Browse files
pradyunsgbluetech
authored andcommitted
Improve how the documentation sidebar is managed
Move away from injecting unstyled HTML into the sidebar, to using Furo's default sidebar with Sphinx's `doctree` instead. This also includes moving to a more typical Sphinx documentation structure with the `index` page serving as the "root" of the `doctree` for Sphinx. Additionally, move custom stylesheets into a `pytest-custom.css` file and use standard Sphinx tooling to inject these styles.
1 parent 9e265ee commit cc9bf00

File tree

9 files changed

+62
-96
lines changed

9 files changed

+62
-96
lines changed

doc/en/_static/pytest-custom.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Tweak how the sidebar logo is presented */
2+
.sidebar-logo {
3+
width: 70%;
4+
}
5+
.sidebar-brand {
6+
padding: 0;
7+
}
8+
9+
/* The landing pages' sidebar-in-content highlights */
10+
#features ul {
11+
padding-left: 1rem;
12+
list-style: none;
13+
}
14+
#features ul li {
15+
margin-bottom: 0;
16+
}
17+
@media (min-width: 46em) {
18+
#features {
19+
width: 50%;
20+
}
21+
}

doc/en/_templates/globaltoc.html

Lines changed: 0 additions & 31 deletions
This file was deleted.

doc/en/_templates/relations.html

Lines changed: 0 additions & 19 deletions
This file was deleted.

doc/en/_templates/sidebar/brand.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

doc/en/_templates/sidebarintro.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

doc/en/_templates/style.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

doc/en/conf.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# -- General configuration -------------------------------------------------------------
2626
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
2727

28-
root_doc = "contents"
28+
root_doc = "index"
2929
extensions = [
3030
"pygments_pytest",
3131
"sphinx.ext.autodoc",
@@ -150,35 +150,19 @@
150150
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
151151

152152
html_theme = "furo"
153+
html_theme_options = {"sidebar_hide_name": True}
154+
155+
html_static_path = ["_static"]
156+
html_css_files = [
157+
"pytest-custom.css",
158+
]
159+
153160
html_title = "pytest documentation"
154161
html_short_title = f"pytest-{release}"
155162

156-
html_logo = "img/pytest_logo_curves.svg"
163+
html_logo = "_static/pytest1.png"
157164
html_favicon = "img/favicon.png"
158165

159-
html_sidebars = {
160-
"index": [
161-
"sidebar/brand.html",
162-
"sidebar/search.html",
163-
"sidebar/scroll-start.html",
164-
"sidebarintro.html",
165-
"globaltoc.html",
166-
"links.html",
167-
"sidebar/scroll-end.html",
168-
"style.html",
169-
],
170-
"**": [
171-
"sidebar/brand.html",
172-
"sidebar/search.html",
173-
"sidebar/scroll-start.html",
174-
"globaltoc.html",
175-
"relations.html",
176-
"links.html",
177-
"sidebar/scroll-end.html",
178-
"style.html",
179-
],
180-
}
181-
182166
html_use_index = False
183167
html_show_sourcelink = False
184168

doc/en/contents.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
.. _toc:
24

35
Full pytest documentation

doc/en/index.rst

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
:orphan:
2-
31
.. _features:
42

53
.. sidebar:: **Next Open Trainings and Events**
@@ -13,6 +11,36 @@
1311
pytest: helps you write better programs
1412
=======================================
1513

14+
.. toctree::
15+
:hidden:
16+
17+
getting-started
18+
how-to/index
19+
reference/index
20+
explanation/index
21+
example/index
22+
23+
.. toctree::
24+
:caption: About the project
25+
:hidden:
26+
27+
changelog
28+
contributing
29+
backwards-compatibility
30+
sponsor
31+
tidelift
32+
license
33+
contact
34+
35+
.. toctree::
36+
:caption: Useful links
37+
:hidden:
38+
39+
pytest @ PyPI <https://pypi.org/project/pytest/>
40+
pytest @ GitHub <https://github.com/pytest-dev/pytest/>
41+
Issue Tracker <https://github.com/pytest-dev/pytest/issues>
42+
PDF Documentation <https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf>
43+
1644
.. module:: pytest
1745

1846
The ``pytest`` framework makes it easy to write small, readable tests, and can

0 commit comments

Comments
 (0)