Sphinx:如何从super方法中包含doc字符串?

时间:2015-02-16 19:42:37

标签: python python-sphinx

我似乎无法找到任何方法让sphinx包含来自超级方法的doc字符串。例如:

class Base(object):
    def a_method(self, param_a, param_b, **kwargs):
        """ This is an adapter method which must be implemented by each Sub class.

        :param param_a: Param A Available to all adapters.
        :type param_a: str
        :param param_b: Param B Available to all adapters.
        :type param_b: str
        """
        raise NotImplementedError('This method must be implemented in each Sub')


class Sub (Base):
    def a_method(self, param_a, param_b, param_c, **kwargs):
        """ Adapted for interface with this unique API.

        :param param_c: An option unique to this API.
        :type param_c: str
        """
        ... obtain data from API here ...
        return result
    # UPDATE TO ORIGINAL: this will combine the docs
    method_a.__doc__ += Base.method_a.__doc__
    # Now i need to combine params so that Sub supersedes Super and
    # incorporate this into sphinx.

我希望Sub的文档包括Base的param_a,Base的param_b和Sub.a_method的文档中的Sub的param_c。有什么办法让输出看起来像这样吗?

class Sub ()
---- a_method (param_a,param_b,param_c,** kwargs)
-------- Super A方法docs -------- Sub A方法docs --------的参数
----------- Param_a (str) - Param A.
----------- Param_b (str) - Param B.
----------- Param_c (str) - Param C.

0 个答案:

没有答案