PyData Theme Elements#
This is a collection of content blocks with special support from this theme’s parent theme, the PyData Sphinx Theme
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.
Page contents
Mathematics#
Most Sphinx sites support math, but it is particularly important for scientific computing and 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 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 by GitHub’s code block style and also has support for Code Block captions/titles. See the 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 just above the code. For example, the following code:
```{code-block} python
:caption: python.py
print("A code block with a caption.")
```
results in:
print("A code block with a caption.")
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.")
```
results in:
1print("A code block with a caption and line numbers.")
2print("A code block with a caption and line numbers.")
3print("A code block with a caption and line numbers.")
Inline code#
When used directly, the code
role just displays the text without syntax highlighting, as a literal. As mentioned in the Sphinx documentation you can also enable syntax highlighting by defining a custom role. It will then use the same highligther as in the code-block
directive.
.. role:: python(code)
:language: python
In Python you can :python:`import sphinx`.
In Python you can import sphinx
.
Code execution#
This theme has support for Jupyter execution libraries so that you can programmatically update your documentation with each build. For examples, see Jupyter notebooks.
Footnotes#
Here’s one footnote1Foo 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. and another footnote 2Foo 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. and a named footenote3Foo 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., symbol 4Foo 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..
Version changes#
This theme supports a short-hand way of making admonitions behave like sidebars. This can be a helpful way of highlighting content that lives to the side of your main text without interrupting the vertical flow as much.
For example, look to the right of an “admonition sidebar” and a traditional Sphinx sidebar.
To make an admonition behave like a sidebar, add the sidebar
class to its list of classes.
For example, the admonition sidebar was created with the following markdown:
```{admonition} A sidebar admonition!
:class: sidebar note
Some sidebar content.
```
Link shortening for git repository services#
Many projects have links back to their issues / PRs hosted on platforms like GitHub or GitLab. Instead of displaying these as raw links, this theme does some lightweight formatting for these platforms specifically.
In reStructuredText, URLs are automatically converted to links, so this works automatically.
In MyST 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 by activating the MyST Linkify extension.
For example:
reStructuredText
https://github.com/pydata/pydata-sphinx-theme/pull/1012
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 with MyST Linkify
https://github.com/pydata/pydata-sphinx-theme/pull/1012
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
: https://github.comhttps://github.com/pydata
: https://github.com/pydatahttps://github.com/pydata/pydata-sphinx-theme
: https://github.com/pydata/pydata-sphinx-themehttps://github.com/pydata/pydata-sphinx-theme/pull/1012
: https://github.com/pydata/pydata-sphinx-theme/pull/1012https://github.com/orgs/pydata/projects/2
: https://github.com/orgs/pydata/projects/2
GitLab
https://gitlab.com
: https://gitlab.comhttps://gitlab.com/gitlab-org
: https://gitlab.com/gitlab-orghttps://gitlab.com/gitlab-org/gitlab
: https://gitlab.com/gitlab-org/gitlabhttps://gitlab.com/gitlab-org/gitlab/-/issues/375583
: https://gitlab.com/gitlab-org/gitlab/-/issues/375583
Links provided with a text body won’t be changed.