Skip to content

Commit 1e43cc7

Browse files
authored
Switch docs site to pydata-sphinx-theme (#368)
- Change html_theme from quantecon_book_theme to pydata_sphinx_theme - Update html_theme_options for pydata compatibility (github icon, PyPI link, edit button) - Add html_context for GitHub edit links - Remove sphinx_thebe extension (theme-specific) - Remove templates_path (no _templates dir exists) - Add pydata-sphinx-theme>=0.15 to [doc] dependencies - Remove sphinx-thebe from [doc] dependencies - Convert {margin} directives to {tip}/{admonition} (margin is sphinx-book-theme specific) - Remove GitHub external link from toctree (now shown as header icon)
1 parent 3d4be18 commit 1e43cc7

7 files changed

Lines changed: 42 additions & 47 deletions

File tree

docs/conf.py

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@
1616
"sphinx_copybutton",
1717
"sphinx_togglebutton",
1818
"sphinxcontrib.bibtex",
19-
"sphinx_thebe",
2019
"sphinx.ext.autodoc",
2120
"sphinx.ext.intersphinx",
2221
"sphinx.ext.viewcode",
2322
]
2423

25-
# Add any paths that contain templates here, relative to this directory.
26-
templates_path = ["_templates"]
27-
2824
# List of patterns, relative to source directory, that match files and
2925
# directories to ignore when looking for source files.
3026
# This pattern also affects html_static_path and html_extra_path.
@@ -43,12 +39,12 @@
4339

4440
# -- Options for HTML output -------------------------------------------------
4541

46-
# The theme to use for HTML and HTML Help pages. See the documentation for
47-
# a list of builtin themes.
48-
#
49-
html_theme = "quantecon_book_theme"
42+
# The theme to use for HTML and HTML Help pages.
43+
# We use pydata-sphinx-theme for the documentation site itself, while
44+
# quantecon_book_theme is the theme being documented.
45+
html_theme = "pydata_sphinx_theme"
5046
html_logo = "_static/qe-logo.png"
51-
html_title = "Quantecon Book Theme"
47+
html_title = "QuantEcon Book Theme"
5248
html_copy_source = True
5349
html_sourcelink_suffix = ""
5450
html_favicon = "_static/qe-logo.png"
@@ -62,37 +58,28 @@
6258
# -- Togglebutton configuration ----------------------------------------------
6359
togglebutton_hint = "Show"
6460
togglebutton_hint_hide = "Hide"
65-
thebe_config = {
66-
"repository_url": "https://github.com/binder-examples/jupyter-stacks-datascience",
67-
"repository_branch": "master",
68-
}
6961

7062
html_theme_options = {
71-
"path_to_docs": "docs",
72-
"repository_url": "https://github.com/QuantEcon/quantecon-book-theme",
73-
# "repository_branch": "gh-pages", # For testing
74-
"launch_buttons": {
75-
"binderhub_url": "https://mybinder.org",
76-
# "jupyterhub_url": "https://datahub.berkeley.edu", # For testing
77-
"colab_url": "https://colab.research.google.com/",
78-
"notebook_interface": "jupyterlab",
79-
"thebe": True,
80-
},
63+
"github_url": "https://github.com/QuantEcon/quantecon-book-theme",
8164
"use_edit_page_button": True,
82-
"use_issues_button": True,
83-
"use_repository_button": True,
84-
"expand_sections": ["reference/index"],
85-
# For testing
86-
# "home_page_in_toc": True,
87-
# "single_page": True
88-
# "extra_footer": "<a href='https://google.com'>Test</a>",
89-
# "extra_navbar": "<a href='https://google.com'>Test</a>",
90-
# Uncomment to test Pygments built-in styles:
91-
# "qetheme_code_style": False,
65+
"show_prev_next": True,
66+
"navigation_with_keys": False,
67+
"header_links_before_dropdown": 6,
68+
"icon_links": [
69+
{
70+
"name": "PyPI",
71+
"url": "https://pypi.org/project/quantecon-book-theme/",
72+
"icon": "fas fa-box",
73+
},
74+
],
9275
}
9376

94-
# Uncomment to test different Pygments styles:
95-
# pygments_style = "monokai"
77+
html_context = {
78+
"github_user": "QuantEcon",
79+
"github_repo": "quantecon-book-theme",
80+
"github_version": "main",
81+
"doc_path": "docs",
82+
}
9683

9784
bibtex_bibfiles = ["references.bib"]
9885
bibtex_reference_style = "author_year"

docs/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ developer/index
5757
5858
reference/index
5959
api/index
60-
GitHub Repository <https://github.com/QuantEcon/quantecon-book-theme>
6160
```
6261

6362
## Acknowledgements

docs/reference/markdown_limits.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,17 @@ Link to above: {eq}`my_label2`
219219

220220
Margin content can include all kinds of things, such as code blocks:
221221

222-
````{margin} Code blocks in margins
222+
````{admonition} Margin example — Code blocks
223+
:class: tip
223224
```python
224225
print("here is some python")
225226
```
226227
````
227228

228229
as well as admonitions and images:
229230

230-
````{margin} **Notes in margins**
231+
````{admonition} Margin example — Notes
232+
:class: tip
231233
```{note}
232234
Wow, a note with an image in a margin!
233235
![](../images/cool.jpg)
@@ -237,7 +239,7 @@ Wow, a note with an image in a margin!
237239

238240
Here's some margin content, let's see how it interacts w/ the toggle button
239241

240-
```{margin} My margin
242+
```{tip} Margin content
241243
Here's my margin content
242244
```
243245

docs/user/launch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ html_theme_options = {
2222
}
2323
```
2424

25-
```{margin} Paired ipynb files
25+
```{tip} Paired ipynb files
2626
If you're using [Jupytext](https://jupytext.readthedocs.io/en/latest/) to
2727
pair an ipynb file with your text files, and that ipynb file is in the same
2828
folder as your content, then Binder/JupyterHub links will point to the ipynb

docs/user/layout.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ Here is my margin content, it is pretty cool!
2727
```
2828
````
2929

30-
```{margin} **Here is my margin content**
31-
It is pretty cool!
30+
```{admonition} Margin example
31+
:class: tip
32+
In the quantecon-book-theme, this pops out to the right margin:
33+
34+
**Here is my margin content** — It is pretty cool!
3235
```
3336

3437
### Content sidebars
@@ -55,7 +58,9 @@ Here is my sidebar content, it is pretty cool!
5558

5659
Sidebar/margin content supports code blocks:
5760

58-
````{margin} Code blocks in margins
61+
````{admonition} Margin example — Code blocks
62+
:class: tip
63+
In the theme, this renders as a code block in the right margin:
5964
```python
6065
print("here is some python")
6166
```
@@ -71,7 +76,9 @@ print("here is some python")
7176

7277
As well as admonitions and images:
7378

74-
````{margin} **Notes in margins**
79+
````{admonition} Margin example — Notes
80+
:class: tip
81+
In the theme, this renders as a note in the right margin:
7582
```{note}
7683
Wow, a note with an image in a margin!
7784
![](../images/cool.jpg)
@@ -132,7 +139,7 @@ This content will be full-width
132139
This content will be full-width
133140
```
134141

135-
```{margin} A note for ipynb users
142+
```{tip} A note for ipynb users
136143
If you are using a Jupyter Notebook as inputs to your documentation using the
137144
[MyST-NB extension](https://myst-nb.readthedocs.io/en/latest/), you can trigger
138145
this behavior with a code cell by adding a `full-width` tag to the cell.

docs/user/notebooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ ax.legend(custom_lines, ['Cold', 'Medium', 'Hot'])
102102
ax.set(title="Smoother lines");
103103
```
104104

105-
```{margin} You can also pop out content to the margin
105+
```{tip} You can also pop out content to the margin
106106
For more information on how to do this,
107107
check out {doc}`layout`.
108108
```

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ code_style = [
5252
"pre-commit"
5353
]
5454
doc = [
55+
"pydata-sphinx-theme>=0.15",
5556
"folium",
5657
"numpy",
5758
"matplotlib",
@@ -60,7 +61,6 @@ doc = [
6061
"nbclient",
6162
"myst-nb",
6263
"sphinx-togglebutton>=0.2.1",
63-
"sphinx-thebe",
6464
"sphinx-copybutton",
6565
"docutils>=0.20",
6666
"plotly",

0 commit comments

Comments
 (0)