Repository: pymc-devs/pymc
Pull request: Add pre-commit check for docs cross-references
It closes #5317 in #DataUmbrellaPyMCSprint

Adds a hook to check for  `docs.pymc.io` inside `docs/source/`.

Depending on what your PR does, here are a few things you might want to address in the description:
+ [x] [linting/style checks have been run](https://docs.pymc.io/en/latest/contributing/python_style.html)

This PR should be merged after the existing links are reviewed. The hook is detecting these references to be fixed:

- [x] docs/source/contributing/developer_guide.rst:65:https://docs.pymc.io/Probability\_Distributions.html#using-pymc-distributions-without-a-model).
- [x] docs/source/contributing/developer_guide.rst:113:https://docs.pymc.io/Probability\_Distributions.html#custom-distributions
- [x] docs/source/contributing/developer_guide.rst:377:   transformation <https://docs.pymc.io/notebooks/api_quickstart.html?highlight=chain%20transformation>`__).
- [x] docs/source/contributing/developer_guide.rst:693:method <https://docs.pymc.io/notebooks/sampling_compound_step.html>`__.
- [x] docs/source/contributing/developer_guide.rst:696:RVs <https://docs.pymc.io/notebooks/sampling_compound_step.html?highlight=compoundstep#Specify-compound-steps>`__.
- [x] docs/source/contributing/developer_guide.rst:714:doc <https://docs.pymc.io/notebooks/sampling_compound_step.html#Specify-compound-steps>`__.
- [x] docs/source/contributing/developer_guide.rst:913:    -  `Using “black box” likelihood function by creating a custom Aesara Op <https://docs.pymc.io/notebooks/blackbox_external_likelihood.html>`__
- [x] docs/source/contributing/developer_guide_implementing_distribution.md: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).
- [x] docs/source/contributing/release_checklist.md:25:+ Make sure the new version appears at the website and that [`docs.pymc.io/en/stable`](https://docs.pymc.io/en/stable) points to it.
- [x] docs/source/glossary.md: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.
- [x] docs/source/learn/examples.md:13:- https://docs.pymc.io/en/stable/Probability_Distributions.html
- [x] docs/source/learn/examples.md:16:- https://docs.pymc.io/en/stable/PyMC3_and_Theano.html


Problem statement:
Add pre-commit check for sphinx cross-references
Now that we have versioned docs, we can't use urls for internal links if we want each version to point to themselves. I think we should add a pre-commit check to ensure there are no links pointing to `docs.pymc.io` anywhere inside the `docs/source/` folder.

I don't know pre-commit but it seems like this should be easy for someone who does know their way around it. cc @MarcoGorelli if you agree with this, can you label it beginner friendly?

Hints from issue discussion:
yeah I think just a pygrep check for this would be good
Hi, I would like to work on this issue ✋🏽 
Assigned it to you

Commit message: :wrench: Add check for docs cross-references #5317

Patch to review:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 978aa51225..e7dcef0605 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -60,3 +60,10 @@ repos:
       entry: from \.[\.\w]* import
       types: [python]
       language: pygrep
+    - id: no-internal-links
+      name: Check no internal links are in the docs
+      description: 'A quick check for the `docs.pymc.io` inside `docs/source/`'
+      files: ^docs/source/
+      entry: 'docs.pymc.io'
+      language: pygrep
+      types_or: [markdown, rst]


Code review comments:
diff_hunk: @@ -60,3 +60,10 @@ repos:
       entry: from \.[\.\w]* import
       types: [python]
       language: pygrep
+    - id: no-internal-links
+      name: Check no internal links are in the docs
+      description: 'A quick check for the `docs.pymc.io` inside `docs/source/`'
+      files: ^docs/source/
+      entry: 'docs.pymc.io'
+      language: pygrep
+      types_or: [markdown, rst]
path: .pre-commit-config.yaml
text: @user1:
This should also include ipynb files, there are some jupyter notebooks that are part of the docs and should follow the same rules

@author:
Done ✔️