Commit Graph

88 Commits

Author SHA1 Message Date
Takeshi KOMIYA
a59f83b6bd Add sphinx.util.inspect:signature_from_ast() 2020-05-31 23:22:20 +09:00
Takeshi KOMIYA
c063c9c0fe
Merge pull request #7757 from tk0miya/7756_posonlyargs
Fix #7756: py domain: The default value for posonlyarg is not shown
2020-05-31 23:21:21 +09:00
Takeshi KOMIYA
bb0b69544b Fix #7756: py domain: The default value for posonlyarg is not shown 2020-05-31 12:21:55 +09:00
Takeshi KOMIYA
e20f29e325 Add sphinx.util.inspect:isgenericalias() 2020-05-30 21:06:54 +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
0526e0a56c
Merge branch '3.x' into 7650_undecorated_signature 2020-05-16 14:56:54 +09:00
John R. Lenton
61378fe048 Make sphinx.util.typing.stringify render optional unions better
Without this change, stringify(Optional[Union[int, str]]) returns
'Union[int, str, None]' rather than the expected 'Optional[...]'.

This change fixes that.

fixes: #7654
2020-05-11 17:20:45 +01:00
Takeshi KOMIYA
3a81ffa79a Fix #7650: autodoc: undecorated signature is shown for decorated functions 2020-05-11 01:11:12 +09:00
Takeshi KOMIYA
6c65327be7
Merge pull request #7624 from tk0miya/refactor_autodoc2
refactor: autodoc: class processors on autofunction is no longer needed
2020-05-09 18:10:55 +09:00
Eric Wieser
c8a4c79daf Do not crash if is_builtin_class_method is passed a non-type 2020-05-08 08:54:53 +01:00
Takeshi KOMIYA
24fe05f14f refactor: autodoc: class processors on autofunction is no longer needed 2020-05-07 01:55:33 +09:00
Takeshi KOMIYA
13113fc0b6 Fix #6588: autodoc: Decorated inherited method has no documentation 2020-04-28 22:33:40 +09:00
Takeshi KOMIYA
b2140c8623 Fix #7510: py domain: keyword-only arguments are wrongly rendered 2020-04-19 22:57:38 +09:00
Takeshi KOMIYA
754d04f80d Merge branch '2.4.x' into 3.x 2020-02-22 19:22:31 +09:00
Takeshi KOMIYA
56eca39cbb Fix a testcase: lambda function renderer has been changed in 3.x 2020-02-22 17:04:05 +09:00
Takeshi KOMIYA
6a439c0bd6
Merge pull request #7155 from tk0miya/function_signature2
py domain: Use AST parser to convert signature to doctree
2020-02-22 16:35:59 +09:00
Takeshi KOMIYA
2fec37219f Fix #7189: autodoc: classmethod coroutines are not detected 2020-02-22 00:49:45 +09:00
Takeshi KOMIYA
63ece93473
Merge pull request #7163 from tk0miya/fix_DeprecationWarning
Fix DeprecationWarnings on testing
2020-02-16 21:45:29 +09:00
Takeshi KOMIYA
7e79822355 Remove testscases for getargspec() (deprecated) 2020-02-16 21:22:23 +09:00
Takeshi KOMIYA
822625d14c Add sphinx.util.inspect:signature_from_str() 2020-02-16 01:43:13 +09:00
Takeshi KOMIYA
cd8f3a78d9 Fix #7156: autodoc: separator for keyword only arguments is not shown 2020-02-16 01:37:23 +09:00
Takeshi KOMIYA
e908e43f67 Fix #7023: autodoc: nested partial functions are not listed 2020-01-17 09:15: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
5867416612 refactor: Add sphinx.util.inspect.signature()
As a successor of sphinx.util.inspect.Singnature, this adds
signature() function behaves like `inspect.signature()`.  It is
very similar to way of python's inspect module.

In addition, this also adds stringify_annotation() helper to
sphinx.util.inspect module.  With these two functions, we can move
to python's Signature object to represent function signatures
perfectly.  It's natural design for python developers than ever.
2020-01-09 00:32:07 +09:00
Takeshi KOMIYA
eaf495c3c4 A happy new year! 2020-01-01 14:27:43 +09:00
Takeshi KOMIYA
b43676011e
Merge branch '2.0' into 6574_annotation_for_varidic_params 2019-08-03 02:19:29 +09:00
Takeshi KOMIYA
ace7b4ded7 Fix #6589: autodoc: Formatting issues with autodoc_typehints='none' 2019-08-02 01:55:53 +09:00
Takeshi KOMIYA
92491c0769 Fix autodoc: missing type annotation for variadic and keyword parameters (refs: #6574) 2019-07-13 19:25:38 +09:00
Takeshi KOMIYA
95723aa6f6 Fix flake8 violations 2019-07-01 00:28:30 +09:00
Takeshi KOMIYA
880c47ff61 Fix #6347: autodoc: crashes with a plain Tuple on Python 3.6 and 3.5 2019-05-29 00:51:01 +09:00
Takeshi KOMIYA
c59f2d9545 Add sphinx.util.inspect:isproperty() 2019-05-12 15:53:39 +09:00
Takeshi KOMIYA
a765c2e4ab Add sphinx.util.inspect:iscoroutinefunction() 2019-04-23 01:40:37 +09:00
Takeshi KOMIYA
d41cae328e Add sphinx.util.inspect:isattributedescriptor() 2019-04-14 02:16:17 +09:00
Takeshi KOMIYA
4aecac8251 refactor: Move subject of inspection to rootdir 2019-04-13 22:48:49 +09:00
Takeshi KOMIYA
2652927667 test: Add testcase for isdescriptor() 2019-04-13 19:52:51 +09:00
Takeshi KOMIYA
b4f6a7f643 test: Add testcase for isbuiltin() 2019-04-13 19:52:51 +09:00
Takeshi KOMIYA
2e8842963b test: Add testcase for isfunction() 2019-04-13 19:52:51 +09:00
Jon Dufresne
f210475489 Python-3-only clean ups discovered by pyupgrade
https://github.com/asottile/pyupgrade

> A tool to automatically upgrade syntax for newer versions of the
> language.

- Drop u str prefix
- Drop base object inheritance
- Drop args to super()
- Use set literals
- Use dict comprehension
- Use set comprehension
2019-03-17 12:58:03 -07:00
Takeshi KOMIYA
76e9f57c2e Merge branch '1.8' 2019-01-02 16:16:25 +09:00
Takeshi KOMIYA
1b1ebd2c75 A happy new year! 2019-01-02 16:00:30 +09:00
Jon Dufresne
bade33c7e4 Remove unnecessary encoding cookie from Python source files
In Python 3, the default encoding of source files is utf-8. The encoding
cookie is now unnecessary and redundant so remove it. For more details,
see the docs:

https://docs.python.org/3/howto/unicode.html#the-string-type

> The default encoding for Python source code is UTF-8, so you can
> simply include a Unicode character in a string literal ...

Includes a fix for the flake8 header checks to stop expecting an
encoding cookie.
2018-12-16 12:22:12 -08:00
Takeshi KOMIYA
8b687ac304 Merge branch '1.8' 2018-11-01 01:24:12 +09:00
Takeshi KOMIYA
793792fafc Fix #5480: autodoc: unable to find type hints for unresolvable Forward references 2018-10-15 23:40:05 +09:00
Takeshi KOMIYA
dc44b0d2a9 Merge branch 'master' into HEAD 2018-09-22 22:54:15 +09:00
Takeshi KOMIYA
3a2418a827 refactoring: Drop PY2 and PY3 flags 2018-09-22 21:27:59 +09:00
Takeshi KOMIYA
40a2fdf315 test: Merge py3/test_util_inspect_py3.py to test_util_inspect.py 2018-09-22 16:36:10 +09:00
Takeshi KOMIYA
b18fe13f55 Drop branches for sys.version_info < (3, 4) 2018-09-22 16:31:07 +09:00
Jon Dufresne
490e4aed41 Remove unnecessary object from class definitions
In Python 3, all classes are new-style classes. The object in the
definition is redundant and unnecessary.
2018-09-11 07:07:01 -07:00
Chris Lamb
17d32d625b Ensure frozenset object descriptions are reproducible
Whilst working on the Reproducible Builds effort [0], we noticed
that sphinx could generate output that is not reproducible.

In particular, the rendering of `frozenset` objects in default
arguments and elsewhere is currently non-determinstic.

For example:

    frozenset(['a', 'b', 'c'])

Might be rendered as any of:

    frozenset({'a', 'b', 'c'})
    frozenset({'a', 'c', 'b'})
    frozenset({'b', 'a', 'c'})
    frozenset({'b', 'c', 'a'})
    frozenset({'c', 'a', 'b'})
    frozenset({'c', 'b', 'a'})

Patch attached that sorts the contents of frozensets whilst rendering.
This is parallel to the `dict` and `set` type logic

  [0] https://reproducible-builds.org/
2018-09-05 15:58:54 +01:00
Takeshi KOMIYA
ea3d0b3768 Merge branch '1.7' into 1.8 2018-08-25 03:07:35 +09:00