Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sphinx extension myst-nb to enable writing executable Markdown notebooks #3379

Merged
merged 9 commits into from
Aug 12, 2024
2 changes: 1 addition & 1 deletion .github/workflows/ci_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
build
make
pip
myst-parser
myst-nb
panel
sphinx
sphinx-autodoc-typehints
Expand Down
2 changes: 1 addition & 1 deletion ci/requirements/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
- make
- pip
# Dev dependencies (building documentation)
- myst-parser
- myst-nb
- panel
- sphinx
- sphinx-autodoc-typehints
Expand Down
18 changes: 16 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)

extensions = [
"myst_parser",
"myst_nb",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.coverage",
Expand Down Expand Up @@ -153,7 +153,21 @@

# Sphinx project configuration
templates_path = ["_templates"]
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
exclude_patterns = [
"_build",
"**.ipynb_checkpoints",
# Workaround from https://github.com/executablebooks/MyST-NB/issues/363 to prevent
# myst-nb from parsing the .ipynb and .py files generated by sphinx-gallery.
"gallery/**.ipynb",
"tutorials/**.ipynb",
"get_started/**.ipynb",
"projections/**.ipynb",
"gallery/**.py",
"tutorials/**.py",
"get_started/**.py",
"projections/**.py",
]

source_suffix = ".rst"
needs_sphinx = "1.8"
# The encoding of source files.
Expand Down
13 changes: 11 additions & 2 deletions doc/install.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add metadata at the top so that myst-nb can recognize it as a MyST notebook.

file_format: mystnb
---

# Installing

## Quickstart
Expand Down Expand Up @@ -233,16 +237,21 @@ from Python.
To ensure that PyGMT and its dependencies are installed correctly, run the following
in your Python interpreter:

```python
```{code-cell} ipython
---
tags: [hide-output]
---

import pygmt
pygmt.show_versions()
```

```{code-cell} ipython
fig = pygmt.Figure()
fig.coast(projection="N15c", region="g", frame=True, land="tan", water="lightblue")
fig.text(position="MC", text="PyGMT", font="80p,Helvetica-Bold,red@75")
fig.show()
```
![pygmt-get-started](https://github.com/GenericMappingTools/pygmt/assets/3974108/f7f51484-8640-4b58-ae5b-6c71e7150f7a){.align-center width="70%"}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include the external image.


You should see a global map with land and water masses colored in tan and lightblue
respectively. On top, there should be the semi-transparent text "PyGMT". If the
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies:
- pytest-doctestplus
- pytest-mpl
# Dev dependencies (building documentation)
- myst-parser
- myst-nb
- panel
- sphinx
- sphinx-autodoc-typehints
Expand Down