Skip to content

Commit 07f991f

Browse files
committed
Transform function and method signatures to rst
1 parent a854ff1 commit 07f991f

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,59 @@
1-
(function-and-method-signatures)=
1+
.. _function-and-method-signatures:
22

3-
# Function and method signatures
3+
Function and method signatures
4+
==============================
45

56
Function signatures in this standard adhere to the following:
67

7-
1. Positional parameters must be
8-
[positional-only](https://www.python.org/dev/peps/pep-0570/) parameters.
8+
1. Positional parameters must be `positional-only <https://www.python.org/dev/peps/pep-0570/>`_ parameters.
99
Positional-only parameters have no externally-usable name. When a function
1010
accepting positional-only parameters is called, positional arguments are
1111
mapped to these parameters based solely on their order.
1212

13-
_Rationale: existing libraries have incompatible conventions, and using names
14-
of positional parameters is not normal/recommended practice._
13+
*Rationale: existing libraries have incompatible conventions, and using names
14+
of positional parameters is not normal/recommended practice.*
1515

16-
```{note}
16+
.. note::
1717

1818
Positional-only parameters are only available in Python >= 3.8. Libraries
1919
still supporting 3.7 or 3.6 may consider making the API standard-compliant
2020
namespace >= 3.8. Alternatively, they can add guidance to their users in the
21-
documentation to use the functions as if they were positional-only.
22-
```
21+
documentation to use the functions as if they were positional-only.
2322

24-
2. Optional parameters must be
25-
[keyword-only](https://www.python.org/dev/peps/pep-3102/) arguments.
23+
2. Optional parameters must be `keyword-only <https://www.python.org/dev/peps/pep-3102/>`_ arguments.
2624

27-
_Rationale: this leads to more readable code, and it makes it easier to
25+
*Rationale: this leads to more readable code, and it makes it easier to
2826
evolve an API over time by adding keywords without having to worry about
29-
keyword order._
27+
keyword order.*
3028

3129
3. For functions that have a single positional array parameter, that parameter
32-
is called `x`. For functions that have multiple array parameters, those
33-
parameters are called `xi` with `i = 1, 2, ...` (i.e., `x1`, `x2`).
30+
is called ``x``. For functions that have multiple array parameters, those
31+
parameters are called ``xi`` with ``i = 1, 2, ...`` (i.e., ``x1``, ``x2``).
3432

3533
4. Type annotations are left out of the signatures themselves for readability; however,
3634
they are added to individual parameter descriptions. For code which aims to
3735
adhere to the standard, adding type annotations is strongly recommended.
3836

3937
A function signature and description will look like:
4038

41-
```
42-
funcname(x1, x2, /, *, key1=-1, key2=None)
39+
::
4340

44-
Parameters
41+
funcname(x1, x2, /, *, key1=-1, key2=None) -> out:
42+
Parameters
4543

46-
x1 : array
47-
description
48-
x2 : array
49-
description
50-
key1 : int
51-
description
52-
key2 : Optional[str]
53-
description
44+
x1 : array
45+
description
46+
x2 : array
47+
description
48+
key1 : int
49+
description
50+
key2 : Optional[str]
51+
description
5452

55-
Returns
53+
Returns
5654

57-
out : array
58-
description
59-
```
55+
out : array
56+
description
6057

61-
Method signatures will follow the same conventions modulo the addition of
62-
`self`.
58+
59+
Method signatures will follow the same conventions modulo the addition of ``self``.

0 commit comments

Comments
 (0)