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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Myst cross reference link example to Jupyter style guide #7235

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/source/contributing/jupyter_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ This guide does not teach nor cover MyST extensively, only gives some opinionate
libraries documentations. Use [sphinx cross-references](https://docs.readthedocs.io/en/stable/guides/cross-referencing-with-sphinx.html)
instead.

* For instance, to link to another notebook, you could use an explicit link in the markdown text: "this model uses the \[Kronecker product](GP-Kron.myst.md)". See {ref}`this page <myst:syntax/targets>` for more details.

:::{caution}
Using urls links breaks self referencing in versioned docs! And at the same time they are
less robust than sphinx cross-references.
Expand All @@ -43,6 +45,37 @@ This guide does not teach nor cover MyST extensively, only gives some opinionate
* When linking to other notebooks, always use a `ref` type cross-reference pointing
to the target in the {ref}`jupyter_style_first_cell`.

* Here are more guidances on reference links:

#### References to targets within the current project
That is, notebooks in pymc-examples referring to other notebooks in pymc-examples.

```
{ref}`explicit text <anchor_id>`
[explicit text](#anchor_id)
```

#### References to targets of other projects
These can be to any project defined in the [intersphinx mapping](https://github.com/pymc-devs/pymc-examples/blob/main/examples/conf.py#L175). For example, from pymc-examples to pymc main docs, or to arviz docs or to matplotlib docs; it doesn't matter when it comes to syntax.

```
{ref}`explicit text <key:anchor_id>`
[explicit text](inv:key:*:ref#anchor_id)
```

where key is one of the keys defined in the [intersphinx mapping](https://github.com/pymc-devs/pymc-examples/blob/main/examples/conf.py#L175), such as `pymc`, `arviz`, `numpy`...

#### References to python objects

```
{type}`import.path` # to show full import path
{type}`~import.path` # to show only object name
```

where type is func for functions, meth for methods, class for classes, prop for property, etc.

Now let's continue with the MysT guidelines.

* If the output (or even code and output) of a cell is not necessary to follow the
notebook or it is very long and can break the flow of reading, consider hiding
it with a {ref}`toggle button <myst-nb:use/hiding/code>`
Expand Down