From: Vladimír Vondruš Date: Wed, 28 Aug 2019 22:32:01 +0000 (+0200) Subject: documentation/python: properly shrink first column also with skipped self. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=6a3e898dca28e8da8dd8c9926d1aaa46bfaf3ca3;p=blog.git documentation/python: properly shrink first column also with skipped self. This will break if the docs skip undocumented parameters, but since that's technically an error, I don't care. --- diff --git a/documentation/templates/python/details-function.html b/documentation/templates/python/details-function.html index f48e1818..1bce6420 100644 --- a/documentation/templates/python/details-function.html +++ b/documentation/templates/python/details-function.html @@ -16,7 +16,7 @@ {% for param in function.params %} {% if loop.index != 1 or param.name != 'self' or param.content %} - {{ param.name }} + {{ param.name }} {{ param.content }} {% endif %} diff --git a/documentation/test_python/content/content.Class.html b/documentation/test_python/content/content.Class.html index 5f4320f6..81d2eff4 100644 --- a/documentation/test_python/content/content.Class.html +++ b/documentation/test_python/content/content.Class.html @@ -140,7 +140,7 @@ add any detailed block. - a + a The first parameter diff --git a/documentation/test_python/inspect_attrs/docs.rst b/documentation/test_python/inspect_attrs/docs.rst new file mode 100644 index 00000000..153f558e --- /dev/null +++ b/documentation/test_python/inspect_attrs/docs.rst @@ -0,0 +1,18 @@ +.. py:property:: inspect_attrs.MyClass.unannotated + :summary: External docs for this property + +.. py:property:: inspect_attrs.MyClassAutoAttribs.complex_annotation + :summary: This is complex. + +.. py:data:: inspect_attrs.MySlotClass.annotated + :summary: This is a float slot. + +.. py:function:: inspect_attrs.MyClass.__init__ + :summary: External docs for the init + :param annotated: The first argument + :param unannotated: This gets the default of four + :param complex_annotation: Yes, a list + :param hidden_property: Interesting, but I don't care. + + The :p:`hidden_property` isn't shown in the output as it's prefixed with + an underscore. diff --git a/documentation/test_python/inspect_attrs/inspect_attrs.py b/documentation/test_python/inspect_attrs/inspect_attrs.py new file mode 100644 index 00000000..cf3ef99a --- /dev/null +++ b/documentation/test_python/inspect_attrs/inspect_attrs.py @@ -0,0 +1,29 @@ +from typing import List, Tuple + +import attr + +@attr.s +class MyClass: + """A class with attr-defined properties""" + + annotated: float = attr.ib() + unannotated = attr.ib(4) + complex_annotation: List[Tuple[int, float]] = attr.ib(default=[]) + + # Shouldn't be shown + _hidden_property: float = attr.ib(3) + +@attr.s(auto_attribs=True) +class MyClassAutoAttribs: + """A class with automatic attr-defined properties""" + + annotated: float + unannotated = 4 + complex_annotation: List[Tuple[int, float]] = [] + +@attr.s(auto_attribs=True, slots=True) +class MySlotClass: + """A class with attr-defined slots""" + + annotated: float + complex_annotation: List[Tuple[int, float]] = []