Skip to content

Commit 59401a6

Browse files
committed
Standardize template structure in all sections
1 parent 8d8bcb8 commit 59401a6

28 files changed

+197
-113
lines changed

docs/_templates/test.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{# This is just used for testing in our documentation #}
2+
<button>TEST</button>

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,13 @@
133133
"navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
134134
"navbar_center": ["version-switcher", "navbar-nav"],
135135
"announcement": "https://raw.githubusercontent.com/pydata/pydata-sphinx-theme/main/docs/_templates/custom-template.html",
136+
"footer_end": ["navbar-icon-links.html"],
136137
# "show_nav_level": 2,
137138
# "navbar_start": ["navbar-logo"],
138139
# "navbar_end": ["theme-switcher", "navbar-icon-links"],
139140
# "navbar_persistent": ["search-button"],
140141
# "primary_sidebar_end": ["custom-template.html", "sidebar-ethical-ads.html"],
141-
# "footer_items": ["copyright", "sphinx-version"],
142+
# "footer_start": ["test.html", "test.html"],
142143
# "secondary_sidebar_items": ["page-toc.html"], # Remove the source buttons
143144
"switcher": {
144145
"json_url": json_url,

docs/user_guide/layout.rst

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Overview of theme layout
1010

1111
Below is a brief overview of the major layout of this theme.
1212
Take a look at the diagram to understand what the major sections are called.
13-
You can click on section titles to learn more about them and some basic layout configuration.
13+
Where you can insert component templates in ``html_theme_options``, we include the variable name ``in inline code``.
14+
Click on section titles to learn more about them and some basic layout configuration.
1415

1516
.. The directives below generate a grid-like layout that mimics the structure of this theme.
1617
.. It uses Sphinx Design grids: https://sphinx-design.readthedocs.io/en/latest/grids.html
@@ -52,18 +53,24 @@ You can click on section titles to learn more about them and some basic layout c
5253

5354
Logo
5455

56+
``navbar_start``
57+
5558
.. grid-item::
5659
:padding: 2
5760
:columns: 6
5861

5962
Section links
6063

64+
``navbar_center``
65+
6166
.. grid-item::
6267
:padding: 2
6368
:columns: 3
6469

6570
Components
6671

72+
``navbar_end``
73+
6774
.. grid-item::
6875
:padding: 2
6976
:outline:
@@ -78,6 +85,10 @@ You can click on section titles to learn more about them and some basic layout c
7885

7986
Links between pages in the active section.
8087

88+
``sidebars``
89+
90+
``primary_sidebar_end``
91+
8192
.. grid-item::
8293
:columns: 8
8394

@@ -88,7 +99,7 @@ You can click on section titles to learn more about them and some basic layout c
8899
.. grid-item::
89100
:class: content
90101
:padding: 2
91-
:columns: 8
102+
:columns: 6
92103
:outline:
93104

94105
.. button-ref:: layout-article-header
@@ -97,6 +108,9 @@ You can click on section titles to learn more about them and some basic layout c
97108

98109
Article Header
99110

111+
``article_header_start``
112+
``article_header_end``
113+
100114
**Article Content**
101115

102116
.. button-ref:: layout-article-footer
@@ -107,7 +121,7 @@ You can click on section titles to learn more about them and some basic layout c
107121

108122
.. grid-item::
109123
:padding: 2
110-
:columns: 4
124+
:columns: 6
111125
:outline:
112126
:class: sidebar-secondary
113127

@@ -119,6 +133,8 @@ You can click on section titles to learn more about them and some basic layout c
119133

120134
Within-page header links
121135

136+
``secondary_sidebar_items``
137+
122138
.. grid::
123139
:margin: 0
124140
:gutter: 0
@@ -149,7 +165,8 @@ You can click on section titles to learn more about them and some basic layout c
149165

150166
Footer
151167

152-
Site-wide links.
168+
``footer_start``
169+
``footer_end``
153170

154171
Horizontal spacing
155172
------------------
@@ -425,18 +442,27 @@ Footer
425442
Located in ``sections/footer.html``.
426443

427444
The footer is just below a page’s main content, and is configured in ``conf.py``
428-
with ``html_theme_options['footer_items']``.
445+
with ``html_theme_options['footer_start']`` and ``html_theme_options['footer_end']``.
429446

430-
By default, it has the following templates:
447+
By default, ``footer_end`` is empty, and ``footer_start`` has the following templates:
431448

432449
.. code-block:: python
433450
434451
html_theme_options = {
435452
...
436-
"footer_items": ["copyright", "sphinx-version", "theme-version"],
453+
"footer_start": ["copyright", "sphinx-version", "theme-version"],
437454
...
438455
}
439456
457+
Within each subsection, components will stack **vertically**.
458+
If you'd like them to stack **horizontally** use a custom CSS rule like the following:
459+
460+
.. code-block:: scss
461+
462+
.footer-items__start, .footer-items__end {
463+
flex-direction: row;
464+
}
465+
440466
Change footer display
441467
---------------------
442468

docs/user_guide/search.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ You can also configure some aspects of the search button and search field, descr
1414
Configure the search field position
1515
-----------------------------------
1616

17-
The position of the search *button* is controlled by ``search-button`` and by default is included in ``html_theme_options["navbar_persistent"]``; you may move it elsewhere as befits your site's layout, or remove it. You can also add an always-visible search field to some/all pages in your site by adding ``search-field.html`` to one of the configuration variables (e.g., ``html_sidebars``, ``html_theme_options["footer_items"]``, etc).
17+
The position of the search *button* is controlled by ``search-button`` and by default is included in ``html_theme_options["navbar_persistent"]``; you may move it elsewhere as befits your site's layout, or remove it.
18+
You can also add an always-visible search field to some/all pages in your site by adding ``search-field.html`` to one of the configuration variables (e.g., ``html_sidebars``, ``html_theme_options["footer_start"]``, etc).
1819

1920
For example, if you'd like the search field to be in your side-bar, add it to
2021
the sidebar templates like so:

docs/user_guide/version-dropdown.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The switcher requires the following configuration steps:
2323

2424
3. Specify where to place the switcher in your page layout. For example, add
2525
the ``"version-switcher"`` template to one of the layout lists in
26-
``html_theme_options`` (e.g., ``navbar_end``, ``footer_items``, etc).
26+
``html_theme_options`` (e.g., ``navbar_end``, ``footer_start``, etc).
2727

2828
Below is a more in-depth description of each of these configuration steps.
2929

@@ -156,7 +156,7 @@ Specify where to display the switcher
156156
Finally, tell the theme where on your site's pages you want the switcher to
157157
appear. There are many choices here: you can add ``"version-switcher"`` to one
158158
of the locations in ``html_theme_options`` (e.g., ``navbar_end``,
159-
``footer_items``, etc). For example:
159+
``footer_start``, etc). For example:
160160

161161
.. code:: python
162162

src/pydata_sphinx_theme/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ def update_config(app):
6767
"Use `secondary_sidebar_items`."
6868
)
6969

70+
# DEPRECATE after 0.14
71+
if theme_options.get("footer_items"):
72+
theme_options["footer_start"] = theme_options.get("footer_items")
73+
logger.warning(
74+
"`footer_items` is deprecated. Use `footer_start` or `footer_end` instead."
75+
)
76+
7077
# Validate icon links
7178
if not isinstance(theme_options.get("icon_links", []), list):
7279
raise ExtensionError(
@@ -205,7 +212,8 @@ def update_and_remove_templates(app, pagename, templatename, context, doctree):
205212
"theme_navbar_end",
206213
"theme_article_header_start",
207214
"theme_article_header_end",
208-
"theme_footer_items",
215+
"theme_footer_start",
216+
"theme_footer_end",
209217
"theme_secondary_sidebar_items",
210218
"theme_primary_sidebar_end",
211219
"sidebars",

src/pydata_sphinx_theme/assets/scripts/pydata-sphinx-theme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function checkPageExistsAndRedirect(event) {
305305
}
306306

307307
// Populate the version switcher from the JSON config file
308-
var themeSwitchBtns = document.querySelectorAll("version-switcher__button");
308+
var themeSwitchBtns = document.querySelectorAll(".version-switcher__button");
309309
if (themeSwitchBtns.length) {
310310
fetch(DOCUMENTATION_OPTIONS.theme_switcher_json_url)
311311
.then((res) => {

src/pydata_sphinx_theme/assets/styles/components/_icon-links.scss

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,24 @@
22
* Icon links in the navbar
33
*/
44

5-
#navbar-icon-links {
5+
.navbar-icon-links {
6+
display: flex;
7+
flex-direction: row;
8+
column-gap: 1rem;
9+
10+
// Remove the padding so that we can define it with flexbox gap above
11+
li.nav-item a.nav-link {
12+
padding-left: 0;
13+
padding-right: 0;
14+
}
15+
16+
// Spacing and centering
17+
a span {
18+
display: flex;
19+
align-items: center;
20+
}
21+
22+
// Icons styling
623
i {
724
&.fa-brands,
825
&.fa-regular,
@@ -12,7 +29,7 @@
1229
font-size: var(--pst-font-size-icon);
1330
}
1431

15-
/* Social media buttons */
32+
/* Social media buttons hard-code the brand color */
1633
&.fa-square-twitter:before {
1734
color: #55acee;
1835
}
@@ -26,29 +43,9 @@
2643
}
2744
}
2845

46+
// Force images to be icon-sized
2947
img.icon-link-image {
3048
height: 1.5em;
3149
border-radius: 0.2rem;
3250
}
33-
34-
li:first-child a {
35-
padding-left: 0;
36-
}
37-
38-
a span {
39-
display: flex;
40-
align-items: center;
41-
}
42-
43-
// inline the element in the navbar as long as they fit and use display block when collapsing
44-
// One breakpoint less than $breakpoint-sidebar-primary.
45-
// See variables/_layout.scss for more info.
46-
@include media-breakpoint-down(lg) {
47-
flex-direction: row;
48-
49-
// Use Bootstrap padding for these nav links to get the spacing right
50-
a {
51-
padding: 0rem 0.5rem;
52-
}
53-
}
5451
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* The list of in-page TOC links
3+
*/
4+
.page-toc {
5+
.section-nav {
6+
padding-left: 0;
7+
border-bottom: none;
8+
9+
ul {
10+
padding-left: 1rem;
11+
}
12+
}
13+
14+
// override bootstrap settings
15+
.nav-link {
16+
font-size: var(--pst-sidebar-font-size-mobile);
17+
@include media-breakpoint-up($breakpoint-sidebar-secondary) {
18+
font-size: var(--pst-sidebar-font-size);
19+
}
20+
}
21+
22+
.onthispage {
23+
color: var(--pst-color-text-base);
24+
font-weight: var(--pst-sidebar-header-font-weight);
25+
margin-bottom: 0.5rem;
26+
}
27+
}

src/pydata_sphinx_theme/assets/styles/components/_searchbox.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ div#searchbox {
3636
text-decoration: none;
3737
}
3838

39-
// add icon via CSS because the link is created by javascript
40-
// match padding to .toc-item > i above
4139
&:before {
4240
content: var(--pst-icon-search-minus);
4341
color: unset;

src/pydata_sphinx_theme/assets/styles/pydata-sphinx-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
@import "./components/icon-links";
3737
@import "./components/header/header-logo";
3838
@import "./components/navbar-links";
39+
@import "./components/page-toc";
3940
@import "./components/prev-next";
4041
@import "./components/search";
4142
@import "./components/searchbox";

src/pydata_sphinx_theme/assets/styles/sections/_footer.scss

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
1-
footer.bd-footer {
2-
width: 100%;
3-
border-top: 1px solid var(--pst-color-border);
4-
padding: 10px;
1+
.bd-footer {
2+
.bd-footer__inner {
3+
border-top: 1px solid var(--pst-color-border);
4+
padding: 1rem 2rem;
5+
display: flex;
6+
flex-grow: 1;
7+
}
8+
9+
.footer-items__start,
10+
.footer-items__end {
11+
display: flex;
12+
flex-direction: column;
13+
gap: 0.5rem;
14+
justify-content: center;
15+
}
16+
17+
.footer-items__end {
18+
margin-left: auto;
19+
}
520

21+
// So that paragraphs don't take up extra room
622
.footer-item p {
723
margin-bottom: 0;
824
}

src/pydata_sphinx_theme/assets/styles/sections/_header-article.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
.header-article__inner {
2-
min-height: var(--pst-header-article-height);
32
display: flex;
43
padding: 0 0.5rem;
54

5+
// The items define the height so that it disappears if there are no items
6+
.header-article-item {
7+
min-height: var(--pst-header-article-height);
8+
height: var(--pst-header-article-height);
9+
}
10+
611
.header-article-items__start,
712
.header-article-items__end {
813
display: flex;

src/pydata_sphinx_theme/assets/styles/sections/_header.scss

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
}
3737

3838
// These items will define the height of the header
39-
.navbar-start-item,
40-
.navbar-center-item,
41-
.navbar-end-item {
39+
.navbar-item {
4240
height: var(--pst-header-height);
4341
max-height: var(--pst-header-height);
4442
display: flex;
@@ -126,7 +124,7 @@
126124

127125
// inline the element in the navbar as long as they fit and use display block when collapsing
128126
@include media-breakpoint-up($breakpoint-sidebar-primary) {
129-
.navbar-center-item {
127+
.navbar-center-items .navbar-item {
130128
display: inline-block;
131129
}
132130
}

src/pydata_sphinx_theme/assets/styles/sections/_sidebar-primary.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@
4747
color: var(--pst-color-text-base);
4848
}
4949

50-
.sidebar-start-items__item,
51-
.sidebar-end-items__item {
52-
padding: 0.5rem 0;
50+
.sidebar-start-items,
51+
.sidebar-end-items {
52+
.sidebar-primary-item {
53+
padding: 0.5rem 0;
54+
}
5355
}
5456

5557
// Hide the sidebar header items on widescreen since they are visible in the header

0 commit comments

Comments
 (0)