Takeshi KOMIYA
f2c0dfe7c4
Close #6518 : autodoc: Add autodoc_type_aliases
...
autodoc_type_aliases allows to keep user defined type alises not
evaluated in the generated document.
2020-10-03 16:03:35 +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
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
916cd4c844
Fix #7901 : autodoc: annotations for overloaded functions are not resolved
...
So far, type annotations for overloaded functions are not resolved
because they are obtained from AST directly. This tries to evaluate
them using a context of its function or method.
2020-07-11 12:49:24 +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
d77622ba79
Fix #7807 : autodoc: wrong signature is shown for the function using contextmanager
2020-06-14 01:31:18 +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
3c5a9442c2
Merge branch '3.x' into 4422_support_GenericAlias
2020-05-31 14:49:13 +09:00
Takeshi KOMIYA
e20f29e325
Add sphinx.util.inspect:isgenericalias()
2020-05-30 21:06:54 +09:00
Takeshi KOMIYA
800dcf0f0a
Close #2106 : autodoc: Support multiple signatures on docstring
2020-05-30 15:40:21 +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
3a81ffa79a
Fix #7650 : autodoc: undecorated signature is shown for decorated functions
2020-05-11 01:11:12 +09:00
Kjell Braden
db72c18cf9
add testcase for complex typehintsext.autodoc.typehints
2020-05-10 20:46:29 +09:00
Takeshi KOMIYA
24fe05f14f
refactor: autodoc: class processors on autofunction is no longer needed
2020-05-07 01:55:33 +09:00
Takeshi KOMIYA
54bb1f3e62
refactor: test: Pass language_level to cython explicitly
2020-05-04 00:23:06 +09:00
Takeshi KOMIYA
9256daaa77
Merge branch '3.x' into 6857_enum_classmethod
2020-05-02 01:48:01 +09:00
Takeshi KOMIYA
25fc47e6b7
Fix #7559 : autodoc: misdetects a sync function is async
2020-05-01 22:05:45 +09:00
Takeshi KOMIYA
d612ef8f0b
Fix #6857 : autodoc: failed to detect a classmethod on Enum class
2020-04-30 22:54:49 +09:00
Takeshi KOMIYA
767864b0f1
Close #7143 : autodoc: Support final classes and methods
2020-04-28 01:24:41 +09:00
Takeshi KOMIYA
7888600f96
Merge pull request #7564 from eric-wieser/fix-missing-__annotations__
...
autodoc: Fix a logic error that causes annotations not to be shown for descriptors
2020-04-27 21:54:17 +09:00
Eric Wieser
b7ce4a4c13
Fix a logic error that causes annotations not to be shown for descriptors
...
This `if not self._datadescriptor` was originally here before type annotations were supported, to prevent showing `descr4 = <_Descriptor ...>` in the docs.
When type annotations were added, the support for appending `:type:` was put in the wrong place.
It should have been outside this if, not within it.
2020-04-27 12:57:39 +01:00
Takeshi KOMIYA
c9e4945623
Merge pull request #7473 from eric-wieser/meta-public
...
Add support for :meta public:
2020-04-23 02:15:42 +09:00
Takeshi KOMIYA
ffb1ca3aaa
test: Add a docstring to avoid an error on py39a5+
2020-04-18 20:28:31 +09:00
Eric Wieser
0d7451c23d
Add support for :meta public:
...
A common use case for this is a class like `namedtuple`, which has a public `_replace` method that is so-named in order not to conflict with arbitrary user-provided attributes.
Rejected spellings include:
* `:meta not-private:`
* `:meta private: False`
2020-04-14 08:41:45 +01:00
Takeshi KOMIYA
231d75b0d0
Merge branch '2.x' into 3.0.x
2020-04-05 23:03:35 +09:00
Takeshi KOMIYA
360efdefec
Fix #7355 : autodoc: a signature of cython-function is not recognized well
2020-03-31 21:14:08 +09:00
Takeshi KOMIYA
dd70d9faac
Fix #7331 : autodoc: a cython-method is not recognized as a method
2020-03-22 23:13:49 +09:00
Takeshi KOMIYA
5c396b6325
Fix #7331 : autodoc: a cython-function is not recognized as a function
2020-03-22 23:13:49 +09:00
Antony Lee
f9048cf18e
Handle singledispatch functions with rewritten signatures.
...
If a singledispatch function has its `__signature__` rewritten, autodoc
fails to annotate that signature because `func.__annotations__` is not
consulted. Instead, directly assign to `__signature__` instead.
2020-03-14 22:52:45 +01:00
Takeshi KOMIYA
8f7cc26b20
autodoc: Support singledispatch methods
2020-03-07 17:50:10 +09:00
Takeshi KOMIYA
961b4d1545
Close #2815 : autodoc: Support singledispatch functions
2020-03-07 17:50:10 +09:00
Takeshi KOMIYA
34057601f4
Close #7165 : autodoc: Support Annotated type (PEP-593)
2020-03-03 00:14:24 +09:00
Terence D. Honles
90de551d4c
Fix: autodoc: __wrapped__
functions are not documented correctly
...
Functions that are decorated with `@lru_cache` or other `functools`
decorators may not even be detected as a function. This results in the
documentation not having the `()` or even trying to render the function
signature.
This change updates the `sphinx.util.inspect` code to unwrap
`__wrapped__` functions before determining if they can be documented.
`@lru_cache` and its associated test is an example of a decorated
function that is incorrectly identified as an attribute rather than a
module level function and when rendering the signature (upon changing
`isattributedescriptor`) the decorated function is still incorrectly
identified as a C function.
This change also renames the newly introduced `unwrap` as `unwrap_all`
because it is different than the prexisting Python supplied
`inspect.unwrap`.
See `update_wrapper` "Changed in version 3.4" for more background:
https://docs.python.org/3/library/functools.html#functools.update_wrapper
2020-02-27 16:27:41 -08:00
Takeshi KOMIYA
754d04f80d
Merge branch '2.4.x' into 3.x
2020-02-22 19:22:31 +09:00
Takeshi KOMIYA
2fec37219f
Fix #7189 : autodoc: classmethod coroutines are not detected
2020-02-22 00:49:45 +09:00
Takeshi KOMIYA
954db2bd27
Merge branch '2.0'
2020-02-16 21:42:20 +09:00
Takeshi KOMIYA
b80c7cd234
Merge pull request #7152 from gpotter2/elipsispatch
...
Fix #7146 : support (...) in type hint comments (V2)
2020-02-16 20:35:40 +09:00
Takeshi KOMIYA
cd8f3a78d9
Fix #7156 : autodoc: separator for keyword only arguments is not shown
2020-02-16 01:37:23 +09:00
gpotter2
51b80ab121
Fix #7146
2020-02-14 16:12:12 +00:00
Takeshi KOMIYA
c5f0025ed9
Merge branch 'master' into 5637
2020-02-12 01:42:05 +09:00
Takeshi KOMIYA
2e87ee85a2
Merge branch '2.0'
2020-02-09 00:57:53 +09:00
Takeshi KOMIYA
92cb828f14
autodoc: Support type_comment styled type annotation for variables
2020-02-03 01:19:05 +09:00
Takeshi KOMIYA
e7a0af807a
Merge branch '2.0'
2020-01-30 23:29:32 +09:00
Takeshi KOMIYA
dcd8f41a77
Add testcase for instance variables without defaults
2020-01-26 01:25:35 +09:00
Takeshi KOMIYA
ecf38edb43
Close #7051 : autodoc: Support instance variables without defaults (PEP-526)
2020-01-25 00:57:36 +09:00
Takeshi KOMIYA
4e257a8084
Merge branch '2.0' into 7023_partial_listed_as_module_members
2020-01-19 23:09:46 +09:00
Takeshi KOMIYA
347e301727
Merge branch '2.0'
2020-01-19 22:47:02 +09:00
Takeshi KOMIYA
a1f6bbf800
Merge pull request #7031 from tk0miya/7023_nested_partial_functions_not_listed
...
#7023 : autodoc: nested partial functions are not listed
2020-01-19 15:49:52 +09:00
Takeshi KOMIYA
53e38ccc30
Fix #7023 : autodoc: partial functions are listed as module members
2020-01-19 15:22:09 +09:00
Takeshi KOMIYA
e908e43f67
Fix #7023 : autodoc: nested partial functions are not listed
2020-01-17 09:15:45 +09:00
Takeshi KOMIYA
7906a6871e
Add testcase a partialmethod not having docstring (refs: #7023 )
2020-01-17 09:11:59 +09:00
Takeshi KOMIYA
ffdfb6cb87
Close #2755 : autodoc: Support type_comment style annotation
...
Note: python3.8+ or typed_ast is required
2020-01-13 13:23:45 +09:00
Takeshi KOMIYA
9ed162921e
autodoc: Support Positional-Only Argument separator (PEP-570 compliant)
2020-01-11 02:32:33 +09:00
Takeshi KOMIYA
b968bb91e9
Close #6830 : autodoc: consider a member private if docstring has "private" metadata
2020-01-04 13:28:07 +09:00
Takeshi KOMIYA
1c088ec163
Fix #6567 : autodoc: autodoc_inherit_docstrings does not effect to __init__()
2019-07-11 01:39:17 +09:00
Takeshi KOMIYA
95723aa6f6
Fix flake8 violations
2019-07-01 00:28:30 +09:00
Takeshi KOMIYA
e0eb86224d
Merge branch '2.1.1' into 2.0
2019-06-10 22:31:18 +09:00
Takeshi KOMIYA
21be789d4d
Revert "Fix #1063 : autodoc: automodule directive handles undocumented module level variables"
...
This reverts commit 69d93c967c
(without
CHANGES).
2019-06-10 21:40:11 +09:00
Takeshi KOMIYA
81e2e1d971
test: Update testcase for autoclass_content and autodoc_docstring_signature
2019-06-03 23:20:33 +09:00
Takeshi KOMIYA
f7851b62e0
test: Update testcase for autoclass_content
2019-06-03 23:20:33 +09:00
Takeshi KOMIYA
42e9fd896e
test: Move class inheritance samples into target.inheritance module
2019-06-03 22:34:33 +09:00
Takeshi KOMIYA
3f617a4a9b
test: Update testcase for between()
2019-06-03 01:16:20 +09:00
Takeshi KOMIYA
6cbee7de3c
test: Move descriptor example to independent file
2019-06-03 00:38:01 +09:00
Takeshi KOMIYA
69d93c967c
Fix #1063 : autodoc: automodule directive handles undocumented module level variables
2019-06-01 23:18:37 +09:00
Takeshi KOMIYA
0ea380eddd
Close #6361 : autodoc: Add autodoc_typehints to suppress typehints from signature
2019-05-26 00:35:24 +09:00
Takeshi KOMIYA
277aba935d
Close #6325 : autodoc: Support attributes in __slots__
2019-05-22 09:56:46 +09:00
Takeshi KOMIYA
e288999933
Close #744 : autodoc: Support abstractmethod
2019-05-15 00:01:00 +09:00
Takeshi KOMIYA
a765c2e4ab
Add sphinx.util.inspect:iscoroutinefunction()
2019-04-23 01:40:37 +09:00
Alex Sergeev
b7f6657dd1
Address feedback
2019-04-13 22:09:01 -10:00
Takeshi KOMIYA
4aecac8251
refactor: Move subject of inspection to rootdir
2019-04-13 22:48:49 +09:00
Brendt Wohlberg
5334d96213
Merge branch 'master' into master
2019-02-28 16:49:01 -08:00
Takeshi KOMIYA
8a391d1781
Merge branch '1.8'
2019-02-17 22:37:23 +09:00
Takeshi KOMIYA
08cd23a0bb
Fix #6047 : autodoc: `autofunction
` emits a warning for method objects
2019-02-17 18:23:14 +09:00
Takeshi KOMIYA
686486498c
Closes #1148 : autodoc: Add autodecorator directive for decorators
2019-02-15 02:14:38 +09:00
Takeshi KOMIYA
a6ef8190ce
Add testcase for mocked objects in autodoc
2019-02-11 01:46:38 +09:00
Takeshi KOMIYA
5428d94d24
Remove coding magic comments from tests
2019-01-02 21:53:07 +09:00
Stephen Finucane
d345d0f8c1
py3: Remove (most) __future__ imports
...
There were two used:
- print_function
- absolute_import
Both of these are mandatory in Python 3.0 onwards [1] and can therefore
be removed...mostly. Unfortunately, mypy is still running in Python 2.7
mode, meaning we need the 'print_function' future wherever we're calling
'print' with the 'file' argument. There's also a single
'absolute_import' future that must be retained as its removal breaks a
test for as-yet unknown reasons. TODOs are added to resolve both issues
in the future.
[1] https://docs.python.org/3/library/__future__.html
Signed-off-by: Stephen Finucane <stephen@that.guru>
2018-12-17 09:46:15 +00:00
Takeshi KOMIYA
c6bd84a614
refactor: Remove u-prefix from strings
2018-12-16 21:28:51 +09:00
Takeshi KOMIYA
fd1dd13a50
refactor: Replace six.StringIO by io.StringIO
2018-12-15 21:00:38 +09:00
Takeshi KOMIYA
5f8b1ede8e
refactor: Replace six.add_metaclass by __metaclass_ attribute
2018-12-15 20:06:26 +09:00
Brendt Wohlberg
aacf2b8e65
Added test for correct nested class name when show-inheritance enabled
2018-12-02 08:36:31 -07:00
Takeshi KOMIYA
ea03286647
test: Move autodoc_missing_imports to test-ext-autodoc
2018-10-17 11:36:11 +09:00
Takeshi KOMIYA
48c634e623
test: Merge py35/test_autodoc_py35.py to test_autodoc.py
2018-09-22 16:41:44 +09:00
Takeshi KOMIYA
522105b79b
Merge branch '1.8'
2018-09-20 20:01:14 +09:00
Takeshi KOMIYA
c7f3933612
Merge branch '1.8' into 5431_warnings_for_callable
2018-09-18 23:34:33 +09:00
Takeshi KOMIYA
5c3a0e4e40
Fix #5431 : autodoc: `autofunction
` emits a warning for callable objects
2018-09-18 13:02:01 +09:00
Takeshi KOMIYA
9e8434f902
Fix #5436 : Autodoc does not work with enum subclasses with properties/methods
2018-09-18 13:01:10 +09:00
Takeshi KOMIYA
6d55e98da1
test: Move EnumCls to target.enum package
2018-09-18 13:01:10 +09:00
Takeshi KOMIYA
a7cab001d9
Drop APIs deprecated in 2.0
2018-09-03 00:31:33 +09:00
Takeshi KOMIYA
7f52ef7512
Merge branch '1.7'
2018-08-19 02:19:06 +09:00