docstring

Tool for automatically check docstring style according to PEP257 [closed]

强颜欢笑 提交于 2019-12-20 17:27:19
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Tools like pep8 can check source code style, but they don't check if docstrings are fromatted according to pep257, pep287. Are there such tools? Update I decided to implement such a static analysis tool on my own, see: https://github.com/GreenSteam/pep257 Right now, most of pep257 is covered. Design was heavily

How can I make Python/Sphinx document object attributes only declared in __init__?

孤人 提交于 2019-12-19 05:58:13
问题 I have Python classes with object attributes which are only declared as part of running the constructor, like so: class Foo(object): def __init__(self, base): self.basepath = base temp = [] for run in os.listdir(self.basepath): if self.foo(run): temp.append(run) self.availableruns = tuple(sorted(temp)) If I now use either help(Foo) or attempt to document Foo in Sphinx, the self.basepath and self.availableruns attributes are not shown. That's a problem for users of our API. I've tried

What's the difference on docstrings with triple SINGLE quotes and triple DOUBLE quotes?

亡梦爱人 提交于 2019-12-18 19:05:27
问题 I was just wondering what is the difference between two ways of writing Python Docstrings ( __doc__ ): three single quotes: ''' Comment goes here ''' three double quotes: """ Comment goes here """ Is there any subtle difference in the way doc string could be formatted later while generating docs? 回答1: No. They are the same. The only difference is that the first one can contain a sequence of three unescaped double quotes, while the second can contain a sequence of three unescaped single quotes

How to express multiple types for a single parameter or a return value in docstrings that are processed by Sphinx?

萝らか妹 提交于 2019-12-18 14:01:09
问题 Sometimes a function in Python may accept an argument of a flexible type. Or it may return a value of a flexible type. Now I can't remember a good example of such a function right now, therefore I am demonstrating what such a function may look like with a toy example below. I want to know how to write docstrings for such functions using the Sphinx documentation notation. In the example below, the arguments may be either str or int . Similarly it may return either str or int . I have given an

Triple-double quote v.s. Double quote

我的梦境 提交于 2019-12-18 12:08:43
问题 What is the preferred way to write Python doc string? """ or " In the book Dive Into Python, the author provides the following example: def buildConnectionString(params): """Build a connection string from a dictionary of parameters. Returns string.""" In another chapter, the author provides another example: def stripnulls(data): "strip whitespace and nulls" return data.replace("\00", "").strip() Both syntax work. The only difference to me is that """ allows us to write multi-line doc. Is

How to find annotations in a PHP5 object?

爱⌒轻易说出口 提交于 2019-12-17 18:08:34
问题 I would like to be able to implement custom annotations in my PHP5 objects, and I'd like to learn how the whole process works by building my own parser. To start, though, I need to know how to FIND the annotations. Is there a Reflection method that I am missing, or is there another way? For example, I'd like to be able to find the following annotation in a class: /** * @MyParam: myvalue */ 回答1: You can do this using ReflectionClass::getDocComment, example: function getClassAnnotations($class)

Why Eclipse Pydev uses @author in default template

爱⌒轻易说出口 提交于 2019-12-13 07:55:48
问题 I have been intrested for python documenting for a while but I can't figured out why @author is default sytnax in python templates. Why it isn't :author: (in restructuredtext style)? From what reason is used syntax with @ and not with : I though that restructuredtext is most common in python world. 回答1: The Epytext Markup language is what you're looking for. It is epydoc's language. It makes use of the @ prefix, with such words as param , type , return , raise , etc. 来源: https://stackoverflow

Python. Hint for variable

倾然丶 夕夏残阳落幕 提交于 2019-12-12 03:45:34
问题 I'm using PyCharm as editor. For example, I have next function: def get_instance(): # method without doc sctring in some module # returns instance of MyClass return some_var And I have second file which calls get_instance() : var = get_instance() How I can to define type of data for value? I want to use autocomplete for variable. For example in php it will be like this: /** @var MyClass $var */ $var = getInstance(); After this I will be see all methods and properties of $var . How to declare

What does “see docstring of the instance object for more information” mean

孤人 提交于 2019-12-11 09:53:23
问题 I feel like this is a dumb question, but when I'm in an IPython notebook and I do help on some numpy/scipy function, like say stat.norm.rvs, it frequently says, about *args and **kargs, "see docstring of the instance object for more information". How do I see this docstring if not with help(stat.norm.rvs)? 回答1: Don't feel dumb; sometimes it is hard to find the information you are looking for, especially when starting out. Moreover, much of the docstrings in scipy.stats are autogenerated, so

Is there a way to make Python's console display docstrings nicely?

好久不见. 提交于 2019-12-11 06:39:48
问题 Whenever I use iPython to ask for a docstring in the PyCharm console, it gives me something that looks like . Is there an easy way to make it return beautiful, word-wrapped docstrings? 来源: https://stackoverflow.com/questions/44937959/is-there-a-way-to-make-pythons-console-display-docstrings-nicely