记录函数参数和类属性类型的标准方法是什么,以区分预期为类实例的那些和预期为类对象本身的那些?
class TestClass(object):
def __init__(self):
pass
class Objectify(object):
def __init__(self):
pass
class NeatDocumentation(object):
"""A class demonstrating neat documentation style.
Attributes:
cls (TestClass?): A class you want to test.
obj (Objectify?): An instance of `Objectify` class.
string (str): A string because why not.
"""
def __init__(self, cls_, obj, string):
self.cls = cls_ # An instance can be created by executing self.cls()
self.obj = obj
self.string = string
答案 0 :(得分:0)
python标准是使用restructuredtext(http://www.sphinx-doc.org/en/1.4.9/rest.html)
的sphinx样式更确切地说,autodoc模块样式:http://www.sphinx-doc.org/en/1.4.8/ext/autodoc.html
如果你想拥有更漂亮的琴弦,你也可以使用狮身人面像 - 拿破仑风格: http://www.sphinx-doc.org/en/1.4.9/ext/napoleon.html
在你的情况下,你可以这样做:
:param your_param: Class to test
:type your_param: :class:`Objectify`
或使用拿破仑:
Args:
your_param (Objectify): The :class:`Objectify` class to test