Skip to content

Commit 3578a9d

Browse files
authored
Docs: switch to sphinx-book-theme from pydata_sphinx_theme
The main reason for the switch is to have access to theme-specific elements like margin notes. Another major change compared to `pydata_sphinx_theme` is the absence of a top-level header, which has us move the contents overview into the sidebar. This has the advantage that the user immediately has a bird's eye glance of the documentation contents. Until the documentation becomes larger, this approach is preferable. Several changes are made to the sidebar: 1. Override the default `icon-links.html` component to include an AiiDA icon that links to the AiiDA website. 2. Override the `sbt-sidebar-nav.thml` component to adapt the default maxdepth. 3. A logo is added for dark mode. Some other additions and tweaks: 1. Added badged to the landing page instead of the release version. 2. Adapt the sidebar `toctree` to include captions and point directly to some subsections. 3. The Python API now has a `toctree` element with a clear name, and the `maxdepth` is adapted to make it more readable. 4. Several panels on the landing page are removed, since the corresponding top-level sections are no longer part of the `toctree`. This also makes the remaining panels to the `Get started` and tutorial sections more prominent. Finally, the `intersphinx_mapping` to the `aiida-core` docs is fixed, along with several broken references, mostly in the Hubbard docstring. The `pydantic` and `typing` related intersphinx warnings are ignored using `nitpick_ignore_regex`, since pydantic doesn't use `sphinx` and there seem to be issues with referencing `typing` classes.
1 parent 45e1907 commit 3578a9d

File tree

19 files changed

+167
-235
lines changed

19 files changed

+167
-235
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ ENV/
111111
submit_test/
112112

113113
# Autogenerated API docs
114-
docs/source/reference/api/aiida_quantumespresso
114+
docs/source/reference/api/auto

docs/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
2424
customdefault:
2525
$(SPHINXBUILD) -b html -nW --keep-going $(ALLSPHINXOPTS) $(BUILDDIR)/html
2626

27-
all: html view
27+
all: clean html view
2828

2929
clean:
3030
rm -rf $(BUILDDIR)
@@ -34,6 +34,5 @@ html:
3434
@echo
3535
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
3636

37-
3837
view:
3938
open $(BUILDDIR)/html/index.html

docs/source/_static/aiida-qe-custom.css

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,29 @@
1111
font-size: 140%;
1212
}
1313

14-
div.navbar-brand-box a.navbar-brand img {
15-
display: block;
16-
height: auto;
17-
width: auto;
18-
max-height: 100vh;
19-
max-width: 90%;
20-
margin: 0 auto;
21-
padding-left: 30px
14+
.navbar-brand {
15+
padding: 0;
16+
padding-top: 0.5rem;
17+
}
18+
19+
img.logo__image {
20+
max-height: 180px;
21+
padding-left: 1.5rem;
22+
padding-bottom: 1rem;
23+
}
24+
25+
.navbar-icon-links i.fa-brands {
26+
font-size: 40px!important;
27+
}
28+
29+
img.aiida-logo {
30+
height: 40px!important;
31+
}
32+
33+
.fa {
34+
color: var(--pst-color-primary);
2235
}
2336

24-
@media (min-width: 768px) {
25-
div.navbar-brand-box a.navbar-brand img {
26-
max-height: 100vh !important
27-
}
37+
.bd-search {
38+
padding: 0 1rem;
2839
}
File renamed without changes.
120 KB
Loading
File renamed without changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{%- macro icon_link_nav_item(url, icon, name, type, attributes='') -%}
2+
{%- if url | length > 2 %}
3+
<li class="nav-item">
4+
{%- set attributesDefault = { "href": url, "title": name, "class": "nav-link", "rel": "noopener", "target": "_blank", "data-bs-toggle": "tooltip", "data-bs-placement": "bottom"} %}
5+
{%- if attributes %}{% for key, val in attributes.items() %}
6+
{% set _ = attributesDefault.update(attributes) %}
7+
{% endfor %}{% endif -%}
8+
{% set attributeString = [] %}
9+
{% for key, val in attributesDefault.items() %}
10+
{%- set _ = attributeString.append('%s="%s"' % (key, val)) %}
11+
{% endfor %}
12+
{% set attributeString = attributeString | join(" ") -%}
13+
<a {{ attributeString }}>
14+
{%- if type == "fontawesome" -%}
15+
<span><i class="{{ icon }} fa-lg" aria-hidden="true"></i></span>
16+
<span class="sr-only">{{ name }}</span>
17+
{%- elif type == "local" -%}
18+
<img src="{{ pathto(icon, 1) }}" class="icon-link-image" alt="{{ name }}"/>
19+
{%- elif type == "url" -%}
20+
<img src="{{ icon }}" class="icon-link-image" alt="{{ name }}"/>
21+
{%- else %}
22+
<span>Incorrectly configured icon link. Type must be `fontawesome`, `url` or `local`.</span>
23+
{%- endif -%}
24+
</a>
25+
</li>
26+
{%- endif -%}
27+
{%- endmacro -%}
28+
{%- if theme_icon_links -%}
29+
<ul class="navbar-icon-links navbar-nav"
30+
aria-label="{{ theme_icon_links_label }}">
31+
<li class="nav-item">
32+
<a href="https://aiida.net/">
33+
<img src="{{ pathto('_static/logo_aiida.svg', 1) }}" alt="AiiDA" class="aiida-logo">
34+
</a>
35+
</li>
36+
{%- for icon_link in theme_icon_links -%}
37+
{{ icon_link_nav_item(icon_link["url"], icon_link["icon"], icon_link["name"], icon_link.get("type", "fontawesome"), icon_link.get("attributes", {})) -}}
38+
{%- endfor %}
39+
</ul>
40+
{%- endif -%}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<nav class="bd-links" id="bd-docs-nav" aria-label="Main">
2+
<div class="bd-toc-item navbar-nav active">
3+
{% if theme_home_page_in_toc == True %}
4+
{#- This mimicks the pydata theme list style so we can append an extra item at the top #}
5+
<ul class="nav bd-sidenav bd-sidenav__home-link">
6+
<li class="toctree-l1{% if pagename == root_doc %} current active{% endif %}">
7+
<a class="reference internal" href="{{ pathto(root_doc) }}">
8+
{{ root_title }}
9+
</a>
10+
</li>
11+
</ul>
12+
{% endif -%}
13+
14+
{# Ref: https://github.com/pydata/pydata-sphinx-theme/blob/ebf7f704879a1cdc6016d6111062103353ac7677/src/pydata_sphinx_theme/__init__.py#L302 #}
15+
{{- generate_toctree_html(
16+
startdepth=0,
17+
kind="sidebar",
18+
maxdepth=2,
19+
collapse=False,
20+
includehidden=True,
21+
titles_only=True,
22+
show_nav_level=theme_show_navbar_depth) }}
23+
</div>
24+
</nav>

docs/source/conf.py

Lines changed: 23 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@
1414
import pathlib
1515
import time
1616

17-
# Load the dummy profile even if we are running locally, this way the documentation will succeed even if the current
18-
# default profile of the AiiDA installation does not use a Django backend.
1917
from aiida.manage.configuration import load_documentation_profile
2018

19+
load_documentation_profile()
2120
# If extensions (or modules to document with autodoc) are in another directory,
2221
# add these directories to sys.path here. If the directory is relative to the
2322
# documentation root, use os.path.abspath to make it absolute, like shown here.
24-
import aiida_quantumespresso
25-
26-
load_documentation_profile()
2723

2824
# -- Project information -----------------------------------------------------
2925

@@ -32,11 +28,6 @@
3228
Materials (THEOS) and National Centre for Computational Design and Discovery of Novel Materials (NCCR MARVEL)),
3329
Switzerland. All rights reserved"""
3430

35-
# The full version, including alpha/beta/rc tags.
36-
release = aiida_quantumespresso.__version__
37-
# The short X.Y version.
38-
version = '.'.join(aiida_quantumespresso.__version__.split('.')[:2])
39-
4031
# -- General configuration ------------------------------------------------
4132

4233
# If your documentation needs a minimal Sphinx version, state it here.
@@ -46,7 +37,6 @@
4637
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4738
# ones.
4839
extensions = [
49-
'sphinx.ext.autodoc',
5040
'sphinx.ext.mathjax',
5141
'sphinx.ext.intersphinx',
5242
'sphinx.ext.viewcode',
@@ -61,9 +51,8 @@
6151
# Setting the intersphinx mapping to other readthedocs
6252
intersphinx_mapping = {
6353
'python': ('https://docs.python.org/3.8', None),
64-
'aiida': ('https://aiida.readthedocs.io/en/latest/', None),
54+
'aiida': ('https://aiida.readthedocs.io/projects/aiida-core/en/latest/', None),
6555
'aiida_pseudo': ('http://aiida-pseudo.readthedocs.io/en/latest/', None),
66-
'sphinx': ('https://www.sphinx-doc.org/en/master', None),
6756
}
6857

6958
myst_enable_extensions = [
@@ -72,18 +61,13 @@
7261
'substitution'
7362
]
7463

75-
myst_substitutions = {
76-
'release': release,
77-
'version': version
78-
}
79-
8064
# Settings for the `autoapi.extenstion` automatically generating API docs
8165
filepath_docs = pathlib.Path(__file__).parent.parent
8266
filepath_src = filepath_docs.parent / 'src'
8367
autoapi_type = 'python'
8468
autoapi_dirs = [filepath_src]
8569
autoapi_ignore = [filepath_src / 'aiida_quantumespresso' / '*cli*']
86-
autoapi_root = str(filepath_docs / 'source' / 'reference' / 'api')
70+
autoapi_root = str(filepath_docs / 'source' / 'reference' / 'api' / 'auto')
8771
autoapi_keep_files = True
8872
autoapi_add_toctree_entry = False
8973

@@ -104,18 +88,24 @@
10488

10589
# List of patterns, relative to source directory, that match files and
10690
# directories to ignore when looking for source files.
107-
exclude_patterns = []
91+
exclude_patterns = ['**.ipynb_checkpoints', 'reference/api/auto/aiida_quantumespresso/index.rst']
10892

10993
# -- Options for HTML output ----------------------------------------------
11094

11195
# The theme to use for HTML and HTML Help pages. See the documentation for
11296
# a list of builtin themes.
11397

114-
html_theme = 'pydata_sphinx_theme'
98+
html_theme = 'sphinx_book_theme'
11599
html_theme_options = {
100+
'repository_url': 'https://github.com/aiidateam/aiida-quantumespresso',
116101
'github_url': 'https://github.com/aiidateam/aiida-quantumespresso',
117102
'twitter_url': 'https://twitter.com/aiidateam',
118103
'use_edit_page_button': True,
104+
'logo': {
105+
'text': 'AiiDA Quantum ESPRESSO',
106+
'image_light': '_static/logo_aiida_quantumespresso-light.png',
107+
'image_dark': '_static/logo_aiida_quantumespresso-dark.png',
108+
}
119109
}
120110
html_static_path = ['_static']
121111
html_context = {
@@ -125,10 +115,12 @@
125115
'doc_path': 'docs/source',
126116
'default_mode': 'light',
127117
}
118+
html_sidebars = {
119+
'**': ['navbar-logo.html', 'navbar-icon-links.html', 'search-field.html', 'sbt-sidebar-nav.html']
120+
}
128121

129122
# The name of an image file (relative to this directory) to place at the top
130123
# of the sidebar.
131-
html_logo = 'images/logo_docs.png'
132124
html_static_path = ['_static']
133125
html_css_files = ['aiida-custom.css', 'aiida-qe-custom.css']
134126

@@ -146,80 +138,18 @@
146138
# Output file base name for HTML help builder.
147139
htmlhelp_basename = 'aiida-quantumespressodoc'
148140

149-
# -- Options for LaTeX output ---------------------------------------------
150-
151-
latex_elements = {
152-
# The paper size ('letterpaper' or 'a4paper').
153-
#'papersize': 'letterpaper',
154-
155-
# The font size ('10pt', '11pt' or '12pt').
156-
#'pointsize': '10pt',
157-
158-
# Additional stuff for the LaTeX preamble.
159-
#'preamble': '',
160-
161-
# Latex figure (float) alignment
162-
#'figure_align': 'htbp',
163-
}
164-
165-
# Grouping the document tree into LaTeX files. List of tuples
166-
# (source start file, target name, title,
167-
# author, documentclass [howto, manual, or own class]).
168-
# latex_documents = [
169-
# ]
170-
171-
# The name of an image file (relative to this directory) to place at the top of
172-
# the title page.
173-
#latex_logo = None
174-
175-
# For "manual" documents, if this is true, then toplevel headings are parts,
176-
# not chapters.
177-
#latex_use_parts = False
178-
179-
# If true, show page references after internal links.
180-
#latex_show_pagerefs = False
181-
182-
# If true, show URL addresses after external links.
183-
#latex_show_urls = False
184-
185-
# Documents to append as an appendix to all manuals.
186-
#latex_appendices = []
187-
188-
# If false, no module index is generated.
189-
#latex_domain_indices = True
190-
191-
# -- Options for manual page output ---------------------------------------
192-
193-
# One entry per manual page. List of tuples
194-
# (source start file, name, description, authors, manual section).
195-
# man_pages = [
196-
# ]
197-
198-
# If true, show URL addresses after external links.
199-
#man_show_urls = False
200-
201-
# -- Options for Texinfo output -------------------------------------------
202-
203-
# Grouping the document tree into Texinfo files. List of tuples
204-
# (source start file, target name, title, author,
205-
# dir menu entry, description, category)
206-
# texinfo_documents = [
207-
# ]
208-
209-
# Documents to append as an appendix to all manuals.
210-
#texinfo_appendices = []
211-
212-
# If false, no module index is generated.
213-
#texinfo_domain_indices = True
214-
215-
# How to display URL addresses: 'footnote', 'no', or 'inline'.
216-
#texinfo_show_urls = 'footnote'
217-
218-
# If true, do not generate a @detailmenu in the "Top" node's menu.
219-
#texinfo_no_detailmenu = False
141+
# ------------------------------------------------------------------------------
220142

221143
# Warnings to ignore when using the -n (nitpicky) option
222144
# We should ignore any python built-in exception, for instance
145+
nitpicky = True
146+
147+
nitpick_ignore_regex = [
148+
(r'py:.*', r'pydantic.*'),
149+
(r'py:.*', r'con.*'),
150+
(r'.*', r'Literal.*'),
151+
(r'.*', r'Tuple.*'),
152+
]
223153
nitpick_ignore = [
224154
('py:exc', 'ArithmeticError'),
225155
('py:exc', 'AssertionError'),

docs/source/howto/calculations/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
(howto-calculations)=
22

3-
# How-to run calculations
3+
# Calculations
4+
5+
:::{important}
6+
The following how-to guides assume that you are familiar with the basics of AiiDA, such as creating data and running processes.
7+
At the very least, make sure you have followed and understand the tutorial on [running a calculation through the API](#tutorials-pw-through-api).
8+
:::
49

510
```{toctree}
611
:maxdepth: 1

0 commit comments

Comments
 (0)