Skip to content

Commit 10abea3

Browse files
OriolAbriltwiecki
andauthored
update navbar (#344)
* update navbar * Merge conflict. Co-authored-by: Thomas Wiecki <[email protected]>
1 parent 1a13e1f commit 10abea3

File tree

8 files changed

+85
-94
lines changed

8 files changed

+85
-94
lines changed

_static/custom.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@
1111
.bd-sidebar {
1212
overflow-y: auto;
1313
}
14+
15+
.navbar-brand {
16+
display: inline-block !important;
17+
}
18+
19+
.supportbutton a {
20+
color: var(--pst-color-sidebar-link-active);
21+
}

_templates/donate.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% if "generated" in sourcename %}
2+
<div class="tocsection editthispage">
3+
{% else %}
4+
<div class="tocsection supportbutton">
5+
{% endif %}
6+
<a href="https://numfocus.org/donate-to-pymc3">
7+
<i class="far fa-heart"></i> {{ _("Support PyMC") }}
8+
</a>
9+
</div>

_templates/search-field.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<form class="bd-search d-flex align-items-center" action="https://www.pymc.io/search.html" method="get">
2+
<i class="icon fas fa-search"></i>
3+
<input type="search" class="form-control" name="q" id="search-input" placeholder="{{ _(theme_search_bar_text) }}" aria-label="{{ theme_search_bar_text }}" autocomplete="off" >
4+
</form>

examples/blog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
orphan: true
3+
---
4+
15
# Recent updates
26

37
<!-- auto generated by ablog so it's empty -->

examples/conf.py

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os, sys
2+
from pathlib import Path
23
from sphinx.application import Sphinx
34

45
# -- Project information -----------------------------------------------------
@@ -26,6 +27,8 @@
2627
"notfound.extension",
2728
"sphinx_gallery.load_style",
2829
"thumbnail_extractor",
30+
"sphinxext.rediraffe",
31+
"sphinx_remove_toctrees",
2932
]
3033

3134
# List of patterns, relative to source directory, that match files and
@@ -85,8 +88,22 @@ def do_nothing(*node):
8588
toctree.TocTree.resolve = patched_toctree_resolve
8689

8790

91+
def remove_index(app):
92+
"""
93+
This removes the index pages so rediraffe generates the redirect placeholder
94+
It needs to be present initially for the toctree as it defines the navbar.
95+
"""
96+
97+
index_file = Path(app.outdir) / "index.html"
98+
index_file.unlink()
99+
100+
app.env.project.docnames -= {"index"}
101+
yield "", {}, "layout.html"
102+
103+
88104
def setup(app: Sphinx):
89105
hack_nbsphinx(app)
106+
app.connect("html-collect-pages", remove_index, 100)
90107

91108

92109
# -- Options for HTML output -------------------------------------------------
@@ -108,6 +125,11 @@ def setup(app: Sphinx):
108125
"url": "https://twitter.com/pymc_devs",
109126
"icon": "fab fa-twitter-square",
110127
},
128+
{
129+
"name": "YouTube",
130+
"url": "https://www.youtube.com/c/PyMCDevelopers",
131+
"icon": "fab fa-youtube",
132+
},
111133
{
112134
"name": "Discourse",
113135
"url": "https://discourse.pymc.io",
@@ -116,13 +138,9 @@ def setup(app: Sphinx):
116138
],
117139
"search_bar_text": "Search...",
118140
"navbar_end": ["search-field.html", "navbar-icon-links.html"],
119-
"external_links": [
120-
{"name": "Contributing", "url": "https://docs.pymc.io/en/latest/contributing/index.html"},
121-
{"name": "docs.pymc.io", "url": "https://docs.pymc.io"},
122-
{"name": "pymc.io", "url": "https://www.pymc.io"},
123-
],
124-
"page_sidebar_items": ["postcard", "page-toc", "edit-this-page"],
141+
"page_sidebar_items": ["postcard", "page-toc", "edit-this-page", "donate"],
125142
"google_analytics_id": "G-6KPRBTE6WV",
143+
"logo_link": "https://www.pymc.io",
126144
}
127145
version = os.environ.get("READTHEDOCS_VERSION", "")
128146
version = version if "." in version else "main"
@@ -141,6 +159,7 @@ def setup(app: Sphinx):
141159

142160
html_favicon = "../_static/PyMC.ico"
143161
html_logo = "../_static/PyMC.png"
162+
html_title = "PyMC example gallery"
144163

145164
# Add any paths that contain custom static files (such as style sheets) here,
146165
# relative to this directory. They are copied after the builtin static files,
@@ -151,7 +170,7 @@ def setup(app: Sphinx):
151170
templates_path = ["../_templates"]
152171
html_sidebars = {
153172
"**": [
154-
# "sidebar-nav-bs.html",
173+
"sidebar-nav-bs.html",
155174
"postcard_categories.html",
156175
"tagcloud.html",
157176
],
@@ -193,6 +212,25 @@ def setup(app: Sphinx):
193212
}
194213
jupyter_execute_notebooks = "off"
195214

215+
rediraffe_redirects = {
216+
"index.md": "gallery.md",
217+
}
218+
remove_from_toctrees = [
219+
"BART/*",
220+
"case_studies/*",
221+
"diagnostics_and_criticism/*",
222+
"gaussian_processes/*",
223+
"generalized_linear_models/*",
224+
"mixture_models/*",
225+
"ode_models/*",
226+
"pymc3_howto/*",
227+
"samplers/*",
228+
"splines/*",
229+
"survival_analysis/*",
230+
"time_series/*",
231+
"variational_inference/*",
232+
]
233+
196234
# bibtex config
197235
bibtex_bibfiles = ["references.bib"]
198236
bibtex_default_style = "unsrt"

examples/gallery.rst

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
Gallery
2-
=======
1+
PyMC Example Gallery
2+
====================
33

4+
.. toctree::
5+
:hidden:
6+
7+
object_index/index
48

59
(Generalized) Linear and Hierarchical Linear Models
610
-------------------------
711

812
.. nbgallery::
9-
:caption: This is a thumbnail gallery:
1013
:name: generalized_linear_models
1114
:glob:
1215
:reversed:
@@ -18,7 +21,6 @@ Case Studies
1821
------------
1922

2023
.. nbgallery::
21-
:caption: This is a thumbnail gallery:
2224
:name: case_studies
2325
:glob:
2426
:reversed:
@@ -29,7 +31,6 @@ Diagnostics and Model Criticism
2931
-------------------------------
3032

3133
.. nbgallery::
32-
:caption: This is a thumbnail gallery:
3334
:name: diagnostics_and_criticism
3435
:glob:
3536
:reversed:
@@ -41,7 +42,6 @@ Gaussian Processes
4142
------------------
4243

4344
.. nbgallery::
44-
:caption: This is a thumbnail gallery:
4545
:name: gaussian_processes
4646
:glob:
4747
:reversed:
@@ -52,7 +52,6 @@ Inference in ODE models
5252
-----------------------
5353

5454
.. nbgallery::
55-
:caption: This is a thumbnail gallery:
5655
:name: ode_models
5756
:glob:
5857
:reversed:
@@ -63,7 +62,6 @@ MCMC
6362
----
6463

6564
.. nbgallery::
66-
:caption: This is a thumbnail gallery:
6765
:name: samplers
6866
:glob:
6967
:reversed:
@@ -74,7 +72,6 @@ Mixture Models
7472
--------------
7573

7674
.. nbgallery::
77-
:caption: This is a thumbnail gallery:
7875
:name: mixture_models
7976
:glob:
8077
:reversed:
@@ -85,7 +82,6 @@ Survival Analysis
8582
-----------------
8683

8784
.. nbgallery::
88-
:caption: This is a thumbnail gallery:
8985
:name: survival_analysis
9086
:glob:
9187
:reversed:
@@ -96,7 +92,6 @@ Time Series
9692
-----------
9793

9894
.. nbgallery::
99-
:caption: This is a thumbnail gallery:
10095
:name: time_series
10196
:glob:
10297
:reversed:
@@ -107,7 +102,6 @@ Variational Inference
107102
---------------------
108103

109104
.. nbgallery::
110-
:caption: This is a thumbnail gallery:
111105
:name: variational_inference
112106
:glob:
113107
:reversed:

examples/index.md

Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,12 @@
11
# PyMC example gallery
22

3-
**Welcome to the PyMC example gallery!**
4-
5-
The PyMC example gallery is a collection of Jupyter notebooks
6-
about PyMC and its usage. These notebooks can be tutorials,
7-
case studies or in-depth explanations.
8-
Some notebooks were originally blog posts, others were adapted from books
9-
and some were written specifically for this example gallery.
10-
This homepage explains the organization of the website and provides
11-
some pointers on how to navigate it.
12-
13-
The collection contains more than 90 notebooks. We are therefore unable
14-
to ensure notebooks are updated and re-executed at the same pace we
15-
publish PyMC releases. Consequently, PyMC has two documentation
16-
websites: the versioned docs and the example gallery
17-
18-
## Versioned docs
19-
We publish the versioned docs directly at `docs.pymc.io`. The only additions
20-
to the url are the language and version of the documentation.
21-
22-
The versioned docs are synced with PyMC releases and contain a handful of
23-
guides about core functionality and the API documentation among other things.
24-
25-
## Example gallery
26-
We publish the example gallery as a sub-project of the versioned docs: `docs.pymc.io/projects/examples`
27-
This means that the building process, language and version of the
28-
example gallery are independent from the versioned docs. However,
29-
the {ref}`search bar in the versioned docs <pymc:search>` searches
30-
both the versioned docs and the example gallery at the same time
31-
(but not the other way around).
32-
33-
We will update the notebooks in the example gallery regularly
34-
and publish the updates to the example gallery website with each commit.
35-
We recommend using the example gallery as an unversioned living
36-
resource, but we will also provide snapshots every few months for cases such as books
37-
that need links to a stable resource.
38-
39-
You can access the snapshots from the version menu at the bottom right of the page.
40-
A version number in the `YYYY.0M.MICRO` format identifies the time the snapshot was published.
41-
42-
---
43-
44-
Notebooks are treated as blog posts. The metadata of each notebook
45-
describes its topics and type of content via tags and categories
46-
and the last update date. We believe that tags and categories
47-
ease and improve navigation (as opposed to a fixed topic division/hierarchy).
48-
In addition, we also provide a list of recent updates and a search bar in the
49-
navigation bar at the top of the page.
50-
51-
:::{caution}
52-
The website is still under construction. Thus, not all notebooks have been updated
53-
to include all the relevant metadata. Those notebooks can only be reached
54-
from the search bar.
55-
:::
56-
57-
### Categories
58-
Notebooks have at most two categories, one indicating the level of the
59-
notebook and another indicating the type of content according to the
60-
[diataxis framework](https://diataxis.fr/). The left sidebar
61-
shows all 7 categories (3 levels + 4 types) at all times. You can click
62-
there to reach the page listing all the notebooks in that category.
63-
If a page has some categories in its metadata they are highlighted in green
64-
in the category list.
65-
66-
### Tags
67-
Notebooks can have any number of tags. Each tag represents a specific topic
68-
of potential interest to readers or a pymc object used within that notebook.
69-
70-
The left sidebar shows all tags at all times. Like categories, they can be clicked
71-
on to reach the page listing all notebooks that contain the tag. If a notebook
72-
has tags in its metadata they are listed on the right sidebar after the {fas}`tags` icon.
73-
743
:::{toctree}
75-
:maxdepth: 1
764
:hidden:
77-
gallery
78-
blog
79-
object_index/index
5+
6+
Home <https://www.pymc.io>
7+
Examples <gallery>
8+
User guide <https://www.pymc.io/projects/docs/en/latest/learning.html>
9+
API <https://www.pymc.io/projects/docs/en/latest/api.html>
10+
Community <https://www.pymc.io/community/index.html>
11+
Contributing <https://www.pymc.io/projects/docs/en/latest/contributing/index.html>
8012
:::

requirements-docs.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ sphinx-notfound-page
1111
nbsphinx
1212
sphinx-gallery
1313
matplotlib
14+
sphinxext-rediraffe
15+
sphinx-remove-toctrees

0 commit comments

Comments
 (0)