Theme-specific elements#
There are a few elements that are unique or particularly important to this theme.Some of these are triggered with configuration or Markdown syntax that is unique to the theme, and we cover them below.
Mathematics#
Most Sphinx sites support math, but it is particularly important for scientific computing, so we illustrate support here as well.
Here is an inline equation:\(X_{0:5} = (X_0, X_1, X_2, X_3, X_4)\) and\(another\) and\(x^2 x^3 x^4\) another. And here’s one to test vertical height\(\frac{\partial^2 f}{\partial \phi^2}\).Here is a block-level equation:
And here is a really long equation with a label!
You can add a link to equations like the one above(1) and(2).
Code blocks#
Code block styling is inspired byGitHub’s code block style and also has support for Code Block captions/titles.Seethe Sphinx documentation on code blocks for more information.
print("A regular code block")print("A regular code block")print("A regular code block")
You can also provide captions with code blocks, which will be displayed right above the code.For example, the following code:
..code-block:: python:caption: python.py print("A code block with a caption.")
```{code-block} python:caption: python.pyprint("A code block with a caption.")```results in:
You can also display line numbers.For example, the following code:
..code-block:: python:caption: python.py:linenos: print("A code block with a caption and line numbers.") print("A code block with a caption and line numbers.") print("A code block with a caption and line numbers.")
```{code-block} python:caption: python.py:linenos:print("A code block with a caption and line numbers.")print("A code block with a caption and line numbers.")print("A code block with a caption and line numbers.")```results in:
Inline code#
When used directly, thecode role just displays the text without syntax highlighting, as a literal. As mentioned in theSphinx documentation you can also enable syntax highlighting by defining a custom role. It will then use the same highlighter as in thecode-block directive.
..role:: python(code):language: pythonIn Python you can:python:`import sphinx`.
```{role} python(code):language: python```In Python you can {python}`import sphinx`.In Python you canimportsphinx.
Code execution#
This theme has support for Jupyter execution libraries so that you can programmatically update your documentation with each build.For examples, seePyData Library Styles.
Admonition sidebars#
A sidebar admonition!
I was made with the{admonition} directive and asidebar class.
Sidebar title
I was made with the{sidebar} directive.
This theme supports a shorthand way of makingadmonitions behave like sidebars.This can be a helpful way of highlighting content without interrupting the vertical flow as much.
For example, on the right are an “admonition sidebar” and a traditional Sphinx sidebar.
To make an admonition behave like a sidebar, add thesidebar class to its list of classes.The admonition sidebar in this section was created with the following Markdown:
..admonition:: A sidebar admonition!:class: sidebar note Some sidebar content.
```{admonition} A sidebar admonition!:class: sidebar noteSome sidebar content.```Footnotes#
Here’s a numeric footnote[1], another one (preceded by a space)[2], a named footnote[3], and a symbolic one[4].All will end up as numbers in the rendered HTML, but in the source they look like[^1],[^2],[^named] and[^*].
Link shortening for git repository services#
Many projects have links back to their issues / PRs hosted on platforms likeGitHub orGitLab.Instead of displaying these as raw links, this theme does some lightweight formatting for these platforms specifically.
InreStructuredText, URLs are automatically converted to links, so this works automatically.
InMyST Markdown, by default, you must define a standard Markdown link and duplicate the URL in the link text.You may skip the need to manually define the link text byactivating the MyST Linkify extension.
For example:
reStructuredText
https://github.com/pydata/pydata-sphinx-theme/pull/1012
MyST Markdown (default)
[https://github.com/pydata/pydata-sphinx-theme/pull/1012](https://github.com/pydata/pydata-sphinx-theme/pull/1012)
MyST Markdown withMyST Linkify
https://github.com/pydata/pydata-sphinx-theme/pull/1012
There are a variety of link targets supported, here’s a table for reference:
GitHub
https://github.com:githubhttps://github.com/pydata:pydatahttps://github.com/pydata/pydata-sphinx-theme:pydata/pydata-sphinx-themehttps://github.com/pydata/pydata-sphinx-theme/pull/1012:pydata/pydata-sphinx-theme#1012https://github.com/orgs/pydata/projects/2:pydata/projects#2
GitLab
https://gitlab.com:gitlabhttps://gitlab.com/gitlab-org:gitlab-orghttps://gitlab.com/gitlab-org/gitlab:gitlab-org/gitlabhttps://gitlab.com/gitlab-org/gitlab/-/issues/375583:gitlab-org/gitlab#375583
Links provided with a text body won’t be changed.
[1]
Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar.
[2]Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar.
[3]Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar.
[4]Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar. Foo bar foo bar.