Suggestion for better comments on / documentation of Core functions (with list of FreePBX core functions)

It occurs to me that one thing that might make things a whole lot easier for developers and module authors would be if someone would take the time to document each core function. I did a quick check of /var/www/html/admin/modules/core/functions.inc.php and found references to the following core functions:

core_ampusers_add($username, $password, $extension_low, $extension_high, $deptname, $sections)
core_ampusers_del($username)
core_ampusers_list()
core_check_destinations($dest=true)
core_check_extensions($exten=true)
core_destinations()
core_devices2astdb()
core_devices_add($id,$tech,$dial,$devicetype,$user,$description,$emergency_cid=null,$editmode=false)
core_devices_addiax2($account)
core_devices_addsip($account)
core_devices_addzap($account)
core_devices_configpageinit($dispnum)
core_devices_configpageload()
core_devices_configprocess()
core_devices_del($account,$editmode=false)
core_devices_deliax2($account)
core_devices_delsip($account)
core_devices_delzap($account)
core_devices_get($account)
core_devices_getiax2($account)
core_devices_getsip($account)
core_devices_getzap($account)
core_devices_list($tech="all",$detail=false,$get_all=false)
core_did_add($incoming,$target=false)
core_did_del($extension,$cidnum)
core_did_edit($old_extension,$old_cidnum, $incoming)
core_did_get($extension="",$cidnum="")
core_did_list($order='extension')
core_directdid_list()
core_getdest($exten)
core_getdestinfo($dest)
core_get_config($engine)
core_hint_get($account)
core_routing_add($name, $patterns, $trunks, $method, $pass, $emergency = "", $intracompany = "", $mohsilence = "")
core_routing_del($name)
core_routing_edit($name, $patterns, $trunks, $pass, $emergency="", $intracompany = "", $mohsilence="")
core_routing_getrouteemergency($route)
core_routing_getrouteintracompany($route)
core_routing_getroutemohsilence($route)
core_routing_getroutenames()
core_routing_getroutepassword($route)
core_routing_getroutepatterns($route)
core_routing_getroutetrunks($route)
core_routing_rename($oldname, $newname)
core_routing_setroutepriority($routepriority, $reporoutedirection, $reporoutekey)
core_routing_setroutepriorityvalue($key)
core_sipname_check($sipname, $extension)
core_trunks_add($tech, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetailseteDialRules($trunknum)
core_trunks_edit($trunknum, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, $failtrunk, $disabletrunk)
core_trunks_getDialRules($trunknum)
core_trunks_getTrunkPeerDetails($trunknum)
core_trunks_getTrunkRegister($trunknum)
core_trunks_gettrunkroutes($trunknum)
core_trunks_getTrunkTech($trunknum)
core_trunks_getTrunkTrunkName($trunknum)
core_trunks_getTrunkUserConfig($trunknum)
core_trunks_getTrunkUserContext($trunknum)
core_trunks_list($assoc = false)
core_trunks_parse_conf($filename, &$conf, &$section)
core_trunks_readDialRulesFile()
core_trunks_writeDialRulesFile($conf)
core_users2astdb()
core_users_add($vars, $editmode=false)
core_users_cleanastdb($extension)
core_users_configpageinit($dispnum)
core_users_configpageload()
core_users_configprocess()
core_users_del($extension, $editmode=false)
core_users_directdid_get($directdid="")
core_users_edit($extension,$vars)
core_users_get($extension)
core_users_list()
core_zapchandids_add($description, $channel, $did)
core_zapchandids_delete($channel)
core_zapchandids_edit($description, $channel, $did)
core_zapchandids_get($channel)
core_zapchandids_list()

It would be great if all these functions were documented somewhere (what each is used for, what it expects in the calling variables and what is returned). Some of them have meaningful comments in the source, some have comments that were probably meaningful to whoever put them in but taken out of context don’t tell us much, and some have little or nothing in the way of comments.

My first plea for developers is that when you add or edit one of these routines, please remember how just about every programming book you’ve ever read has emphasized the need for meaningful comments in source code. Just because you understand what a particular function does, doesn’t mean that anyone else will.

My second thought is that it would probably be a huge help for aspiring module writers if all of these functions were fully documented, either with each having its own wiki page or perhaps one common wiki page that describes each function. The latter would probably be easier to navigate for the person who’s not sure which function would best serve whatever purpose they may be trying to accomplish, though it could make for a somewhat long page if each function is fully documented.

Wiseoldowl -

I fully support your initiative. In order to achieve some traction I am willing to offer to assist in the legwork.

The developers probably don’t want to wast their finite time with these types of efforts. However if we build the document framework and populate as much info as we can then we can go back at the developers to assist us in filling the gaps.

Let’s try and get some volunteers lined up, I am “in”