Commit Graph

72 Commits

Author SHA1 Message Date
Takeshi KOMIYA
7ecf6b88aa Merge branch '3.4.x' into 3.x 2021-01-01 13:56: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
9e9e486e65 Close #8022: autodoc: Allow to hide the value of the variables via metadata
autodata and autoattribute directives does not show right-hand value of
the variable if its docstring contains ``:meta hide-value:`` in
info-field-list.
2020-12-27 12:46:03 +09:00
Takeshi KOMIYA
70bb2262d6 Fix #8567: autodoc: Instance attributes are incorrectly added to Parent class
The instance attributes on subclasses are shown on the document of
parent class unexpectedly because of autodoc modifies `__annotations__`
in place.  This fix creates a copy of `__annotations__` attribute and
attach it to the subclass.
2020-12-22 02:38:31 +09:00
Takeshi KOMIYA
dd1615c59d
Merge pull request #8543 from tk0miya/8534_autoattribute_alias_derived
Fix #8534: autoattribute failed to document a commented attribute in alias dervied class
2020-12-17 22:35:35 +09:00
Takeshi KOMIYA
9721327989 Fix #8545: autodoc: a __slots__ attribute is not documented even having docstring
To avoid filtering __slots__ attributes having docstring at
filter_members(), this passes docstring captured at get_class_members()
to the filter_members() via ObjectMember.
2020-12-17 22:19:28 +09:00
Takeshi KOMIYA
0dbbf1dd54 Fix #8534: autoattribute failed to document a commented attribute in alias dervied class 2020-12-17 22:13:20 +09:00
Takeshi KOMIYA
55c110f609 Fix #8541: autodoc_type_aliases doesn't work for the instance attrs
So far, autodoc obtains type annotations of instance attributes by
ModuleAnalyzer directly.  As a result, autodoc_type_aliases are ignored
for these variables.

This goes to merge type annotations from the class itself and
ModuleAnalyzer's, and get type annotations using `typing.get_type_hints()`
to apply autodoc_type_aliases.
2020-12-17 01:07:54 +09:00
Takeshi KOMIYA
caa1d1f3c2 Fix #8534: autoattribute failed to document a commented attribute in alias class
So far, autoattribute uses "given class name" to fetch comments of
uninitialized instance attributes.  But pycode expects to use "real"
class name on searching attribute comments.

This adds UninitializedInstanceAttributeMixin to handle it simply.
2020-12-16 02:43:31 +09:00
Jon Dufresne
850512090a Remove duplicate test in test_ext_autodoc.py
Duplicate since c6bd84a614.
2020-12-12 06:28:23 -08:00
Takeshi KOMIYA
bb63f03034 Fix #8503: autoattribute could not create document for a GenericAlias 2020-11-29 12:24:10 +09:00
Timo Ludwig
ccfd98dc07
Fix #8493: Use restify() in autodoc to reference alias attributes 2020-11-28 12:12:02 +01:00
Takeshi KOMIYA
9eb96d5c79 Fix #8460: autodata directive does not display the detail of TypeVars
The details are only shown when automodule directive is used.  This
allows to document them via other auto* directives.
2020-11-22 13:57:48 +09:00
Takeshi KOMIYA
24a329eebe
Merge pull request #8465 from tk0miya/8460_NewType
Fix #8460: autodoc: Support custom types defined by typing.NewType
2020-11-22 13:47:39 +09:00
Takeshi KOMIYA
b4d4d4e808 refactor: Rename example class 2020-11-22 03:06:03 +09:00
Takeshi KOMIYA
6973888294 Support NewType as a class attribute 2020-11-21 23:56:16 +09:00
Takeshi KOMIYA
93d6c212f7 Fix #8460: autodoc: Support custom types defined by typing.NewType
A custom type defined by typing.NewType was rendered as a function
because the generated type is a function having special attributes.
This renders it as a variable.

Note: The module name where the NewType object defined is lost on
generating it.  So it is hard to make cross-reference for these custom
types.
2020-11-21 23:04:42 +09:00
Takeshi KOMIYA
21a3bd4127 refactor: Fix flake8 violations under tests/ directory 2020-11-15 17:15:40 +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
218de39462 Fix testcases for singledispatch are sometimes failed
They are sometimes failed with python3.5 because the order of singledispatch
functions is not stable on python 3.5.  This uses comparision via "in"
keyword to check the signature of singledispatch functions stably.
2020-11-04 23:19:27 +09:00
Matthias Geier
82c83ed478 autodoc: Add test for single-string __slots__ 2020-10-25 10:27:43 +01:00
Takeshi KOMIYA
6dbe28a632 Fix #7786: autodoc: can't detect overloaded methods defined in other file 2020-10-05 22:49:05 +09:00
Takeshi KOMIYA
ec06f5571e
Merge pull request #8142 from jcarrano/typing-generic-signatures
autodoc: fix constructor signatures for classes derived from typing.Generic
2020-10-03 01:23:36 +09:00
Takeshi KOMIYA
dfbe687db6
Merge branch '3.x' into 8103_cached_property 2020-09-13 11:07:33 +09:00
Juan Carrano
740be7f2a5 autodoc: blacklist typing.Generic.__new__
When documenting classes derived from typing.Generic (essentially all classes in the
typing module) the constructor signature would show an unhelpful (*args, **kwds).

typing.Generic has a __new__ method which was picked up by sphinx. With this patch it
is skipped and constructor signatures for generic classes are shown as they should.
2020-08-21 18:47:50 +02:00
Juan Carrano
642686159f autodoc: Test the signature of typing.Generic subclasses.
This test is currently failing because typing.Generic.__new__ clobbers the
real signature.
2020-08-21 18:47:14 +02:00
Takeshi KOMIYA
088b049170 Fix #8103: autodoc: cached_property is not considered as a property
sphinx.util.inspect:isproperty() does not considers that
cached_property decorator that has been added since Python 3.8 is
a kind of properties.  This fixes it.
2020-08-13 23:16:59 +09:00
Takeshi KOMIYA
611fff975e Fix #8099: autodoc: NameError is raised when script uses TYPE_CHECKING
`typing.get_type_hints()` raises NameError when the target object
contains unresolavable type annotation (ex. TYPE_CHECKING).  This
handles the exception and use unresolved annotations for type hints.
2020-08-13 22:57:12 +09:00
Takeshi KOMIYA
88b2ec6c34 Fix #8041: autodoc: An ivar on super class is not shown unexpectedly
An annotated instance variable on super class is not documented when
derived class has also other annotated instance variables because
`obj.__annotations__` is overrided by derived class's type hints.

To get annotations of the target class correctly, this scans MRO to
get all of annotated instance variables.
2020-08-08 00:21:29 +09:00
Takeshi KOMIYA
c0157cf074 refactor: test: Rename target.enum to target.enums
Using "enum" for module name bothers me on debugging errors because
it sometimes raises ImportError.
2020-08-03 02:30:30 +09:00
Takeshi KOMIYA
5d301b44b9 Fix #8032: autodoc: A typehint for inherited ivars is not shown
This tries to import the parent object for the instance attribute
to get type annotations for the variable.
2020-08-02 18:27:03 +09:00
Takeshi KOMIYA
488a173904 Fix #1362: autodoc: Support private class attributes
So far, autodoc treats a "private" class attribute as a mere attribute.
But its name is mangled by python interpreter. This make it unmangled
name to be documented expectedly.
2020-07-18 03:39:38 +09:00
Takeshi KOMIYA
610ab926a4 fix 2020-07-16 23:59:26 +09:00
Takeshi KOMIYA
9b74e6cd67 autodoc: the signature of base function will be shown for decorated functions 2020-07-05 03:08:27 +09:00
Takeshi KOMIYA
659846b805 Fix #7812: autodoc: crashed when given name is conflicted
Note: this partially reverts #7594 to avoid errors.
2020-07-04 20:48:02 +09:00
Takeshi KOMIYA
e860903cd8 Fix #7844: autodoc: Failed to detect module when relative module name given 2020-06-22 01:53:09 +09:00
Takeshi KOMIYA
8bd5f8b214 autodoc: Support TypeVar (refs: #7722) 2020-06-06 12:45:20 +09:00
Takeshi KOMIYA
49de4ab1a1 Support overloaded constructors (__call__, __init__ and __new__) 2020-06-02 00:44:07 +09:00
Takeshi KOMIYA
fb2f777079 Close #3610: autodoc: Support overloaded functions 2020-05-31 23:59:32 +09:00
Takeshi KOMIYA
c1fd36cc9c Close #4422: autodoc: Support GenericAlias 2020-05-30 21:53:42 +09:00
Eric Wieser
d229b120ad Fix autoclass signature parsing
This fixes:
* Signatures defined by __new__
* Signatures defined by metaclasses
* Signatures defined by builtin base classes

All of these changes bring the sphinx docs inline with the behavior of `inspect.signature`.

Note that this changes autodoc to output `.. py:class: MyClass()` with parentheses even if no user-defined __init__ is present.
This is quite deliberate, as if no user-defined `__init__` is present the default is `object.__init__`, which indeed does not take arguments.
2020-05-28 08:36:56 +01:00
Takeshi KOMIYA
a5e3b4a43d Fix #3673: autodoc: bysource order does not work for a module having __all__ 2020-05-23 21:52:11 +09:00
Takeshi KOMIYA
a1293e2825
Merge pull request #7709 from tk0miya/refactor_test_ext_autodoc
refactor: test: Separate tests for autofunction
2020-05-23 02:38:53 +09:00
Takeshi KOMIYA
f13e05a01b refactor: test: Separate tests for autofunction 2020-05-22 23:41:45 +09:00
Takeshi KOMIYA
c5f7ded772
Merge branch '3.x' into 7668_wront_retann 2020-05-22 23:15:47 +09:00
Takeshi KOMIYA
38a21d7dac Fix #7676: autodoc: typo in the default value of autodoc_member_order 2020-05-17 01:47:32 +09:00
Takeshi KOMIYA
fcfdc19624 refactor: autodoc: Remove magic mock from singledispatch processing 2020-05-16 22:55:24 +09:00
Jakob Lykke Andersen
97accc931d
Merge pull request #7663 from jakobandersen/astext
Fix astext() for two Sphinx nodes
2020-05-16 10:09:22 +02:00
Takeshi KOMIYA
dff45a11b7 Fix #7668: autodoc: wrong retann value is passed to autodoc-proccess-signature 2020-05-16 14:51:18 +09:00
Jakob Lykke Andersen
41971382f8 ... and don't break tests. 2020-05-14 19:41:17 +02:00