Hi all,
I have wrote a small "Module" that I call in my ArcGIS Python window to do simple tasks for me when I am doing edits. When I call my Function basically only the function and the arguments show up. In the module I have a docstring listed below in hopes that it would pick that up as well incase i want to share this with co-workers. Anyone know the solution to this?
Below is an example of one of the functions:
def calc_feet(table):
""" Creates a Field named "Feet" and calculates the Field """
py = "PYTHON_9.3"
var = "Feet"
type = "DOUBLE"
sql = "float(!shape.length@feet!)"
arcpy.AddField_management(table, var, type)
arcpy.CalculateField_management(table, var, sql, py, "#")
import gis # my module
gis.calc_feet("my table")
#help window only shows:
gis.calc_feet(table) with no docstring
Solved! Go to Solution.
First script
"""
calling_script.py
Callings doc
"""
import sys
script = sys.argv[0]
import import_this # import the module
reload(import_this) # needed for testing otherwise the import is ignored
print("main script: {}\nHelp from import:\n{}".format(script, help(import_this)))
print("-----------------------")
print("this script doc:\n{}".format( __doc__ ))Imports this
""" import_this.py import_this ... main docstring """ import sys def do_squat(): """Doc string indented with 4 spaces """ print 'hello' if __name__ == '__main__': do_squat()
results in this
>>> >>> Help on module import_this: NAME import_this - import_this.py FILE d:\temp\import_this.py DESCRIPTION import_this ... main docstring FUNCTIONS do_squat() Doc string indented with 4 spaces main script: D:\Temp\calling_script.py Help from import: None ----------------------- this script doc: calling_script.py Callings doc
First script
"""
calling_script.py
Callings doc
"""
import sys
script = sys.argv[0]
import import_this # import the module
reload(import_this) # needed for testing otherwise the import is ignored
print("main script: {}\nHelp from import:\n{}".format(script, help(import_this)))
print("-----------------------")
print("this script doc:\n{}".format( __doc__ ))Imports this
""" import_this.py import_this ... main docstring """ import sys def do_squat(): """Doc string indented with 4 spaces """ print 'hello' if __name__ == '__main__': do_squat()
results in this
>>> >>> Help on module import_this: NAME import_this - import_this.py FILE d:\temp\import_this.py DESCRIPTION import_this ... main docstring FUNCTIONS do_squat() Doc string indented with 4 spaces main script: D:\Temp\calling_script.py Help from import: None ----------------------- this script doc: calling_script.py Callings doc
Exactly the information I was looking for thanks Dan.
Here's the real thing:
Matthew
More documentation and a fuller example are included in my blog post
Documenting Scripts .... part 2
which is a follow-up to an earlier one. I have included Curtis's reference in the documentation as well.