docstring

Python docstring with vim pythoncomplete is not displaying newlines for my own class functions

落爺英雄遲暮 提交于 2019-12-10 19:47:31
问题 I am getting some unexpected results when trying to use Python Omni Completion on my own class functions. The docstring for the functions are not getting formatted correctly with line breaks as shown in the picture below: When I am importing modules from the standard python library I get the result I would expect: According to the python docstring conventions a newline in the source file should be interpreted as a newline. Does anyone know what's going on here and perhaps how to solve the

How does NumPy process docstrings into sphinx documentation for Parameters?

安稳与你 提交于 2019-12-10 13:11:14
问题 I want to build our documentation using sphinx and get the same formatting on parameters as the NumPy docs ( https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt ) I have found two ways to document parameters in this rst style with sphinx, one which is :param name: description or :keyword name: description and the other (which is the NumPy style) Parameters ---------- name: type description Here is an example of what that looks like: http://docs.scipy.org/doc/numpy/reference

How to avoid redundancy between c++ and boost::python docs?

扶醉桌前 提交于 2019-12-10 09:33:13
问题 I'm adding a python module in a c++ code, using boost::python. The c++ project is documented with doxygen. I want to create a documentation for the python module but I don't know how not to be redundant like this : #include <boost/python.hpp> using namespace boost::python; /** @brief Sum two integers * @param a an integer * @param b another integer * @return sum of integers */ int sum(int a, int b) { return a+b; } BOOST_PYTHON_MODULE(pymodule) { def("sum",&sum,args("a","b"), "Sum two integers

Formatting python docstrings for dicts

自闭症网瘾萝莉.ら 提交于 2019-12-10 01:25:28
问题 What's the recommended way of adding a docstring for a dictionary parameter? I can see multiple line docstring examples here. I need to document the input arguments to a function in the docstring. If it's a simple variable, I can use something like: def func2(a=x, b = y): """ fun2 takes two integers Keyword arguments: a -- refers to age (default 18) b -- refers to experience (default 0) """ If we have dict passed as input argument to function: def func3(**kwargs): """ takes dictionary as

How to specify different return types in python docstring

浪子不回头ぞ 提交于 2019-12-09 17:05:17
问题 I'm currently writing documentation for my python package using Sphinx and the autodoc plugin. For a function return value I can e.g. write :returns: int: count which tells sphinx that there is a return value of type int, named count. I now got a function which gets me predecessors of items in my database: def get_previous_release(release_id): """ Holt Vorgängeritem eines Items mit der ID release_id :param release_id: ID des items für das Release :type release_id: int """ if not isinstance

Inherit a parent class docstring as __doc__ attribute

这一生的挚爱 提交于 2019-12-08 16:33:31
问题 There is a question about Inherit docstrings in Python class inheritance, but the answers there deal with method docstrings. My question is how to inherit a docstring of a parent class as the __doc__ attribute. The usecase is that Django rest framework generates nice documentation in the html version of your API based on your view classes' docstrings. But when inheriting a base class (with a docstring) in a class without a docstring, the API doesn't show the docstring. It might very well be

PEP 257 docstring trim in standard library?

浪尽此生 提交于 2019-12-08 14:34:21
问题 PEP 257 says: Docstring processing tools will strip a uniform amount of indentation from the second and further lines of the docstring, equal to the minimum indentation of all non-blank lines after the first line. Any indentation in the first line of the docstring (i.e., up to the first newline) is insignificant and removed. Relative indentation of later lines in the docstring is retained. Blank lines should be removed from the beginning and end of the docstring. A function trim implementing

Utilizing docstrings

守給你的承諾、 提交于 2019-12-07 03:16:52
问题 It's a newbie question, but I didn't manage to google anything reasonably concise yet enlightening on the subject. I've got Sublime Text editor and an excellent plugin DocBlockr https://github.com/spadgos/sublime-jsdocs , which makes proper commenting a piece of cake. What am I supposed to do after I'm through with the comments? At a very minimum, I'd like to be able to invoke annotations in REPL. What else documentation wise is available? I want something lightweight and easy, for medium

Python set docstring and get method name of dynamically generated classmethod

安稳与你 提交于 2019-12-06 20:35:28
I'm trying to get/set the name and docstring of dynamically created class methods as follows, but am having trouble figuring out exactly how to do it: import sys import inspect class test(object): pass @classmethod def genericFunc(cls, **kwargs): print "function:", (inspect.stack()[0][3]) print "kwargs:", kwargs function_list = ['myF1', 'myF2'] for func in function_list: setattr(test, func, genericFunc) #set docstring for func here? if __name__ == '__main__': x = test() print "docstring:", x.myF1.__doc__ x.myF1(arg1="foo") y = test() print "docstring:", y.myF2.__doc__ y.myF2(arg1="foo", arg2=

python rtype docstring/restructured text for class factories/selectors

末鹿安然 提交于 2019-12-06 19:50:29
问题 :rtype: specifies that this is type of returned object Therefore, when I create object obj in following snippet I receive warning from IDE, that cls is not callable , since IDE expects, that cls is object of type SomeAbstractClass , and I want SomeAbstractClass itself IDE is right, since this is default behaviour. But how can I specify, that I am returning class, not instance of class? Specifying type instead of SomeAbstractClass helps a bit, but not a solution, since no further introspection