Is it possible to get function and method documentation programmatically?
Is it possible to have python return a list or dictionary of method arguments and their type?
For instance take cv2.threshold function. If I go to the docs webpage I can see all of the info I want, but is it possible to get this information in code? I would like to query the function cv2.threshold and have something tell me it takes the arguments [src,thresh,maxval,type[,dst]). It would be ideal if it also told me what type or class the values are:
e.g. the docs say: Python: cv2.threshold(src, thresh, maxval, type[, dst]) → retval, dst
so I want to be able to do something like:
foo.getMethods(cv2.threshold) -> {src:mat, thresh:int, maxval:int, type:built-in/[cv2. THRESH_BINARY_INV,cv2. THRESH_BINARY)]}
All of this info is in the documentation on the web page, I just want to access it to dynamically setup a codebase I am working on for a GUI.
Can I access this info without having to setup a web-scraper to pull it directly from the website?
Edit: I've uploaded a video to show exactly what I want to do.
Up to now for each function I have to manually enter its parameters which look like this (for cv2.threshold or Binary Threshold in the video):
def guiParams(self):
thresh = {'type':'int',
'name':'threshold value',
'min':0,
'max' : 255,
'default': 127}
maxval = {'type':'int',
'name':'max threshold value',
'min':0,
'max' : 255,
'default': 255}
threshtype ={'type':'builtin',
'name':'thresholding type',
'options':{'THRESH_BINARY':cv2.THRESH_BINARY,
'THRESH_BINARY_INV':cv2.THRESH_BINARY_INV,
'THRESH_TRUNC':cv2.THRESH_TRUNC,
'THRESH_TOZERO':cv2.THRESH_TOZERO,
'THRESH_TOZERO_INV':cv2.THRESH_TOZERO_INV},
'default':'THRESH_BINARY'
}
return [thresh,maxval,threshtype]
This question is trying to figure out how I can get the information in these dictionaries (primarily the attribute name and type, default/typical values would be a bonus) grammatically so I can ensure the gui will work with every image processing method in the opencv Library