Skip to content

Commit 1aa1bbd

Browse files
authored
Merge branch 'main' into see-more-accepts-sphinx-crosslinks
2 parents c8e2003 + 532cd7d commit 1aa1bbd

28 files changed

+446
-132
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
name: Run CircleCI artifacts redirector
66
steps:
77
- name: GitHub Action step
8-
uses: larsoner/circleci-artifacts-redirector-action@master
8+
uses: scientific-python/circleci-artifacts-redirector-action@4e13a10d89177f4bfc8007a7064bdbeda848d8d1 # v1.0.0
99
with:
1010
repo-token: ${{ secrets.GITHUB_TOKEN }}
1111
api-token: ${{ secrets.CIRCLECI_ARTIFACT_REDIRECTOR_TOKEN }}

.github/workflows/release.yml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,47 @@
11
name: Build Wheel and Release
22
on:
3+
pull_request:
4+
branches:
5+
- main
36
push:
47
tags:
58
- v*
69

710
jobs:
8-
pypi-publish:
9-
name: upload release to PyPI
10-
if: github.repository_owner == 'numpy' && startsWith(github.ref, 'refs/tags/v') && github.actor == 'jarrodmillman' && always()
11+
sdist_wheel:
12+
name: sdist and wheels
1113
runs-on: ubuntu-latest
12-
# Specifying a GitHub environment is optional, but strongly encouraged
13-
environment: release
14-
permissions:
15-
# IMPORTANT: this permission is mandatory for trusted publishing
16-
id-token: write
1714
steps:
18-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
1916
with:
2017
fetch-depth: 0
21-
22-
- uses: actions/setup-python@v5
23-
name: Install Python
18+
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
2419
with:
2520
python-version: "3.12"
26-
2721
- name: Build wheels
2822
run: |
2923
git clean -fxd
3024
pip install -U build twine wheel
3125
python -m build --sdist --wheel
26+
- run: twine check --strict dist/*
27+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
28+
with:
29+
name: dist
30+
path: dist
3231

33-
- name: Publish package distributions to PyPI
34-
uses: pypa/gh-action-pypi-publish@release/v1
32+
pypi-publish:
33+
needs: sdist_wheel
34+
name: upload release to PyPI
35+
if: github.repository_owner == 'numpy' && startsWith(github.ref, 'refs/tags/v') && github.actor == 'jarrodmillman' && always()
36+
runs-on: ubuntu-latest
37+
# Specifying a GitHub environment is optional, but strongly encouraged
38+
environment: release
39+
permissions:
40+
# IMPORTANT: this permission is mandatory for trusted publishing
41+
id-token: write
42+
steps:
43+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
44+
with:
45+
name: dist
46+
path: dist
47+
- uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
os: [Ubuntu]
19-
python-version: ["3.9", "3.10", "3.11", "3.12"]
19+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2020
sphinx-version:
2121
["sphinx==6.0", "sphinx==6.2", "sphinx==7.0", "sphinx>=7.3"]
2222
include:
@@ -37,14 +37,13 @@ jobs:
3737
- name: Setup environment
3838
run: |
3939
python -m pip install --upgrade pip wheel setuptools
40-
python -m pip install -r requirements/test.txt -r requirements/doc.txt
4140
python -m pip install codecov
4241
python -m pip install ${{ matrix.sphinx-version }}
4342
python -m pip list
4443
4544
- name: Install
4645
run: |
47-
python -m pip install .
46+
python -m pip install .[test,doc]
4847
pip list
4948
5049
- name: Run test suite
@@ -79,7 +78,7 @@ jobs:
7978
strategy:
8079
matrix:
8180
os: [ubuntu]
82-
python-version: ["3.11", "3.12"]
81+
python-version: ["3.11", "3.12", "3.13"]
8382
steps:
8483
- uses: actions/checkout@v4
8584

@@ -91,13 +90,12 @@ jobs:
9190
- name: Setup environment
9291
run: |
9392
python -m pip install --upgrade pip wheel setuptools
94-
python -m pip install --pre -r requirements/test.txt -r requirements/doc.txt
9593
python -m pip install codecov
9694
python -m pip list
9795
9896
- name: Install
9997
run: |
100-
python -m pip install .
98+
python -m pip install .[test,doc]
10199
pip list
102100
103101
- name: Run test suite

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ doc/_build
1616
numpydoc/tests/tinybuild/_build
1717
numpydoc/tests/tinybuild/generated
1818
MANIFEST
19+
node_modules

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
6+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
77
hooks:
88
- id: check-added-large-files
99
- id: check-ast
@@ -18,14 +18,14 @@ repos:
1818
- id: trailing-whitespace
1919

2020
- repo: https://github.com/pre-commit/mirrors-prettier
21-
rev: ffb6a759a979008c0e6dff86e39f4745a2d9eac4 # frozen: v3.1.0
21+
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
2222
hooks:
2323
- id: prettier
2424
types_or: [yaml, toml, markdown, css, scss, javascript, json]
2525
args: [--prose-wrap=preserve]
2626

2727
- repo: https://github.com/astral-sh/ruff-pre-commit
28-
rev: "f8a3f8c471fb698229face5ed7640a64900b781e" # frozen: v0.4.4
28+
rev: "89c421dff2e1026ba12cdb9ebd731f4a83aa8021" # frozen: v0.8.6
2929
hooks:
3030
- id: ruff
3131
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]

.readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ version: 2
66

77
# Set the OS, Python version and other tools you might need
88
build:
9-
os: ubuntu-22.04
9+
os: ubuntu-24.04
1010
tools:
11-
python: "3.11"
11+
python: "3.13"
1212
# You can also specify other tool versions:
1313
# nodejs: "19"
1414
# rust: "1.64"

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ numpydoc -- Numpy's Sphinx extensions
44

55
.. image:: https://readthedocs.org/projects/numpydoc/badge/?version=latest
66
:alt: Documentation Status
7-
:scale: 100%
87
:target: https://numpydoc.readthedocs.io/en/latest/
98

109
.. image:: https://codecov.io/gh/numpy/numpydoc/branch/main/graph/badge.svg

doc/conf.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import sys
1313
from datetime import date
1414

15+
from intersphinx_registry import get_intersphinx_mapping
16+
1517
import numpydoc
1618

1719
# for example.py
@@ -80,7 +82,7 @@
8082
html_theme = "pydata_sphinx_theme"
8183
html_theme_options = {
8284
"show_prev_next": False,
83-
"navbar_end": ["theme-switcher", "search-field.html", "navbar-icon-links.html"],
85+
"navbar_end": ["theme-switcher", "navbar-icon-links.html"],
8486
"icon_links": [
8587
{
8688
"name": "GitHub",
@@ -136,9 +138,6 @@
136138

137139
# -- Intersphinx setup ----------------------------------------------------
138140

139-
# Example configuration for intersphinx: refer to the Python standard library.
140-
intersphinx_mapping = {
141-
"python": ("https://docs.python.org/3/", None),
142-
"numpy": ("https://numpy.org/devdocs/", None),
143-
"sklearn": ("https://scikit-learn.org/stable/", None),
144-
}
141+
# Example configuration for intersphinx: refer to several Python libraries.
142+
143+
intersphinx_mapping = get_intersphinx_mapping(packages=["python", "numpy", "sklearn"])

doc/format.rst

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ respective types.
175175
y
176176
Description of parameter `y` (with type not specified).
177177

178-
Enclose variables in single backticks. The colon must be preceded
179-
by a space, or omitted if the type is absent.
178+
The colon must be preceded by a space, or omitted if the type is absent.
179+
When referring to a parameter anywhere within the docstring, enclose its
180+
name in single backticks.
180181

181182
For the parameter types, be as precise as possible. Below are a
182183
few examples of parameters and their types.
@@ -224,11 +225,11 @@ description, they can be combined::
224225
Input arrays, description of `x1`, `x2`.
225226

226227
When documenting variable length positional, or keyword arguments, leave the
227-
leading star(s) in front of the name::
228+
leading star(s) in front of the name and do not specify a type::
228229

229-
*args : tuple
230+
*args
230231
Additional arguments should be passed as keyword arguments
231-
**kwargs : dict, optional
232+
**kwargs
232233
Extra arguments to `metric`: refer to each metric documentation for a
233234
list of all possible arguments.
234235

@@ -549,23 +550,29 @@ not explicitly imported, `.. plot::` can be used directly if
549550
Documenting classes
550551
-------------------
551552

553+
.. _classdoc:
554+
552555
Class docstring
553556
```````````````
554557
Use the same sections as outlined above (all except :ref:`Returns <returns>`
555558
are applicable). The constructor (``__init__``) should also be documented
556559
here, the :ref:`Parameters <params>` section of the docstring details the
557-
constructor's parameters.
560+
constructor's parameters. While repetition is unnecessary, a docstring for
561+
the class constructor (``__init__``) can, optionally, be added to provide
562+
detailed initialization documentation.
558563

559564
An **Attributes** section, located below the :ref:`Parameters <params>`
560565
section, may be used to describe non-method attributes of the class::
561566

562567
Attributes
563568
----------
564569
x : float
565-
The X coordinate.
570+
Description of attribute `x`.
566571
y : float
567-
The Y coordinate.
572+
Description of attribute `y`.
568573

574+
When referring to an attribute anywhere within the docstring, enclose its
575+
name in single backticks.
569576
Attributes that are properties and have their own docstrings can be
570577
simply listed by name::
571578

@@ -606,6 +613,8 @@ becomes useful to have an additional **Methods** section:
606613
607614
"""
608615
616+
When referring to a method anywhere within the docstring, enclose its
617+
name in single backticks.
609618
If it is necessary to explain a private method (use with care!), it can
610619
be referred to in the :ref:`Extended Summary <extended_summary>` or the
611620
:ref:`Notes <notes>` section.
@@ -690,11 +699,11 @@ belong in docstrings.
690699
Other points to keep in mind
691700
----------------------------
692701
* Equations : as discussed in the :ref:`Notes <notes>` section above, LaTeX
693-
formatting should be kept to a minimum. Often it's possible to show equations as
694-
Python code or pseudo-code instead, which is much more readable in a
695-
terminal. For inline display use double backticks (like ``y = np.sin(x)``).
696-
For display with blank lines above and below, use a double colon and indent
697-
the code, like::
702+
formatting should be kept to a minimum. Often it's possible to show
703+
equations as Python code or pseudo-code instead, which is much more readable
704+
in a terminal. For inline display of code, use double backticks
705+
like ````y = np.sin(x)````. For display with blank lines above and below,
706+
use a double colon and indent the code, like::
698707

699708
end of previous sentence::
700709

@@ -717,9 +726,13 @@ Other points to keep in mind
717726
(i.e. scalar types, sequence types), those arguments can be documented
718727
with type `array_like`.
719728

720-
* Links : If you need to include hyperlinks in your docstring, note that
721-
some docstring sections are not parsed as standard reST, and in these
722-
sections, numpydoc may become confused by hyperlink targets such as::
729+
* Links : Depending on project settings, hyperlinks to documentation of
730+
modules, classes, functions, methods, and attributes should automatically
731+
be created if a recognized name is included within single backticks (e.g.
732+
```numpy``` renders as :any:`numpy`). If you need to include other
733+
hyperlinks, note that some docstring sections are not parsed as standard
734+
reST, and in these sections, numpydoc may become confused by hyperlink
735+
targets such as::
723736

724737
.. _Example: http://www.example.com
725738

@@ -729,17 +742,31 @@ Other points to keep in mind
729742

730743
`Example <http://www.example.com>`_
731744

732-
733745
Common reST concepts
734746
--------------------
735747
For paragraphs, indentation is significant and indicates indentation in the
736748
output. New paragraphs are marked with a blank line.
737749

738-
Use ``*italics*``, ``**bold**`` and ````monospace```` if needed in any
739-
explanations
740-
(but not for variable names and doctest code or multi-line code).
741-
Variable, module, function, and class names should be written between
742-
single back-ticks (```numpy```).
750+
Use ``*italics*``, ``**bold**`` if needed in any explanations.
751+
752+
Use of backticks in reST is a common point of confusion because it is different
753+
from markdown. In most flavors of markdown, single backticks are used for
754+
monospaced font; in reST, *double* backticks are for ``monospaced font``,
755+
whereas the behavior of single backticks is defined by the default role. This
756+
leads to the following style recommendations:
757+
758+
- Module, class, function, method, and attribute names should render as
759+
hyperlinks in monospaced font (e.g. :any:`numpy`); depending on project
760+
settings, this may be accomplished simply be enclosing them in single
761+
backticks. If the hyperlink does not render as intended, explicitly
762+
include the appropriate role and/or namespace.
763+
- This guide continues to recommended that parameter names be enclosed within
764+
single backticks. Currently, this may cause parameter names to render
765+
improperly and cause warnings, but numpydoc will soon release a feature
766+
that causes them to render as monospaced hyperlinks to the parameter
767+
documentation.
768+
- All other text that is intended to render in ``monospaced`` font should be
769+
enclosed within ````double backticks````.
743770

744771
A more extensive example of reST markup can be found in `this example
745772
document <http://docutils.sourceforge.net/docs/user/rst/demo.txt>`_;

doc/install.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This extension requires Python 3.9+, sphinx 6+ and is available from:
99

1010
* `numpydoc on PyPI <http://pypi.python.org/pypi/numpydoc>`_
1111
* `numpydoc on GitHub <https://github.com/numpy/numpydoc/>`_
12+
* `numpydoc on conda-forge <https://prefix.dev/channels/conda-forge/packages/numpydoc>`_
1213

1314
`'numpydoc'` should be added to the ``extensions`` option in your Sphinx
1415
``conf.py``. ``'sphinx.ext.autosummary'`` will automatically be loaded

0 commit comments

Comments
 (0)