Commit Graph

49 Commits

Author SHA1 Message Date
Takeshi KOMIYA
70ea4381ca
Merge pull request #8841 from AWhetter/autodoc_signatures_without_backslash
Overloaded function signatures do not require a separating backslash
2021-04-04 18:02:01 +09:00
Matt Wozniski
4c72848b85 Test autodoc_typehint_undoc
Add new tests to exercise the new autodoc_typehint_undoc option. Where
an existing test would have a meaningful behavior change with the new
option set to False, that test is copied, the new option is set to False
in the copy, and the assertions reflect the new expected behavior.

The new test test_autodoc_typehints_description_with_documented_init
illustrates the problem reported in #7329, and the new test
test_autodoc_typehints_description_with_documented_init_no_undoc
illustrates that this issue no longer occurs when the new
autodoc_typehint_undoc option is set to False.
2021-03-27 14:54:38 -04:00
Ashley Whetter
94b5607591 Overloaded function signatures do not require a separating backslash 2021-03-27 10:25:20 -07:00
Takeshi KOMIYA
75f5122996 Fix #7383: autodoc: Support typehints for properties
py:property directive now outputs py:property directive to describe
its type annotation.
2021-03-13 22:51:46 +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
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
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
85567748d9 Fix #8164: autodoc: Classes that inherit mocked class are not documented
Use ismock() to check a module member is a mocked or not. It allows not
to skip subclasses of mocked class.
2020-12-29 00:26:23 +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
ad804647b5
Merge pull request #8459 from tk0miya/8452_autodoc_type_aliases_with_autodoc_typehints
Fix #8452: autodoc_type_aliases doesn't work with autodoc_typehints
2020-11-22 01:34:31 +09:00
Takeshi KOMIYA
333e7a447e Fix #8452: autodoc_type_aliases doesn't work with autodoc_typehints 2020-11-22 01:26:32 +09:00
François Freitag
419e145e36
Make tests/ a Python package
Allows relative imports.
2020-11-20 19:43:02 +01:00
Takeshi KOMIYA
44fbe9da7b Fix #8434: autodoc_type_aliases does not effect to variables 2020-11-16 02:11:15 +09:00
Takeshi KOMIYA
68cc0f7e94
Merge pull request #8408 from francoisfreitag/isort
Sort imports with isort
2020-11-12 02:05:13 +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
6d1cafe7bd autodoc: Add Optional[t] to annotation of function and method
As typing.get_type_hints() doing, this adds Optional[t] to type
annotations if a default value equal to None is set.

Note: this is default behavior of inspect.signature() since Python 3.10.
2020-11-10 02:41:58 +09:00
Takeshi KOMIYA
e31189d970 test: do not use "object" for the type annotation
Usually we use "Any" type for the type annotation which takes any kinds
of types, instead of "object" class.  So this replaces "object" to "Any"
in our example.
2020-11-08 12:57:54 +09:00
Takeshi KOMIYA
cc97a07640 Fix #7785: autodoc_typehints=none does not effect to overloads 2020-10-24 20:54:56 +09:00
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
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
4e739b85ee Fix #7850: autodoc: KeyError is raised for invalid mark up 2020-06-26 20:49:22 +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
Kjell Braden
db72c18cf9 add testcase for complex typehintsext.autodoc.typehints 2020-05-10 20:46:29 +09:00
Takeshi KOMIYA
eef7e4cdd5 test: Rename test_autodoc.py to test_ext_autodoc.py 2020-05-06 13:55:45 +09:00
Takeshi KOMIYA
91a22a3ecc
Merge pull request #7358 from tk0miya/refactor_autodoc
refactor: autodoc: Remove needless spaces from blank line
2020-03-22 17:55:32 +09:00
Takeshi KOMIYA
9ebad705b8 refactor: autodoc: Remove needless spaces from blank line 2020-03-22 17:47:18 +09:00
Takeshi KOMIYA
d517aa6c16 Close #7079: Make autodoc_typehints=description formal 2020-03-07 13:19:37 +09:00
Takeshi KOMIYA
954db2bd27 Merge branch '2.0' 2020-02-16 21:42:20 +09:00
Takeshi KOMIYA
98d24464f1 refactor: Support suppressed type_comment (refs: #7152) 2020-02-16 17:32:21 +09:00
gpotter2
51b80ab121 Fix #7146 2020-02-14 16:12:12 +00:00
Takeshi KOMIYA
4dd8b1022f test: Use read_text() and read_bytes() 2020-02-01 11:58:51 +09:00
Takeshi KOMIYA
e7a0af807a Merge branch '2.0' 2020-01-30 23:29:32 +09:00
Takeshi KOMIYA
5397664d42 Add a new extension: sphinx.ext.autodoc.typehints 2020-01-25 17:56:39 +09:00
Takeshi KOMIYA
347e301727 Merge branch '2.0' 2020-01-19 22:47:02 +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
0319faf8f1 Merge branch '2.0' 2020-01-01 14:40:39 +09:00
Takeshi KOMIYA
eaf495c3c4 A happy new year! 2020-01-01 14:27:43 +09:00
Takeshi KOMIYA
01f8dad160 Merge branch '2.0' 2019-08-19 00:37:30 +09:00
Takeshi KOMIYA
ace7b4ded7 Fix #6589: autodoc: Formatting issues with autodoc_typehints='none' 2019-08-02 01:55:53 +09:00
jfbu
685e3fdb49 Merge branch '2.0' 2019-08-01 17:49:24 +02: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
9f470cec6c Merge branch '2.0' 2019-06-09 01:27:34 +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
f4114bb794 test: Update testcase for autodoc_inherit_docstrings 2019-06-03 22:34:35 +09:00
Takeshi KOMIYA
7de8c63407 test: Move testcases for autodoc configurations to test_ext_autodoc_configs 2019-06-03 01:28:56 +09:00