mcneel / ghpython

A Grasshopper component for Rhino.Python
http://www.food4rhino.com/project/ghpython
117 stars 34 forks source link

descriptive comments #31

Closed piac closed 12 years ago

piac commented 12 years ago

User request: being able to add more descriptive comments

http://python.rhino3d.com/threads/849-GH-Python-component

sbaer commented 12 years ago

I think a good way to implement this would be through DocStrings http://www.python.org/dev/peps/pep-0257/ http://docs.python.org/release/1.4/tut/node100.html

bengolder commented 12 years ago

Converting doc strings into descriptive comments or help text would be great, and would be an easy feature to understand. It would also encourage a good coding style. I think Steve's suggestion is great.

piac commented 12 years ago

The upcoming version of GhPython will support this syntax:

"""
Compute the sum of an Arithmetic Progression, or the
sum of all numbers from x to y.
    Args:
        F: The first number included in the series.
        L: The last number included in the series.
    Returns:
        S: The sum of numbers between F and L.
"""
if F is None: F = 0
if L is None: L = 1

S = (F + L) * (L - F + 1) // 2

This is based on the syntax for DocStrings found here: http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments