Message176524
This issue is to settle on and provide a way to document the constructor of a class separately from the overall summary/description of a class.
This is something that Ezio, Nick, and I discussed briefly on IRC a few hours ago. We all see the value in it.
Currently, Sphinx's "class" directive is used in many places to document the constructor of a class. One drawback of this approach is that linking to the class using the :class: role links to the constructor as opposed to the class summary. As a result, in many cases the class description needs to be added before the class directive, and a second link needs to be created and used for the overall description.
One way to address this would be to create a new "constructor" directive similar to directives like method, classmethod, and staticmethod. The constructor documentation could then be hyperlinked to using a new :constructor: role (or perhaps :ctor: to go with the pattern of 4-letter roles). The class summary could then go immediately after the class directive, with the constructor directive following, as follows:
.. class:: Foo
Description of Foo.
.. constructor:: Foo(bar=1)
Return a Foo.
This could render as--
class **Foo**
Description of Foo.
*constructor* **Foo**(bar=1)
Return a Foo.
It is possible that something similar could be achieved by abusing the method directive for constructors and linking to them using :meth:`~Foo.Foo`, but that wouldn't be ideal in a few respects.
Nick also raised a related issue for base classes, etc. I will let him speak to that issue, which might be best as part of another new issue. |
|
Date |
User |
Action |
Args |
2012-11-28 09:03:32 | chris.jerdonek | set | recipients:
+ chris.jerdonek, ncoghlan, ezio.melotti, docs@python |
2012-11-28 09:03:32 | chris.jerdonek | set | messageid: <1354093412.82.0.692042663136.issue16568@psf.upfronthosting.co.za> |
2012-11-28 09:03:32 | chris.jerdonek | link | issue16568 messages |
2012-11-28 09:03:31 | chris.jerdonek | create | |
|