Skip to content

Commit c8f6e24

Browse files
authored
Include by default a HoloViz dropdown in the primary sidebar with links to all the HoloViz sites (#319)
1 parent 7c4c941 commit c8f6e24

File tree

4 files changed

+167
-22
lines changed

4 files changed

+167
-22
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* Sidebar styling for the HoloViz dropdown section */
2+
.hv-sb-dd {
3+
margin-bottom: 0.5em;
4+
}
5+
6+
.hv-sb-dd .btn-group {
7+
width: 100%;
8+
}
9+
10+
.hv-sb-dd .hv-sb-dd-value {
11+
text-align: start;
12+
font-size: 0.9rem;
13+
}
14+
15+
.hv-sb-dd .btn {
16+
background-color: var(--pst-color-surface);
17+
color: var(--pst-color-text-base);
18+
}
19+
20+
.hv-sb-dd a.btn:hover {
21+
color: var(--pst-color-link-hover);
22+
text-decoration: underline;
23+
text-decoration-thickness: max(3px, 0.1875rem, 0.12em);
24+
}
25+
26+
.hv-sb-dd .dropdown-toggle-split {
27+
border-left: solid 1px lightgray;
28+
}
29+
30+
.hv-sb-dd .dropdown-menu {
31+
width: 100%;
32+
background-color: var(--pst-color-surface);
33+
color: var(--pst-color-text-base);
34+
}
35+
36+
.hv-sb-dd .dropdown-item {
37+
font-size: 0.8rem;
38+
}
39+
40+
.hv-sb-dd .hv-icon {
41+
font-size: 0.75em;
42+
margin-left: 0.3em;
43+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% if hv_sidebar_dropdown %}
2+
<div class="hv-sb-dd">
3+
<div class="btn-group">
4+
{% if 'href' in hv_sidebar_dropdown['dropdown_value'] %}
5+
<a href="{{ hv_sidebar_dropdown['dropdown_value']['href'] }}" class="btn hv-sb-dd-value" target="_blank">{{ hv_sidebar_dropdown['dropdown_value']['text'] }}<i class="fa fa-external-link hv-icon" aria-hidden="true"></i></a>
6+
{% else %}
7+
<span class="btn hv-sb-dd-value">{{ hv_sidebar_dropdown['dropdown_value']['text'] }}</span>
8+
{% endif %}
9+
<button type="button" class="btn dropdown-toggle dropdown-toggle-split" data-bs-toggle="dropdown" aria-expanded="false">
10+
<span class="visually-hidden"></span>
11+
</button>
12+
<ul class="dropdown-menu">
13+
{% for project_name, project_opts in hv_sidebar_dropdown['libraries'].items() %}
14+
{% if project_name | lower not in project | lower %}
15+
<li><a class="dropdown-item" href="{{ project_opts['url'] }}" target="_blank" title="{{ project_opts['title'] }}">{{ project_opts['text'] }}<i class="fa fa-external-link hv-icon" aria-hidden="true"></i></a></li>
16+
{% endif %}
17+
{% endfor %}
18+
{% if hv_sidebar_dropdown['others'] %}
19+
<li><hr class="dropdown-divider"></li>
20+
{% for project_name, project_opts in hv_sidebar_dropdown['others'].items() %}
21+
{% if project_name | lower not in project | lower %}
22+
<li><a class="dropdown-item" href="{{ project_opts['url'] }}" target="_blank" title="{{ project_opts['title'] }}">{{ project_opts['text'] }}<i class="fa fa-external-link hv-icon" aria-hidden="true"></i></a></li>
23+
{% endif %}
24+
{% endfor %}
25+
{% endif %}
26+
</ul>
27+
</div>
28+
</div>
29+
{% endif %}

nbsite/shared_conf.py

Lines changed: 95 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,6 @@ def holoviz_icon_white(cur_file):
2424
return str(icon_path)
2525

2626

27-
def setup(app):
28-
try:
29-
from nbsite.paramdoc import param_formatter, param_skip
30-
app.connect('autodoc-process-docstring', param_formatter)
31-
app.connect('autodoc-skip-member', param_skip)
32-
except ImportError:
33-
print('no param_formatter (no param?)')
34-
35-
nbbuild.setup(app)
36-
app.connect("builder-inited", remove_mystnb_static)
37-
38-
def remove_mystnb_static(app):
39-
# Ensure our myst_nb.css is loaded by removing myst_nb static_path
40-
# from config
41-
app.config.html_static_path = [
42-
p for p in app.config.html_static_path if 'myst_nb' not in p
43-
]
44-
4527
extensions = [
4628
'myst_nb',
4729
'sphinx_design',
@@ -105,7 +87,8 @@ def remove_mystnb_static(app):
10587
'gallery.css',
10688
'alert.css',
10789
'dataframe.css',
108-
'scroller.css'
90+
'scroller.css',
91+
'hv-sidebar-dropdown.css',
10992
]
11093

11194
# A single line footer that includes the copyright and the last updated date.
@@ -123,8 +106,8 @@ def remove_mystnb_static(app):
123106
# The layout.html template in pydata-sphinx-theme removes the default
124107
# sidebar-nav-bs.html template.
125108
html_sidebars = {
126-
"index": ["sidebar-nav-bs-alt"],
127-
"**": ["sidebar-nav-bs-alt"],
109+
"index": ["sidebar-nav-bs-alt", "hv-sidebar-dropdown"],
110+
"**": ["sidebar-nav-bs-alt", "hv-sidebar-dropdown"],
128111
}
129112

130113
# To be reused in a conf.py file to define the `copyright` string reused
@@ -207,3 +190,94 @@ def linkcode_resolve(domain, info):
207190
return f"{GITHUB_BASE_URL}{package}/blob/main/{package}/{fn}{linespec}"
208191
else:
209192
return f"{GITHUB_BASE_URL}{package}/blob/v{pver}/{package}/{fn}{linespec}"
193+
194+
195+
nbsite_hv_sidebar_dropdown = {
196+
'dropdown_value': {
197+
'href': 'https://holoviz.org',
198+
'text': 'HoloViz.org',
199+
},
200+
'libraries': {
201+
'panel': {
202+
'text': 'Panel',
203+
'url': 'https://param.holoviz.org',
204+
'title': 'Assembling objects from many different libraries into a layout or app, whether in a Jupyter notebook or in a standalone servable dashboard',
205+
},
206+
'hvplot': {
207+
'text': 'hvPlot',
208+
'url': 'https://hvplot.holoviz.org',
209+
'title': 'Quickly return interactive HoloViews, GeoViews, or Panel objects from Pandas, Xarray, or other data structures',
210+
},
211+
'holoviews': {
212+
'text': 'HoloViews',
213+
'url': 'https://holoviews.org',
214+
'title': 'Declarative objects for instantly visualizable data, building Bokeh plots from convenient high-level specifications',
215+
},
216+
'geoviews': {
217+
'text': 'GeoViews',
218+
'url': 'https://geoviews.org',
219+
'title': 'Visualizable geographic data that that can be mixed and matched with HoloViews objects',
220+
},
221+
'datashader': {
222+
'text': 'Datashader',
223+
'url': 'https://datashader.org',
224+
'title': 'Rasterizing huge datasets quickly as fixed-size images',
225+
},
226+
'param': {
227+
'text': 'Param',
228+
'url': 'https://param.holoviz.org',
229+
'title': 'Make your Python code clearer and more reliable by declaring Parameters',
230+
},
231+
'lumen': {
232+
'text': 'Lumen',
233+
'url': 'https://lumen.holoviz.org',
234+
'title': 'Framework for visual analytics that allows users to build data-driven dashboards from a simple YAML specification',
235+
},
236+
'colorcet': {
237+
'text': 'Colorcet',
238+
'url': 'https://colorcet.holoviz.org',
239+
'title': 'A wide range of perceptually uniform continuous colormaps and perceptually based categorical color sets for use with the other libraries',
240+
},
241+
},
242+
'others': {
243+
'examples': {
244+
'text': 'Examples Gallery',
245+
'url': 'https://examples.holoviz.org',
246+
'title': ' Visualization-focused examples using HoloViz for specific topics ',
247+
},
248+
'blog': {
249+
'text': 'Blog',
250+
'url': 'https://blog.holoviz.org',
251+
'title': 'HoloViz blog',
252+
},
253+
},
254+
}
255+
256+
257+
def remove_mystnb_static(app):
258+
# Ensure our myst_nb.css is loaded by removing myst_nb static_path
259+
# from config
260+
app.config.html_static_path = [
261+
p for p in app.config.html_static_path if 'myst_nb' not in p
262+
]
263+
264+
265+
def add_hv_sidebar_dropdown_context(app, pagename, templatename, context, doctree, *args) -> None:
266+
# Inject it in the context to make it available to the template namespace.s
267+
context['hv_sidebar_dropdown'] = app.config.nbsite_hv_sidebar_dropdown
268+
269+
270+
def setup(app):
271+
try:
272+
from nbsite.paramdoc import param_formatter, param_skip
273+
app.connect('autodoc-process-docstring', param_formatter)
274+
app.connect('autodoc-skip-member', param_skip)
275+
except ImportError:
276+
print('no param_formatter (no param?)')
277+
278+
nbbuild.setup(app)
279+
app.connect("builder-inited", remove_mystnb_static)
280+
281+
# hv_sidebar_dropdown
282+
app.add_config_value('nbsite_hv_sidebar_dropdown', {}, 'html')
283+
app.connect("html-page-context", add_hv_sidebar_dropdown_context)

site/doc/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
"icon": "fab fa-discourse",
7070
},
7171
],
72-
"navbar_end": ["navbar-icon-links"],
7372
"pygments_light_style": "material",
7473
"pygments_dark_style": "material",
7574
'secondary_sidebar_items': [

0 commit comments

Comments
 (0)