From 7afb41757c364556e1826a3ba907b5631aca769f Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Sun, 3 Jun 2018 20:34:47 +0300 Subject: [PATCH] PY-29717 Don't render type for "self"/"cls" method parameters These are mostly obvious at the call site. --- .../python/documentation/PythonDocumentationProvider.java | 8 +++++--- .../quickdoc/AncestorClassDocstringForConstructor.html | 2 +- .../AncestorInnerClassDocstringForConstructor.html | 2 +- .../testData/quickdoc/ClassDocstringForConstructor.html | 2 +- .../testData/quickdoc/ClassUndocumentedConstructor.html | 2 +- .../quickdoc/ClassUndocumentedEmptyConstructor.html | 2 +- python/testData/quickdoc/HoverOverMethod.html | 2 +- python/testData/quickdoc/InheritedMethod.html | 2 +- python/testData/quickdoc/InheritedMethodOfInnerClass.html | 2 +- .../quickdoc/InnerClassDocstringForConstructor.html | 2 +- python/testData/quickdoc/Method.html | 2 +- python/testData/quickdoc/PropNewDeleter.html | 2 +- python/testData/quickdoc/PropNewDocstringOfGetter.html | 2 +- python/testData/quickdoc/PropNewGetter.html | 2 +- python/testData/quickdoc/PropNewSetter.html | 2 +- python/testData/quickdoc/PropNewUndefinedSetter.html | 2 +- python/testData/quickdoc/PropOldDeleter.html | 2 +- .../testData/quickdoc/PropOldDocParamOfPropertyCall.html | 2 +- python/testData/quickdoc/PropOldDocstringOfGetter.html | 2 +- python/testData/quickdoc/PropOldGetter.html | 2 +- python/testData/quickdoc/PropOldSetter.html | 2 +- python/testData/quickdoc/PropOldUndefinedSetter.html | 2 +- .../quickdoc/ReferenceToMethodQualifiedWithInstance.html | 2 +- .../testData/quickdoc/SingleArgumentMethodNotWrapped.html | 2 +- 24 files changed, 28 insertions(+), 26 deletions(-) diff --git a/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java b/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java index b73a792d488f..205c537776c2 100644 --- a/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java +++ b/python/src/com/jetbrains/python/documentation/PythonDocumentationProvider.java @@ -244,9 +244,11 @@ public class PythonDocumentationProvider extends AbstractDocumentationProvider i else { firstIsSelf = parameter.isSelf(); } - result.append(escaped(StringUtil.notNullize(parameter.getName(), PyNames.UNNAMED_ELEMENT))) - .append(saveSpaces(": ")); - result.append(formatTypeWithLinks(parameter.getType(context), function, context)); + result.append(escaped(StringUtil.notNullize(parameter.getName(), PyNames.UNNAMED_ELEMENT))); + if (!parameter.isSelf()) { + result.append(saveSpaces(": ")); + result.append(formatTypeWithLinks(parameter.getType(context), function, context)); + } first = false; } diff --git a/python/testData/quickdoc/AncestorClassDocstringForConstructor.html b/python/testData/quickdoc/AncestorClassDocstringForConstructor.html index 875570053654..94f6e68edea4 100644 --- a/python/testData/quickdoc/AncestorClassDocstringForConstructor.html +++ b/python/testData/quickdoc/AncestorClassDocstringForConstructor.html @@ -1 +1 @@ -
AncestorClassDocstringForConstructor.Sub
def __init__(self: Sub) -> None
Class docstring.

Documentation is copied from:

Base
\ No newline at end of file +
AncestorClassDocstringForConstructor.Sub
def __init__(self) -> None
Class docstring.

Documentation is copied from:

Base
\ No newline at end of file diff --git a/python/testData/quickdoc/AncestorInnerClassDocstringForConstructor.html b/python/testData/quickdoc/AncestorInnerClassDocstringForConstructor.html index ce760ab07b67..b053458fa5c4 100644 --- a/python/testData/quickdoc/AncestorInnerClassDocstringForConstructor.html +++ b/python/testData/quickdoc/AncestorInnerClassDocstringForConstructor.html @@ -1 +1 @@ -
Sub
def __init__(self: Sub) -> None
Class docstring.

Documentation is copied from:

Base
\ No newline at end of file +
Sub
def __init__(self) -> None
Class docstring.

Documentation is copied from:

Base
\ No newline at end of file diff --git a/python/testData/quickdoc/ClassDocstringForConstructor.html b/python/testData/quickdoc/ClassDocstringForConstructor.html index dc6a4573392e..3517afeea071 100644 --- a/python/testData/quickdoc/ClassDocstringForConstructor.html +++ b/python/testData/quickdoc/ClassDocstringForConstructor.html @@ -1 +1 @@ -
ClassDocstringForConstructor.MyClass
def __init__(self: MyClass) -> None
Class docstring.

Documentation is copied from:

MyClass
\ No newline at end of file +
ClassDocstringForConstructor.MyClass
def __init__(self) -> None
Class docstring.

Documentation is copied from:

MyClass
\ No newline at end of file diff --git a/python/testData/quickdoc/ClassUndocumentedConstructor.html b/python/testData/quickdoc/ClassUndocumentedConstructor.html index 6f2c8f3bf948..fca685b4f79a 100644 --- a/python/testData/quickdoc/ClassUndocumentedConstructor.html +++ b/python/testData/quickdoc/ClassUndocumentedConstructor.html @@ -1 +1 @@ -
ClassUndocumentedConstructor.Foo
def __init__(self: Foo) -> None
Doc of Foo.

Documentation is copied from:

Foo
\ No newline at end of file +
ClassUndocumentedConstructor.Foo
def __init__(self) -> None
Doc of Foo.

Documentation is copied from:

Foo
\ No newline at end of file diff --git a/python/testData/quickdoc/ClassUndocumentedEmptyConstructor.html b/python/testData/quickdoc/ClassUndocumentedEmptyConstructor.html index 396d7df0ccf2..2e530823697e 100644 --- a/python/testData/quickdoc/ClassUndocumentedEmptyConstructor.html +++ b/python/testData/quickdoc/ClassUndocumentedEmptyConstructor.html @@ -1 +1 @@ -
ClassUndocumentedEmptyConstructor.Foo
def __init__(self: Foo) -> None
Doc of Moo()

Documentation is copied from:

Moo.__init__
\ No newline at end of file +
ClassUndocumentedEmptyConstructor.Foo
def __init__(self) -> None
Doc of Moo()

Documentation is copied from:

Moo.__init__
\ No newline at end of file diff --git a/python/testData/quickdoc/HoverOverMethod.html b/python/testData/quickdoc/HoverOverMethod.html index 4b3b009d9b08..df3b31fcbac6 100644 --- a/python/testData/quickdoc/HoverOverMethod.html +++ b/python/testData/quickdoc/HoverOverMethod.html @@ -1,2 +1,2 @@ class A -def f(self: A) -> int \ No newline at end of file +def f(self) -> int \ No newline at end of file diff --git a/python/testData/quickdoc/InheritedMethod.html b/python/testData/quickdoc/InheritedMethod.html index c30c155f3cd3..4dc65fd84de9 100644 --- a/python/testData/quickdoc/InheritedMethod.html +++ b/python/testData/quickdoc/InheritedMethod.html @@ -1 +1 @@ -
InheritedMethod.B
def foo(self: B) -> None
Doc from A.foo.

Documentation is copied from:

A.foo
\ No newline at end of file +
InheritedMethod.B
def foo(self) -> None
Doc from A.foo.

Documentation is copied from:

A.foo
\ No newline at end of file diff --git a/python/testData/quickdoc/InheritedMethodOfInnerClass.html b/python/testData/quickdoc/InheritedMethodOfInnerClass.html index 77e85371631e..78da378db495 100644 --- a/python/testData/quickdoc/InheritedMethodOfInnerClass.html +++ b/python/testData/quickdoc/InheritedMethodOfInnerClass.html @@ -1 +1 @@ -
Sub
def method(self: Sub) -> None
Base class docstring.

Documentation is copied from:

Base.method
\ No newline at end of file +
Sub
def method(self) -> None
Base class docstring.

Documentation is copied from:

Base.method
\ No newline at end of file diff --git a/python/testData/quickdoc/InnerClassDocstringForConstructor.html b/python/testData/quickdoc/InnerClassDocstringForConstructor.html index a5344c901753..49b61002f28a 100644 --- a/python/testData/quickdoc/InnerClassDocstringForConstructor.html +++ b/python/testData/quickdoc/InnerClassDocstringForConstructor.html @@ -1 +1 @@ -
MyClass
def __init__(self: MyClass) -> None
Class docstring.

Documentation is copied from:

MyClass
\ No newline at end of file +
MyClass
def __init__(self) -> None
Class docstring.

Documentation is copied from:

MyClass
\ No newline at end of file diff --git a/python/testData/quickdoc/Method.html b/python/testData/quickdoc/Method.html index 0b05b718234a..d8fad60654a1 100644 --- a/python/testData/quickdoc/Method.html +++ b/python/testData/quickdoc/Method.html @@ -1 +1 @@ -
Method.Foo
@deco
def meth(self: Foo) -> Optional[Any]
Doc of meth.
\ No newline at end of file +
Method.Foo
@deco
def meth(self) -> Optional[Any]
Doc of meth.
\ No newline at end of file diff --git a/python/testData/quickdoc/PropNewDeleter.html b/python/testData/quickdoc/PropNewDeleter.html index 052fbc4b41ee..b15116fe941a 100644 --- a/python/testData/quickdoc/PropNewDeleter.html +++ b/python/testData/quickdoc/PropNewDeleter.html @@ -1 +1 @@ -
Property x of PropNewDeleter.A
@x.deleter
def x(self: A, v: Any) -> None
Deletes X

Accessor kind:

Deleter
\ No newline at end of file +
Property x of PropNewDeleter.A
@x.deleter
def x(self, v: Any) -> None
Deletes X

Accessor kind:

Deleter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropNewDocstringOfGetter.html b/python/testData/quickdoc/PropNewDocstringOfGetter.html index 946d73ea4390..400cec76379e 100644 --- a/python/testData/quickdoc/PropNewDocstringOfGetter.html +++ b/python/testData/quickdoc/PropNewDocstringOfGetter.html @@ -1 +1 @@ -
Property m of PropNewDocstringOfGetter.C
@m.setter
def m(self: C, x: Any) -> None
Foo

Documentation is copied from:

property getter

Accessor kind:

Setter
\ No newline at end of file +
Property m of PropNewDocstringOfGetter.C
@m.setter
def m(self, x: Any) -> None
Foo

Documentation is copied from:

property getter

Accessor kind:

Setter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropNewGetter.html b/python/testData/quickdoc/PropNewGetter.html index 5aca287b2693..a07043ff0ed7 100644 --- a/python/testData/quickdoc/PropNewGetter.html +++ b/python/testData/quickdoc/PropNewGetter.html @@ -1 +1 @@ -
Property x of PropNewGetter.A
@property
def x(self: A) -> int
Does things to X

Accessor kind:

Getter
\ No newline at end of file +
Property x of PropNewGetter.A
@property
def x(self) -> int
Does things to X

Accessor kind:

Getter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropNewSetter.html b/python/testData/quickdoc/PropNewSetter.html index 9152d4d33799..f9584e2397cb 100644 --- a/python/testData/quickdoc/PropNewSetter.html +++ b/python/testData/quickdoc/PropNewSetter.html @@ -1 +1 @@ -
Property x of PropNewSetter.A
@x.setter
def x(self: A, v: Any) -> None
Sets X

Accessor kind:

Setter
\ No newline at end of file +
Property x of PropNewSetter.A
@x.setter
def x(self, v: Any) -> None
Sets X

Accessor kind:

Setter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropNewUndefinedSetter.html b/python/testData/quickdoc/PropNewUndefinedSetter.html index ed202ea92ba8..d398360178aa 100644 --- a/python/testData/quickdoc/PropNewUndefinedSetter.html +++ b/python/testData/quickdoc/PropNewUndefinedSetter.html @@ -1 +1 @@ -
Property attr of PropNewUndefinedSetter.C
@property
def attr(self: C) -> int
Docstring.

Documentation is copied from:

property getter

Accessor kind:

Setter (not defined)
\ No newline at end of file +
Property attr of PropNewUndefinedSetter.C
@property
def attr(self) -> int
Docstring.

Documentation is copied from:

property getter

Accessor kind:

Setter (not defined)
\ No newline at end of file diff --git a/python/testData/quickdoc/PropOldDeleter.html b/python/testData/quickdoc/PropOldDeleter.html index 3c5bf2994f0e..1ca492f2e419 100644 --- a/python/testData/quickdoc/PropOldDeleter.html +++ b/python/testData/quickdoc/PropOldDeleter.html @@ -1 +1 @@ -
Property x of PropOldDeleter.A
def __getX(self: A) -> Any
Doc of getter

Accessor kind:

Deleter
\ No newline at end of file +
Property x of PropOldDeleter.A
def __getX(self) -> Any
Doc of getter

Accessor kind:

Deleter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropOldDocParamOfPropertyCall.html b/python/testData/quickdoc/PropOldDocParamOfPropertyCall.html index b0c3e3532497..4d5f56cb8255 100644 --- a/python/testData/quickdoc/PropOldDocParamOfPropertyCall.html +++ b/python/testData/quickdoc/PropOldDocParamOfPropertyCall.html @@ -1 +1 @@ -
Property attr of PropOldDocParamOfPropertyCall.C
def _set(self: C, x: Any) -> None
Docstring

Accessor kind:

Setter
\ No newline at end of file +
Property attr of PropOldDocParamOfPropertyCall.C
def _set(self, x: Any) -> None
Docstring

Accessor kind:

Setter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropOldDocstringOfGetter.html b/python/testData/quickdoc/PropOldDocstringOfGetter.html index 2386a7a5588b..4c9842fe0da6 100644 --- a/python/testData/quickdoc/PropOldDocstringOfGetter.html +++ b/python/testData/quickdoc/PropOldDocstringOfGetter.html @@ -1 +1 @@ -
Property attr of PropOldDocstringOfGetter.C
def _set(self: C, x: Any) -> None
Getter.

Documentation is copied from:

property getter

Accessor kind:

Setter
\ No newline at end of file +
Property attr of PropOldDocstringOfGetter.C
def _set(self, x: Any) -> None
Getter.

Documentation is copied from:

property getter

Accessor kind:

Setter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropOldGetter.html b/python/testData/quickdoc/PropOldGetter.html index 9be60c80556e..dc72b146beb5 100644 --- a/python/testData/quickdoc/PropOldGetter.html +++ b/python/testData/quickdoc/PropOldGetter.html @@ -1 +1 @@ -
Property x of PropOldGetter.A
def __getX(self: A) -> Any
Doc of getter

Accessor kind:

Getter
\ No newline at end of file +
Property x of PropOldGetter.A
def __getX(self) -> Any
Doc of getter

Accessor kind:

Getter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropOldSetter.html b/python/testData/quickdoc/PropOldSetter.html index 4aa061451ed2..f4263f93a853 100644 --- a/python/testData/quickdoc/PropOldSetter.html +++ b/python/testData/quickdoc/PropOldSetter.html @@ -1 +1 @@ -
Property x of PropOldSetter.A
def __getX(self: A, x: Any) -> None
Doc of getter

Accessor kind:

Setter
\ No newline at end of file +
Property x of PropOldSetter.A
def __getX(self, x: Any) -> None
Doc of getter

Accessor kind:

Setter
\ No newline at end of file diff --git a/python/testData/quickdoc/PropOldUndefinedSetter.html b/python/testData/quickdoc/PropOldUndefinedSetter.html index 864288fac7f1..f6e4e7d2b741 100644 --- a/python/testData/quickdoc/PropOldUndefinedSetter.html +++ b/python/testData/quickdoc/PropOldUndefinedSetter.html @@ -1 +1 @@ -
Property attr of PropOldUndefinedSetter.C
def _get(self: C) -> int
Docstring.

Documentation is copied from:

property getter

Accessor kind:

Setter (not defined)
\ No newline at end of file +
Property attr of PropOldUndefinedSetter.C
def _get(self) -> int
Docstring.

Documentation is copied from:

property getter

Accessor kind:

Setter (not defined)
\ No newline at end of file diff --git a/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html b/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html index 559e524a6a3d..5c491b002972 100644 --- a/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html +++ b/python/testData/quickdoc/ReferenceToMethodQualifiedWithInstance.html @@ -1 +1 @@ -
list
def count(self: list, object: _T) -> int
L.count(value) -> integer -- return number of occurrences of value

Assigned to:

c1
\ No newline at end of file +
list
def count(self, object: _T) -> int
L.count(value) -> integer -- return number of occurrences of value

Assigned to:

c1
\ No newline at end of file diff --git a/python/testData/quickdoc/SingleArgumentMethodNotWrapped.html b/python/testData/quickdoc/SingleArgumentMethodNotWrapped.html index e6596fa5a0fc..fa6b99f58e43 100644 --- a/python/testData/quickdoc/SingleArgumentMethodNotWrapped.html +++ b/python/testData/quickdoc/SingleArgumentMethodNotWrapped.html @@ -1 +1 @@ -
SingleArgumentMethodNotWrapped.MyClass
def method(self: MyClass, param: Any) -> None
\ No newline at end of file +
SingleArgumentMethodNotWrapped.MyClass
def method(self, param: Any) -> None
\ No newline at end of file