Commit Graph

82 Commits

Author SHA1 Message Date
Takeshi KOMIYA
e38c1bda01 Fix a testcase 2022-04-03 22:44:12 +09:00
Takeshi KOMIYA
fd42063725 autodoc_typehints_description_target: Rename returnvalue_and_documented_params to documented_params 2022-04-03 22:42:44 +09:00
Takeshi KOMIYA
f731bf1999 Merge branch '5.x' into autodoc_force_undocumented_rtype 2022-04-03 22:29:22 +09:00
Takeshi KOMIYA
a78c07ca07 Fix #10280: autodoc_docstring_signature generates needless return typehint
Basically, autodoc suppresses return value typehint for class
constructors.  But it was unexpectedly shown if
`autodoc_docstring_signature` is enabled and docstring has multiple
signatures.
2022-04-03 16:32:35 +09:00
Takeshi KOMIYA
aa1bc83c2a Merge branch '4.x' 2022-03-19 22:58:15 +09:00
Takeshi KOMIYA
b12b39db05
Merge pull request #10212 from AA-Turner/remove-module-docstring-titles
Remove module docstring titles
2022-03-14 02:14:17 +09:00
Takeshi KOMIYA
f7a0107ddb Merge branch '4.x' 2022-03-03 02:28:07 +09:00
Takeshi KOMIYA
12104fe5de test: Follow the new behavior of typing.get_type_hints() since py311
Since python-3.11, `typing.get_type_hints()` will not add Optional[t] to
type annotations even if a default value for function argument is None.

refs: https://github.com/python/cpython/pull/30304 (bpo-46195)
2022-03-03 01:34:21 +09:00
Adam Turner
5775912455 Collapse single line docstrings 2022-02-20 03:13:45 +00:00
Adam Turner
6bb7b891a1 Remove copyright and licence fields 2022-02-20 03:06:23 +00:00
Adam Turner
5694e0ce60 Fix module docstring indentation 2022-02-20 00:35:13 +00:00
Adam Turner
4f5a3269a6 Fix module docstring first line 2022-02-20 00:11:08 +00:00
Adam Turner
6b8bccec59 Remove module titles in docstrings 2022-02-19 23:17:29 +00:00
Takeshi KOMIYA
616f112e6a autodoc: The default of autodoc_typehints_format becomes to 'smart'
The default value of autodoc_typehints_format configuration is changed
to `'smart'`.  It will suppress the leading module names of typehints
(ex. `io.StringIO` -> `StringIO`).

refs: #9075
2022-01-02 17:35:19 +09:00
Takeshi KOMIYA
e1c090d9f7
Merge pull request #10034 from tk0miya/10027_autodoc_typehints_format_for_bases
Fix #10027: autodoc_typehints_format does not work with :show-inheritance:
2022-01-02 11:39:22 +09:00
Takeshi KOMIYA
f38bd8e952 Merge branch '4.3.x' into 4.x 2022-01-01 20:02:10 +09:00
Takeshi KOMIYA
b84771dcd2 A happy new year! 2022-01-01 18:45:03 +09:00
Takeshi KOMIYA
3fc98a2b3d Fix #10027: autodoc_typehints_format does not work with :show-inheritance: 2022-01-01 18:06:57 +09:00
Takeshi KOMIYA
1f71f85fd6 Fix #10015: autodoc: autodoc_typehints_format='short' does not work when autodoc_typehints='description' 2021-12-27 02:23:02 +09:00
Takeshi KOMIYA
f3a098d4e9
Merge branch '4.x' into 9194_Literal_type_not_hyperlinked 2021-12-26 20:34:38 +09:00
Takeshi KOMIYA
7da429924e Fix testcase in py36 case 2021-12-26 20:34:05 +09:00
Takeshi KOMIYA
bdbad40f57 Fix #9194: autodoc: Prepend the "typing" module name on the signature
To create hyperlinks to container types automatically, this prepends the
module names for the types under "typing" module.
2021-12-26 01:04:40 +09:00
Takeshi KOMIYA
a87153c018 autodoc: Rename autodoc_unqualified_typehints to autodoc_typehints_format (refs: #9931) 2021-12-24 10:14:19 +09:00
Takeshi KOMIYA
c71ff1cd21 Close #9075: autodoc: Add a config variable autodoc_unqualified_typehints
If autodoc_unqualified_typehints feature enabled, autodoc suppresses the
leading module names of typehints of function signatures (ex.
`io.StringIO` -> `StringIO`)
2021-12-03 18:05:49 +09:00
gschwaer
1caf4823f2 feat: add tests and fix None rtype 2021-11-29 20:06:37 +01:00
Takeshi KOMIYA
f88ac53e51 Fix #9883: autodoc: doccomment for the alias to mocked object was ignored 2021-11-29 02:06:16 +09:00
Takeshi KOMIYA
5fb6fb6039 Fix #9651: autodoc_typehints_description_target was confused by :returns:
It only checks the existence of `:return:` field.  And it does not check
`:returns:` field.  It causes the absence of return types.
2021-09-26 02:10:13 +09:00
Christian Clauss
86583c578c Fix typos discovered by codespell 2021-09-08 02:15:25 +02:00
Jeremy Maitin-Shepard
6c969ac87e Fix autodoc_docstring_signature support for __init__ and __new__
The `MethodDocumenter.get_doc` method added by
51ae283a38 prevents
DocstringSignatureMixin from working correctly for __init__ and
__new__ methods.  Additionally, the __new__ docstring was not obtained
correctly.

This commit checks for `self._new_docstrings` being set, and also
corrects the logic for obtaining the __new__ docstring.

There still remains the issue that when the class signature is
obtained from the signature of __init__ or __new__, only the real
signature is used, due to the use of `sphinx.util.inspect.signature`;
the autodoc_docstring_signature option does not have any effect.
2021-07-31 09:32:40 -07:00
Takeshi KOMIYA
2aef00d7bd Fix #9384: autodoc_typehints='none' supports typehints for attributes 2021-06-29 21:57:26 +09:00
Takeshi KOMIYA
51ae283a38 Close #4257: autodoc: Add autodoc_class_signature
Add `autodoc_class_signature` to separate the class entry and the
definition of `__init__()` method.
2021-05-16 01:53:48 +09:00
Ashley Whetter
28d3f8136e autodoc.typehints can accurately represent overloads 2021-05-08 21:34:25 -07:00
Takeshi KOMIYA
28ab5f233c Close #8588: autodoc: autodoc_type_aliases supports dotted name
It allows users to define an alias for a class with module name
like `foo.bar.BazClass`.
2021-05-03 18:47:47 +09:00
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