Skip to content

Commit 114e439

Browse files
Add pre-commit check for docs cross-references (#5486)
* 🔧 Add check for docs cross-references #5317 * ✨ check jupyter notebooks #5317 * 🔧 add all links in the intersphinx mapping * 📝 add cross-references * 📝 remove cross-references * 📝 add cross-references * 🔧 exclude files * Update .pre-commit-config.yaml * 📝 add ignore file Co-authored-by: Oriol Abril-Pla <[email protected]> * ✏️ remove duplicated * Fix ref in developer_guide.rst Co-authored-by: Oriol Abril-Pla <[email protected]> * Fix ref in developer_guide.rst Co-authored-by: Oriol Abril-Pla <[email protected]> * Fix reference in developer_guide.rst Co-authored-by: Oriol Abril-Pla <[email protected]> * Fix ref in examples.md Co-authored-by: Oriol Abril-Pla <[email protected]> * Fix ref in learn/examples.md Co-authored-by: Oriol Abril-Pla <[email protected]> * Fix ref in learn/examples.md Co-authored-by: Oriol Abril-Pla <[email protected]> * Fix ref in learn/usage_overview.rst Co-authored-by: Oriol Abril-Pla <[email protected]> * 🙈 ignore index.md * fix arviz cross references in notebooks Co-authored-by: Oriol Abril-Pla <[email protected]>
1 parent da2030e commit 114e439

11 files changed

+74
-50
lines changed

.pre-commit-config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,35 @@ repos:
6060
entry: from \.[\.\w]* import
6161
types: [python]
6262
language: pygrep
63+
- id: no-internal-links
64+
name: Check no internal links are in the docs
65+
description: >-
66+
'A quick check for the links in the intersphinx '
67+
'mapping inside `docs/source/`'
68+
'See docs/source/conf.py for more information.'
69+
files: ^docs/source/
70+
# Files that should be ignored:
71+
# - index.md
72+
# - 404.md
73+
# - contributing/release_checklist.md
74+
# The other files are under development and should be
75+
# removed from the list once they are revised.
76+
exclude: >
77+
(?x)(index.md|
78+
404.md|
79+
contributing/release_checklist.md|
80+
contributing/developer_guide.rst|
81+
learn/examples.md)
82+
entry: >
83+
(?x)(arviz-devs.github.io|
84+
aesara.readthedocs.io|
85+
aeppl.readthedocs.io|
86+
docs.pymc.io|
87+
numpy.org/doc|
88+
pymc-examples.readthedocs.io|
89+
myst-parser.readthedocs.io|
90+
myst-nb.readthedocs.io|
91+
docs.python.org|
92+
xarray.pydata.org)
93+
language: pygrep
94+
types_or: [markdown, rst, jupyter]

docs/source/Advanced_usage_of_Aesara_in_PyMC.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Good reasons for defining a custom `Op` might be the following:
102102
and sufficiently parallelizable to make the cost worth it.
103103
We would definitely like to hear about any such examples.
104104

105-
Aesara has extensive `documentation, <https://aesara.readthedocs.io/en/latest/extending/index.html>`_
105+
Aesara has extensive :doc:`documentation <aesara:index>`
106106
about how to write new Ops.
107107

108108

docs/source/PyMC_and_Aesara.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ their posterior probability density up to a constant factor. We then use
1717
symbolic manipulations of this function to also get access to its gradient.
1818

1919
For a thorough introduction to Aesara see the
20-
`aesara docs <https://aesara.readthedocs.io/en/latest/>`_,
20+
:doc:`aesara docs <aesara:index>`,
2121
but for the most part you don't need detailed knowledge about it as long
2222
as you are not trying to define new distributions or other extensions
2323
of PyMC. But let's look at a simple example to get a rough
@@ -81,7 +81,7 @@ like NumPy arrays. Most NumPy functions are available in `aesara.tensor`
8181
can be found in `at.nlinalg` and `at.slinalg` (the NumPy and SciPy
8282
operations respectively). Some support for sparse matrices is available
8383
in `aesara.sparse`. For a detailed overview of available operations,
84-
see `the aesara api docs <https://aesara.readthedocs.io/en/latest/library/tensor/index.html>`_.
84+
see :mod:`the aesara api docs <aesara.tensor>`.
8585

8686
A notable exception where Aesara variables do *not* behave like
8787
NumPy arrays are operations involving conditional execution.

docs/source/api/distributions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.. _api_distributions:
12
*************
23
Distributions
34
*************

docs/source/contributing/developer_guide.rst

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@
77
PyMC Developer Guide
88
====================
99

10-
`PyMC <https://docs.pymc.io/>`__ is a Python package for Bayesian
10+
:doc:`PyMC <index>` is a Python package for Bayesian
1111
statistical modeling built on top of
12-
`Aesara <https://aesara.readthedocs.io/en/latest/index.html>`__. This
12+
:doc:`Aesara <aesara:index>`. This
1313
document aims to explain the design and implementation of probabilistic
1414
programming in PyMC, with comparisons to other PPL like TensorFlow Probability (TFP)
1515
and Pyro in mind. A user-facing API
16-
introduction can be found in the `API
17-
quickstart <https://docs.pymc.io/notebooks/api_quickstart.html>`__. A more accessible, user facing deep introduction can be found in
16+
introduction can be found in the :ref:`API quickstart <pymc_overview>`. A more accessible, user facing deep introduction can be found in
1817
`Peadar Coyle's probabilistic programming primer <https://github.com/springcoil/probabilisticprogrammingprimer>`__
1918

2019
Distribution
2120
------------
2221

2322
A high-level introduction of ``Distribution`` in PyMC can be found in
24-
the `documentation <https://docs.pymc.io/Probability_Distributions.html>`__. The source
23+
the :ref:`documentation <api_distributions>`. The source
2524
code of the probability distributions is nested under
26-
`pymc/distributions <https://github.com/pymc-devs/pymc/blob/main/pymc/distributions/>`__,
27-
with the ``Distribution`` class defined in `distribution.py
28-
<https://github.com/pymc-devs/pymc/blob/main/pymc/distributions/distribution.py#L23-L44>`__.
25+
:ref:`pymc/distributions <api_distributions>`,
26+
with the :class:`~pymc.Distribution` class defined in ``distribution.py``.
2927
A few important points to highlight in the Distribution Class:
3028

3129
.. code:: python
@@ -66,8 +64,7 @@ functions. Instead, to access a stateless distribution, you need to call
6664
https://docs.pymc.io/Probability\_Distributions.html#using-pymc-distributions-without-a-model).
6765
6866
With this distinction in mind, we can take a closer look at the
69-
stateless distribution part of pymc (see distribution api in `doc
70-
<https://docs.pymc.io/api/distributions.html>`__), which divided into:
67+
stateless distribution part of pymc (see distribution api in :ref:`doc <api_distributions>`), which divided into:
7168
7269
- Continuous
7370
@@ -319,14 +316,13 @@ cannot be transformed.
319316
correction for inverse mapping). The use cases we considered are limited
320317
to the set of distributions that are bounded, and the transformation
321318
maps the bounded set to the real line - see
322-
`doc
323-
<https://docs.pymc.io/notebooks/api_quickstart.html#Automatic-transforms-of-bounded-RVs>`__.
319+
:ref:`API quickstart <pymc_overview#Automatic-transforms-of-bounded-RVs>`.
324320
However, other transformations are possible.
325321
In general, PyMC does not provide explicit functionality to transform
326322
one distribution to another. Instead, a dedicated distribution is
327323
usually created in order to optimise performance. But getting a
328324
``TransformedDistribution`` is also possible (see also in
329-
`doc <https://docs.pymc.io/notebooks/api_quickstart.html#Transformed-distributions-and-changes-of-variables>`__):
325+
:ref:`doc <pymc_overview##Transformed-distributions-and-changes-of-variables>`):
330326
331327
.. code:: python
332328

docs/source/contributing/developer_guide_implementing_distribution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ This guide does not attempt to explain the rationale behind the `Distributions`
2323
{class}`~aesara.tensor.random.op.RandomVariable` are responsible for implementing the random sampling methods, which in version 3 of PyMC used to be one of the standard `Distribution` methods, alongside `logp` and `logcdf`.
2424
The `RandomVariable` is also responsible for parameter broadcasting and shape inference.
2525

26-
Before creating a new `RandomVariable` make sure that it is not offered in the [Numpy library](https://numpy.org/doc/stable/reference/random/generator.html#distributions).
27-
If it is, it should be added to the [Aesara library](https://github.com/aesara-devs/aesara) first and then imported into the PyMC library.
26+
Before creating a new `RandomVariable` make sure that it is not offered in the {mod}`Numpy library <numpy.random>`.
27+
If it is, it should be added to the {doc}`Aesara library <aesara>` first and then imported into the PyMC library.
2828

2929
In addition, it might not always be necessary to implement a new `RandomVariable`.
3030
For example if the new `Distribution` is just a special parametrization of an existing `Distribution`.

docs/source/glossary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Functional Programming
1111
This contrasts with functions or methods that depend on variables that are not explicitly passed as an input (such as accessing `self.variable` inside a method) or that alter the inputs or other state variables in-place, instead of returning new distinct variables as outputs.
1212

1313
Dispatching
14-
Choosing which function or method implementation to use based on the type of the input variables (usually just the first variable). For some examples, see Python's documentation for the [singledispatch](https://docs.python.org/3/library/functools.html#functools.singledispatch) decorator.
14+
Choosing which function or method implementation to use based on the type of the input variables (usually just the first variable). For some examples, see Python's documentation for the {func}`singledispatch <~functools.singledispatch>` decorator.
1515

1616
[Dispersion](https://en.wikipedia.org/wiki/Statistical_dispersion)
1717
In statistics, dispersion (also called variability, scatter, or spread) is the extent to which a distribution is stretched or squeezed

docs/source/learn/examples.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33

44
TODO add "core" notebooks:
55

6-
- https://docs.pymc.io/en/stable/pymc-examples/examples/generalized_linear_models/GLM-linear.html
7-
- https://github.com/pymc-devs/pymc-examples/blob/main/examples/generalized_linear_models/GLM-linear.ipynb
6+
- {ref}`GLM-linear`
87

9-
- https://docs.pymc.io/en/stable/pymc-examples/examples/case_studies/multilevel_modeling.html
10-
- https://github.com/pymc-devs/pymc-examples/blob/main/examples/case_studies/multilevel_modeling.ipynb
8+
- {ref}`nb:multilevel_modeling`
119

12-
- https://docs.pymc.io/en/stable/pymc-examples/examples/diagnostics_and_criticism/model_comparison.html
13-
- https://github.com/pymc-devs/pymc-examples/blob/main/examples/diagnostics_and_criticism/model_comparison.ipynb
10+
- {ref}`model_comparison`
1411
TODO: Add reference to ArviZ docs since it was taken from there
1512

1613
- https://docs.pymc.io/en/stable/Probability_Distributions.html
@@ -20,11 +17,9 @@ TODO add "core" notebooks:
2017
update needed: from "pymc and theano" to "pymc and aesara" tutorial (not just auto-renaming from theano to aesara but showing correct use). Very related to migration guide as well, though the migration guide already covers it.
2118
- https://github.com/pymc-devs/pymc/blob/37ba9a3e3a19b738f48cb30007f4d70c33bdd0f6/docs/source/PyMC_and_Aesara.rst
2219

23-
- https://docs.pymc.io/en/stable/pymc-examples/examples/diagnostics_and_criticism/posterior_predictive.html
24-
- https://github.com/pymc-devs/pymc-examples/blob/2002ebd815a199be89b011039906b197bca42361/examples/diagnostics_and_criticism/posterior_predictive.ipynb
20+
- {ref}`posterior_predictive`
2521

26-
- https://docs.pymc.io/en/stable/Gaussian_Processes.html
27-
- https://github.com/pymc-devs/pymc/blob/37ba9a3e3a19b738f48cb30007f4d70c33bdd0f6/docs/source/Gaussian_Processes.rst
22+
- {mod}`pymc.gp`
2823

2924
TODO link to the pymc-examples
3025
TODO add categories to all notebooks

docs/source/learn/examples/posterior_predictive.ipynb

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

docs/source/learn/examples/pymc_overview.ipynb

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

docs/source/learn/usage_overview.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Usage Overview
66

77
For a detailed overview of building models in PyMC, please read the appropriate sections in the rest of the documentation. For a flavor of what PyMC models look like, here is a quick example.
88

9-
First, let's import PyMC and `ArviZ <https://arviz-devs.github.io/arviz/>`__ (which handles plotting and diagnostics):
9+
First, let's import PyMC and :doc:`ArviZ <arviz:index>` (which handles plotting and diagnostics):
1010

1111
::
1212

0 commit comments

Comments
 (0)