Commit Graph

150 Commits

Author SHA1 Message Date
Takeshi KOMIYA
120525563c Cloase #9445: :py:property: directive now supports :classmethod: option
Since python 3.9, `classmethod` starts to support creating a "class
property".  This allows to describe it.
2021-07-17 14:24:31 +09:00
Takeshi KOMIYA
866719f48f Merge branch '4.x' into 9427 2021-07-11 02:12:32 +09:00
Takeshi KOMIYA
dd89c3689e py domain: Add testcase for empty callable (refs: #9427) 2021-07-11 02:12:23 +09:00
Takeshi KOMIYA
90470b094e Close #9268: python_use_unqualified_type_names supports type field 2021-06-03 00:09:16 +09:00
Takeshi KOMIYA
201f61f722 Fix #9280: py domain: "exceptions" module is not displayed
Since v0.2, python domain gives a special treatment for the exceptions
module to suppress its name on documenting exception classes.  It had
been worthy on python2 era.  But the module has been removed since
python3.  Therefore, the special treatment becomes harmful for user
libraries.  This removes it to render module names correctly.

Note: Now we've only supported python3.  So this is not incompatible.
2021-05-30 03:46:55 +09:00
Takeshi KOMIYA
a1b0e55548 Close #1874: py domain: Support union types using | in info-field-list 2021-05-22 01:55:43 +09:00
Takeshi KOMIYA
d9be8f6d4e Fix #9224: info-field-list does not support a type containing space
So far, DocFieldTransformer has split the field name for `:type:`
and `:param:` at the first whitespace.  Therefore, it does not allow
to use a type containing whitespace (ex. `Dict[str, str]`).

This changes the splitting logic to divide the field name at the last
whitespace (a.k.a `rstrip()`).  It allows to use whitespaces on types.
2021-05-15 20:31:09 +09:00
Takeshi KOMIYA
4ab0dba755 Fix #9205: py domain: canonical option causes xref resolution error
The :canonical: option causes "more than one target for
cross-reference" warning because the class having the same name is
registered.
2021-05-11 01:15:14 +09:00
Takeshi KOMIYA
d02a466cb5 Fix #9121: py domain: duplicated warning for canonical and alias
A duplicated warning is emitted when both canonical and its alias
objects are defined on the same document. But it should not be emitted
because they're the same object, not conflicted.
2021-04-23 01:19:18 +09:00
Takeshi KOMIYA
c7b169c5a9 Fix #8127: py domain: Ellipsis in info-field-list causes nit-picky warning
On parsing the types, the leading dot of the ellipsis (...) is considered
as a reference name.  And its first dot is considered as a notation for
relative type reference (ex. ".ClassName"). As a result, it was converted
double dots unexpectedly.

This changes the parsing rule to treat the ellipsis as a symbol, not a
name.
2021-04-17 02:06:57 +09:00
Takeshi KOMIYA
204f86f736 py domain: Add py:property directive to describe a property (refs: #7068) 2021-03-11 01:56:39 +09:00
Takeshi KOMIYA
930a880294 Fix #7199: py domain: Add a new confval: python_use_unqualified_type_names
Add a new config variable: python_use_unqualified_type_names.  If enabled,
it goes to suppress the module name of the python reference if it can be
resolved.
2021-03-06 14:00:00 +09:00
jfbu
fbafb308b8 Merge branch '3.x' into master_with_merged_3.x 2021-02-02 18:01:55 +01:00
Takeshi KOMIYA
2c2b8c1154 py domain: Support type union operator (PEP-604) (refs: #8775)
Upgrade annotation parser for python domain to support type union
operator introduced in PEP-604.  It's available on all python
interpreters.
2021-02-01 21:12:29 +09:00
Takeshi KOMIYA
30f8640bab Merge branch '3.x' 2021-01-16 21:51:46 +09:00
Takeshi KOMIYA
a3df1d00c7 test: Add testcase for relative/short xref for py domain 2021-01-11 03:12:39 +09:00
Takeshi KOMIYA
918086b559 Close #5977: :var: field do not create a cross-reference
Since its beginning, `:var:` field has created a cross-reference to the
attribute having the same name.  It is meaningful only if the attribute
is documented by `py:attribute` directive.  It means the `:var:` field
and `:attr:` role are almost the same and conflicted.  Additionally,
the cross-reference points incorrect variable if the target is not
documented.

Thus, the cross-reference feature of `:var:` field is disabled.
2021-01-01 22:53:23 +09:00
Takeshi KOMIYA
9cac2001f7 test: py domain: Add a testcase for :var: field 2021-01-01 18:15:42 +09:00
Takeshi KOMIYA
4b452338f9 Merge branch '3.x' 2021-01-01 13:57:19 +09:00
Takeshi KOMIYA
f996859420 A happy new year!
.. note::

   $ find sphinx tests LICENSE doc/conf.py -type f -exec sed -i '' -e 's/2007\-20../2007-2021/' {} \;
   $ git co sphinx/locale/**/*.js sphinx/templates/epub3/mimetype
2021-01-01 13:40:48 +09:00
Takeshi KOMIYA
a7a77d154b Merge branch '3.x' 2020-12-20 21:33:57 +09:00
Takeshi KOMIYA
30c594fbc5 Fix #8365: py domain: :type: and :rtype: gives false ambiguous warnings
The searching context like py:module and py:class are missing in the
pending_xref nodes generated from info-field-lists.  This sets these
searching context info to them.
2020-12-19 18:42:01 +09:00
Takeshi KOMIYA
279e547860 Merge branch '3.x' 2020-11-12 02:50:43 +09:00
François Freitag
0949735210
Sort imports with isort
Keep imports alphabetically sorted and their order homogeneous across
Python source files.

The isort project has more feature and is more active than the
flake8-import-order plugin.

Most issues caught were simply import ordering from the same module.
Where imports were purposefully placed out of order, tag with
isort:skip.
2020-11-11 13:19:05 +01:00
Takeshi KOMIYA
8bf84167a3 Merge branch '3.x' 2020-11-05 02:21:47 +09:00
Takeshi KOMIYA
0e98e9b1a8 Fix #6914: Emit a detailed warning when failed to resolve :ref:
To be clear the ambiguous warning for missing-reference :ref:,
this separates the warning to missing-label and missing-caption.

To emit a warning dynamically, this also adds a new event:
`warn-missing-reference` to customize warning messages via event
handlers.
2020-11-03 02:27:43 +09:00
Takeshi KOMIYA
445b9515c1 Merge branch '3.x' 2020-10-24 18:12:45 +09:00
Eric Larson
d10802fa6a TST: Add test 2020-10-07 14:25:24 -04:00
Takeshi KOMIYA
cc941db40b Fix #8255: py domain: number in defarg is changed to decimal
Number literals in default argument value is converted to decimal form
unexpectedly by AST module.  This fixes the signature parsing code to
recosntruct it correctly.

Note: This is only available in Python 3.8+.
2020-10-05 01:08:14 +09:00
Takeshi KOMIYA
c14c00397e Merge branch '3.x' 2020-08-01 16:59:00 +09:00
Takeshi KOMIYA
a99675bf78 Fix #8008: py domain: failed to parse a type annotation containing ellipsis
Fix _parse_annotation() does not support a type annotation having ellipsis.
2020-07-30 01:48:25 +09:00
Takeshi KOMIYA
327c187284 Merge branch '3.x' 2020-07-24 23:49:45 +09:00
Takeshi KOMIYA
4410668776 Fix #7928: py domain: failed to resolve a type annotation for the attribute 2020-07-09 01:49:34 +09:00
Takeshi KOMIYA
1a223209f2 Merge branch '3.x' 2020-07-05 19:56:21 +09:00
Jakob Lykke Andersen
18b3e3c450 Add tests for noindexentry 2020-07-05 09:17:20 +02:00
Takeshi KOMIYA
fa9dc7c698 Merge tag 'v3.1.1' 2020-07-05 00:13:23 +09:00
Takeshi KOMIYA
cd7d3c0ddd Fix #7808: autodoc: Warnings raised on variable and attribute type annotations 2020-06-10 22:58:39 +09:00
Takeshi KOMIYA
3c7d35d2a2 Merge branch '3.x' 2020-05-17 19:12:56 +09:00
Jakob Lykke Andersen
41971382f8 ... and don't break tests. 2020-05-14 19:41:17 +02:00
Takeshi KOMIYA
e5dad73cf2 py domain: Add :canonical: option 2020-05-04 14:49:50 +09:00
Takeshi KOMIYA
88e8ebbe19 Close #7596: py domain: Change a type annotation for variables to a hyperlink 2020-05-04 14:30:20 +09:00
Takeshi KOMIYA
87308d9607 Close #7143: py domain: Add :final: option to py:*: directives 2020-04-28 01:24:29 +09:00
Takeshi KOMIYA
b2140c8623 Fix #7510: py domain: keyword-only arguments are wrongly rendered 2020-04-19 22:57:38 +09:00
Takeshi KOMIYA
2e219366c4 Fix #7461: py domain: fails with IndexError for empty tuple in type annotation 2020-04-12 12:57:22 +09:00
Takeshi KOMIYA
d9d381de11 Fix #7445: a return annotation `None` is not converted to a hyperlink 2020-04-10 02:07:02 +09:00
Takeshi KOMIYA
7aa5584a47 Fix #7301: capital characters are not allowed for node_id 2020-03-29 23:55:56 +09:00
Takeshi KOMIYA
fe9473f42e Fix #7219: py:module directive generates incorrect index entry 2020-03-29 19:37:21 +09:00
Takeshi KOMIYA
ce25d0080e Fix #7219: py:function directive generates incorrect index entry 2020-03-29 19:37:19 +09:00
Takeshi KOMIYA
8edae5fe28
Merge pull request #7356 from tk0miya/7301_node_id
Fix #7301: Allow . and _ for node_id
2020-03-22 23:42:56 +09:00
Takeshi KOMIYA
b0a6b3f285 Close #7341: py domain: type annotations are converted to cross refs 2020-03-22 17:10:00 +09:00
Takeshi KOMIYA
7bbf79c313 Fix #7301: Allow . and _ for node_id
In development of 3.0, Sphinx starts to obey to the rule of
"Identifier Normalization" of docutils.  This extends it to allow
dots(".") and underscores("_") for node identifier.

It allows Sphinx to generate node identifier from source string as
possible as it is (bacause dots and underscores are usually used in
many programming langauges).

This change will keep not to break hyperlinks as possible.
2020-03-22 16:39:00 +09:00
Takeshi KOMIYA
50cf68e0d4 py domain: Allow to make a style for arguments of functions and methods (refs: #6417) 2020-03-14 16:55:55 +09:00
Takeshi KOMIYA
dd455fe3d3 test: Add testcases for decorators 2020-03-07 23:05:26 +09:00
Takeshi KOMIYA
729efd28b0 py domain: Generate node_id for objects in the right way 2020-03-07 02:00:50 +09:00
Takeshi KOMIYA
5ff3b9dc4d py domain: Generate node_id for modules in the right way 2020-03-07 01:48:17 +09:00
Takeshi KOMIYA
0465c1a7ad Add testcase for modindex_common_prefix 2020-02-29 18:23:58 +09:00
Takeshi KOMIYA
01eff916d1 Fix missing commas after PEP-570 separators 2020-02-24 02:03:15 +09:00
Takeshi KOMIYA
6a439c0bd6
Merge pull request #7155 from tk0miya/function_signature2
py domain: Use AST parser to convert signature to doctree
2020-02-22 16:35:59 +09:00
Takeshi KOMIYA
ccd7381d38 test: Use Path.read_text() instead 2020-02-16 20:43:51 +09:00
Takeshi KOMIYA
c4d7f4d6c8 py domain: Use AST parser to convert signature to doctree 2020-02-16 01:52:04 +09:00
Takeshi KOMIYA
ecf7307023
Merge branch '2.0' into 6785_attr_can_refer_props 2020-02-06 22:30:50 +09:00
Takeshi KOMIYA
179a1f9cc2 py domain: Support type annotations for variables
This adds ``:type:`` and ``:value:`` options to both ``py:data``
and ``py:attribute`` directives.  It allows to describe its
annotation in detail.
2020-02-01 12:58:27 +09:00
Takeshi KOMIYA
33fcd393ab Fix #6785: py domain: :py:attr: is able to refer properties again 2020-01-25 13:55:27 +09:00
Takeshi KOMIYA
eaf495c3c4 A happy new year! 2020-01-01 14:27:43 +09:00
Takeshi KOMIYA
557d8d140e
Merge pull request #6365 from tk0miya/refactor_py_domain
Add :abstractmethod: option to py:method directive and support abstractmethod by autodoc
2019-05-19 23:46:34 +09:00
Takeshi KOMIYA
8ed6a9ceb4 Fix #6379: py domain: Module index (py-modindex.html) has duplicate titles 2019-05-19 22:19:13 +09:00
Takeshi KOMIYA
358e582490 Add :abstractmethod: option to py:method directive (refs: #6138) 2019-05-15 00:00:51 +09:00
Takeshi KOMIYA
a142a654fc Add :property: option to py:method directive 2019-05-12 15:53:39 +09:00
Takeshi KOMIYA
e0abb10792 Fix #4777: Add :async: option to py:function and py:method directives 2019-04-23 01:40:37 +09:00
Takeshi KOMIYA
331594e2ca Add :classmethod: and :staticmethod: options to py:method directive 2019-04-13 23:14:59 +09:00
Takeshi KOMIYA
6af3896103 Add PyFunction and PyVariable; directives for python functions and variables 2019-04-13 20:26:07 +09:00
Takeshi KOMIYA
fcc964b66f Add PyAttribute class; a directive for python attribute description 2019-04-07 22:40:08 +09:00
Takeshi KOMIYA
c8334705ca Add PyClassMethod and PyStaticMethod; directives for python method description 2019-04-07 22:39:27 +09:00
Takeshi KOMIYA
dd6c79476f Add PyMethod class; a directive for python method description 2019-04-07 22:39:27 +09:00
Takeshi KOMIYA
700be75a73 Fix #6196: py domain: unexpected prefix is generated 2019-03-23 22:32:37 +09:00
Takeshi KOMIYA
8980f637c9 Add testcase for sphinx.domains.python 2019-03-23 21:44:00 +09:00
Takeshi KOMIYA
65970a3033 Fix #6140: Use unittest.mock instead of mock 2019-03-09 15:16:04 +09:00
Takeshi KOMIYA
76e9f57c2e Merge branch '1.8' 2019-01-02 16:16:25 +09:00
Takeshi KOMIYA
1b1ebd2c75 A happy new year! 2019-01-02 16:00:30 +09:00
Jon Dufresne
6978918ffc Replace use of six.text_type with str
This removes the last use of the six package allowing Sphinx to remove
it as a dependency.
2018-12-18 16:23:10 -08:00
Jon Dufresne
bade33c7e4 Remove unnecessary encoding cookie from Python source files
In Python 3, the default encoding of source files is utf-8. The encoding
cookie is now unnecessary and redundant so remove it. For more details,
see the docs:

https://docs.python.org/3/howto/unicode.html#the-string-type

> The default encoding for Python source code is UTF-8, so you can
> simply include a Unicode character in a string literal ...

Includes a fix for the flake8 header checks to stop expecting an
encoding cookie.
2018-12-16 12:22:12 -08:00
Takeshi KOMIYA
c6bd84a614 refactor: Remove u-prefix from strings 2018-12-16 21:28:51 +09:00
Takeshi KOMIYA
c0fffb9e8b Fix #5432: py domain: :type: field can't process :term: references 2018-09-22 15:24:14 +09:00
Takeshi KOMIYA
f7027049b1 Fix flake8 violations 2018-02-19 23:20:56 +09:00
Takeshi KOMIYA
f1f6ca8cc9 Merge branch 'happy_new_year' into master 2018-01-01 01:09:17 +09:00
Takeshi KOMIYA
2426cedb8b A happy new year! 2018-01-01 01:06:58 +09:00
Takeshi KOMIYA
7e7b389eed Merge branch 'stable' 2017-10-23 12:23:58 +09:00
Takeshi KOMIYA
ffad4f08c7 Fix #3739: `:module:` option is ignored at content of pyobjects 2017-10-21 21:37:44 +09:00
Sam Park
7020f6b41d Add tests 2017-07-15 15:18:49 -07:00
Andy Freeland
7046d17631 Python parameter/variable types should match classes, not all objects
Parameter and variable types in the Python domain have the
counter-intuitive behavior of matching instance methods (or likely any
other objects) rather than classes, e.g.:

```python
class Foo(object):
    def list(self):
        """List some things."""

def bar(x):
    """
    :param x: x
    :type x: list
    """
```

`bar()` will link to `Foo.list()` rather than the standard library
`list` type.
2017-07-12 21:52:38 -07:00
shimizukawa
d497d74370 refs #3458: add sphinx.testing that are moved from /tests directory. 2017-05-14 20:47:15 +09:00
Takeshi KOMIYA
c07ed92a20 Merge branch 'stable' into 1.6-release 2017-05-13 15:42:03 +09:00
Takeshi KOMIYA
4104b93c6e Fix #3320: Warning about reference target not being found for container types 2017-05-13 15:03:11 +09:00
Takeshi KOMIYA
b39b0191a7 Fix #3351: intersphinx does not refers context 2017-04-16 18:25:21 +09:00
Takeshi KOMIYA
c57e47e042 Year++ 2017-03-26 11:49:34 +09:00
Anthony Johnson
b0875d63fc
Fix Python domain nesting
Moved #3465 here, to address this in `stable` instead.

This fixes a problem with the Python domain object nesting. Because only one
object name was stored in `ref_context`, and reset to `None` in `after_content`,
nesting broke if you put anything after a nested class:

```rst
.. py:class:: Parent

    .. py:method:: foo()

        This wouldn't resolve: :py:meth:`bar`

    .. py:class:: Child

        In the `after_content` method, the object is reset to `None`, so
        anything after this in the same nesting is considered to be top level
        instead.

    .. py:method:: bar()

        This is top level, as the domain thinks the surrounding object is `None`
```

This depends on #3519 and can be rebased after that is merged into stable

Fixes #3065
Refs #3067
2017-03-06 19:04:19 -08:00
Anthony Johnson
3502336b13
Add tests for xrefs on Python and JavaScript domains
These are just the passing test cases for the domains currently. I am going to
patch up issues with nesting on both domains to start, so these are the test
cases I'll be testing against. I'll see about addressing the other core
domains, or at very least the cpp domain, with similar tests if this looks
okay.

So far, these tests only test against methods/functions for the basic nesting
structure. More complete tests will test additional domain roles.

Refs #662
2017-03-05 16:00:25 -08:00
Georg Brandl
46d7e8558e Obligatory copyright update. 2016-01-14 22:54:04 +01:00
Georg Brandl
a23903d8d5 Merge branch 'stable' 2015-01-03 21:41:14 +01:00
Georg Brandl
d47a7587f9 Complete test suite overhaul.
* rename a few test modules to make the names more consistent

* do not copy/use Sphinx from build/ (unnecessary without 2to3)

* use a temporary dir for *all* test projects, the source tree
  will stay pristine that way  (default is tests/build)

* speed up tests by ~3x by splitting up test projects and avoiding
  rebuilds
2014-09-21 17:17:02 +02:00