Commit Graph

161 Commits

Author SHA1 Message Date
Adam Turner
fb5b80c340 Fix PT007 (use lists in `pytest.mark.parametrize`) 2023-08-10 13:11:24 +01:00
Adam Turner
02e011e4ff Fix PT006 (use tuples in `pytest.mark.parametrize`) 2023-08-10 13:00:48 +01:00
Adam Turner
1cfb68d8be
Consistently name the object description options (#11533)
*  The directive option ``:noindex:`` was renamed to ``:no-index:``.
*  The directive option ``:noindexentry:`` was renamed to ``:no-index-entry:``.
*  The directive option ``:nocontentsentry:`` was renamed to ``:no-contents-entry:``.

The previous names are retained as aliases, but will be deprecated
and removed in a future version of Sphinx (9.0 or later).
2023-07-28 22:30:26 +01:00
latosha-maltba
97d2c5da2f
Add the `:no-typesetting:` option for only creating targets (#10478)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2023-07-28 19:43:27 +01:00
picnixz
480630c649
Support PEP 695 and PEP 696 syntax in the Python domain (#11444)
* Generic classes can be documented with ``.. py:class::`` using PEP 695 syntax:

  .. code:: rst

     .. py:class:: Sequence[T]

* Generic functions can be documented with ``.. py:function::`` using PEP 695 syntax:

  .. code:: rst

     .. py:function:: foo[T](x: T)

* Default values for type bounds are supported.

Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2023-07-23 23:22:40 +01:00
TLouf
86b07d4a97
Allow multi-line object description signatures (#11011)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-authored-by: Jean-François B <2589111+jfbu@users.noreply.github.com>
Co-authored-by: TLouf <loufthomas@gmail.com>
2023-05-11 14:28:57 +01:00
Adam Turner
4a3febb69a
Add an option for displaying short `Literal` types (#11109)
The new ``python_display_short_literal_types`` configuration option
for the ``py`` domain controls display of PEP 586 ``Literal`` types.
The 'short' format is inspired by PEP 604, using the bitwise OR operator
to distinguish the possible legal values for the argument.
2023-04-05 13:07:25 +01:00
Adam Turner
c8f4a03dac Fix COM812 2023-02-18 01:58:05 +00:00
Jeremy Maitin-Shepard
8de6638697
Add `content_offset parameter to nested_parse_with_titles` (#11147)
Previously, ``nested_parse_with_titles`` always passed ``0`` as the input
offset when invoking ``nested_parse``.  When parsing the content of a
directive, as is a common use case for ``nested_parse_with_titles``,
this leads to incorrect source file/line number information, as it
does not take into account the directive's ``content_offset``, which is
always non-zero.

This issue affects *all* object descriptions due to GH-10887.  It also
affects the ``sphinx.ext.ifconfig`` extension.

The ``py:module`` and ``js:module`` directives employed a workaround for
this issue, by wrapping the calls to ``nested_parse_with_title`` with
``switch_source_input``.  That worked, but was more complicated (and
likely less efficient) than necessary.

This commit adds an optional ``content_offset`` parameter to
``nested_parse_with_titles``, and fixes callers to pass the appropriate
content offset when needed.

This commit eliminates the now-unnecessary calls to
``switch_source_input`` and instead specifies the correct ``content_offset``.
2023-02-15 05:45:28 +00:00
Adam Turner
a13cf2c24d Adopt `profile = "black" for isort`
This allows using Ruff's import sorting fixers
2023-01-07 18:31:15 +00:00
Adam Turner
77a02cf696
Use PEP 604 display for `typing.Optional and typing.Union` (#11072) 2023-01-02 17:49:18 +00:00
Adam Turner
4660b62de0 Drop Python 3.7 2022-09-27 18:31:47 +01:00
Adam Turner
7649eb1505 Clean up after dropping Python 3.6 2022-09-27 18:31:47 +01:00
Adam Turner
14c9b40f15 Merge branch '5.x'
# Conflicts:
#	setup.py
#	sphinx/application.py
#	sphinx/environment/__init__.py
#	sphinx/ext/autodoc/directive.py
#	tests/test_build_html.py
2022-09-09 09:58:24 +01:00
danieleades
12bff8a273
Remove unneeded noqa lint suppression comments (#10772) 2022-08-28 20:03:17 +01:00
Jean-François B
5c82449eca Merge branch '5.x' 2022-08-06 18:31:14 +02:00
ProGamerGov
b2fe07e1a1
Properly support of in docstring type specifiers (#10738)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2022-08-02 23:43:32 +01:00
Jean-François B
80198e82aa Merge branch '5.x' into master
Resolved merge conflicts:
    sphinx/ext/extlinks.py
    sphinx/ext/napoleon/docstring.py
    (and removed from the latter a now unused import for flake8 F401
    compliance)
2022-06-30 15:00:16 +02:00
Adam Turner
ac0fc4b781
Remove more deprecated items in Sphinx 6.0 (#10562) 2022-06-26 15:01:09 +01:00
Jeremy Maitin-Shepard
1198fbe7f9
Ensure ObjectDescription signature nodes include line numbers (#10249)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2022-06-23 21:48:32 +01:00
Ezio Melotti
1a1491b8a7
Show the repr of the value in some warnings (#10439)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2022-06-16 21:07:25 +01:00
Adam Turner
b8a38f037b Special case ** 2022-06-15 10:15:53 +01:00
Adam Turner
3dc6ed166f Add higher level test 2022-06-15 09:29:35 +01:00
Anselm Kruis
6ffe881f55 Test for issue #10456: removing meta-fields
Add two meta-fields to an appropriate test case.
Currently the test fails, because of bug #10456.
The next commit fixes the issue.
2022-05-16 15:45:32 +02:00
Adam Turner
24e3b7c8c8 .read_text() -> .read_text(encoding='utf8') 2022-04-27 03:04:19 +01:00
Adam Turner
5775912455 Collapse single line docstrings 2022-02-20 03:13:45 +00:00
Adam Turner
6bb7b891a1 Remove copyright and licence fields 2022-02-20 03:06:23 +00:00
Adam Turner
5694e0ce60 Fix module docstring indentation 2022-02-20 00:35:13 +00:00
Adam Turner
4f5a3269a6 Fix module docstring first line 2022-02-20 00:11:08 +00:00
Adam Turner
6b8bccec59 Remove module titles in docstrings 2022-02-19 23:17:29 +00:00
Takeshi KOMIYA
a0e44a7300 test: Migrate to Node.findall() from Node.traverse() 2022-01-03 01:06:20 +09:00
Takeshi KOMIYA
f38bd8e952 Merge branch '4.3.x' into 4.x 2022-01-01 20:02:10 +09:00
Takeshi KOMIYA
b84771dcd2 A happy new year! 2022-01-01 18:45:03 +09:00
Takeshi KOMIYA
5da68c3de3 Fix py domain: "typing" types are not hyperlinked in info-field-list 2021-12-27 02:23:02 +09:00
Takeshi KOMIYA
0a5783f75b py domain: Suppress the leading "typing." module from typehints
To support creating hyperlinks to container types naturally, py domain
should take fully-qualified typehints for them.  But nobody wants to
show "typing." module name on the signature. So this suppresses them
automatically.
2021-12-25 02:50:31 +09:00
Takeshi KOMIYA
94cbce69da Fix #9194: autodoc: types in typing module are not hyperlinked
This converts types in typing module to valid references when
`autodoc_unqualified_typehints` option enabled.
2021-12-25 02:50:31 +09:00
Takeshi KOMIYA
49f576569c Fix autodoc: Failed to parse Literal type in py36 and py37 2021-12-25 02:41:38 +09:00
Takeshi KOMIYA
627d73a683 test: Remove debug print 2021-12-19 18:15:56 +09:00
Takeshi KOMIYA
5eaed2bed7 py domain: Allow "~" prefix as a prefix of typehints in signature
Now python domain supports the "~" prefix at the beginning of the
typehints of the function signatures:

  .. py:function:: func(x: ~typing.Dict)

It's rescognized as the same as python reference roles do
(ex. :py:class:`~typing.Dict`).
2021-11-30 01:54:23 +09:00
Takeshi KOMIYA
acaf70596e Fix #9899: py domain: Allows cross-reference specifier to :type: option 2021-11-29 00:32:56 +09:00
Takeshi KOMIYA
52787deb32 Fix #9775: py domain: Literal typehint was converted to a cross reference 2021-10-30 16:57:33 +09:00
Takeshi KOMIYA
34f957f131
Merge branch '4.x' into 9697_property_with_parens 2021-10-09 14:00:39 +09:00
Jakob Lykke Andersen
a64196f048 js/py nodes, update arglist rendering 2021-10-03 10:17:31 +02:00
Takeshi KOMIYA
b9204186f0 Fix #9697: An index entry with parens was registered for py:method 2021-10-03 13:03:23 +09:00
Jakob Lykke Andersen
fb45dba61e py nodes, isort fix 2021-10-02 12:42:17 +02:00
Jakob Lykke Andersen
01ef6a437f py nodes, PyObject anno 2021-10-02 12:41:40 +02:00
Jakob Lykke Andersen
ae7865aaf8 py nodes, PyProperty get_signature_prefix 2021-10-02 12:41:40 +02:00
Jakob Lykke Andersen
5a3b7f130d py nodes, PyMethod get_signature_prefix 2021-10-02 12:41:40 +02:00
Jakob Lykke Andersen
51e7b6d2aa py nodes, PyClassLike, get_signature_prefix 2021-10-02 12:41:40 +02:00
Jakob Lykke Andersen
83fcc98dbc py nodes, PyFunction get_signature_prefix 2021-10-02 12:41:40 +02:00