Commit Graph

97 Commits

Author SHA1 Message Date
Takeshi KOMIYA
a39cf57717 Close #8924: autodoc: Support bound argument for TypeVar 2021-02-24 22:51:06 +09:00
jfbu
87fa272763 Merge branch '3.x' into merge_3.x_into_master
Resolved Conflicts:
	sphinx/texinputs/sphinxpackagefootnote.sty
2021-02-04 16:31:45 +01:00
Takeshi KOMIYA
0d50b97fa3
Merge pull request #8297 from pbudzyns/exclude-members-fix
Local autodoc options override or extend autodoc_default_options.
2021-02-04 22:24:52 +09:00
jfbu
fbafb308b8 Merge branch '3.x' into master_with_merged_3.x 2021-02-02 18:01:55 +01:00
Takeshi KOMIYA
7ca5248057 Fix #8775: Avoid the crash of autodoc caused by type union operator
The type union operator (PEP-604) causes autodoc crashed in python 3.9
or below because of the syntax is not suppoerted yet in the interpreters.
Internally, `typing.get_type_hints()` raises TypeError on evaluating the
annotation by BitOr operator for types.

To avoid the crash, this adds a fallback not to evaluate the annotations
and keep as is.  As a side effect, `autodoc_type_aliases` will not work
for the modules and classes that uses type union operator for their
annotations.
2021-02-01 21:21:56 +09:00
pbudzyns
fd6587d5e9 rebase and fix tests 2021-02-01 10:58:09 +01:00
pbudzyns
270921d73a Merge remote-tracking branch 'upstream/3.x' into exclude-members-fix 2021-02-01 10:46:44 +01:00
pbudzyns
8d380cadc7 check if autodoc_defaults are str, fix tests 2021-02-01 09:46:19 +01:00
Takeshi KOMIYA
7318d1dfd4 autodoc: Support type union operator (PEP-604) (refs: #8775)
Upgrade autodoc to support type union operator introduced in
PEP-604. It's available only with python 3.10+.
2021-01-31 23:38:36 +09:00
pbudzyns
ac5079ed85 redundant '+' has no effect 2021-01-25 16:07:18 +01:00
pbudzyns
381e30c23b add more extendable options and tests 2021-01-25 13:24:01 +01:00
pbudzyns
7348ba8d60 add more extendable options and tests 2021-01-25 13:15:13 +01:00
pbudzyns
0a85b4148e add more extendable options and tests 2021-01-25 12:54:08 +01:00
Takeshi KOMIYA
5ce72f465b Merge branch '3.x' 2021-01-22 22:52:32 +09:00
Takeshi KOMIYA
d88166e84b Close #8514: autodoc: Default values of overloads are taken from actual implementation
As a well-known idiom, mypy recommends to use ellipsis ("...") for
default argument values as a elided style.  This allows to write the
style and helps to document it with copying the default argument
values from actual implementation.

Note: This does not copy the default argument value when the argument
of overloaded function has its own default value.
2021-01-17 02:32:50 +09:00
Takeshi KOMIYA
425cd1af02 Fix #8693: autodoc: Default values for overloads are rendered as string
The default values for overloaded functions are rendered as string
literal unexpectedly because autodoc extracts code snippets from
the source code, not actual value (ex. int, ellipsis, and so on).

This introduces a simple wrapper class; `DefaultValue` to render these
code snippets like actual values, not string literals.
2021-01-17 02:30:20 +09:00
Takeshi KOMIYA
4b452338f9 Merge branch '3.x' 2021-01-01 13:57:19 +09:00
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
a122397b4b Merge branch '3.x' 2020-12-29 18:37:45 +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
a7a77d154b Merge branch '3.x' 2020-12-20 21:33:57 +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
Takeshi KOMIYA
2c98e909bf Merge branch '3.x' 2020-12-14 02:02:29 +09:00
Takeshi KOMIYA
0b074c9e48 Merge commit 'a82b06f2abb1226d82b18e3f85bdf19be7b9eb3f' 2020-12-14 01:58:23 +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
a00d62c445 Merge branch '3.x' 2020-11-22 16:04:07 +09: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
3a4ae2092a Merge branch '3.x' 2020-11-21 01:01:36 +09:00
Takeshi KOMIYA
21a3bd4127 refactor: Fix flake8 violations under tests/ directory 2020-11-15 17:15:40 +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
6d5e43a0ff Drop code for supporting py35 2020-11-06 01:36:04 +09: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