post_process_documentation Namespace Reference


Functions

def collapse_event_pair
def collapse_manager_events
def main
def merge_parameter_information


Function Documentation

def post_process_documentation::collapse_event_pair (   managerEventOne,
  managerEventTwo 
)

Definition at line 51 of file post_process_documentation.py.

00051                                                          :
00052     # Move all children of managerEventTwo to managerEventOne
00053     for node in managerEventTwo.childNodes:
00054         managerEventOne.appendChild(node.cloneNode(True))
00055 
00056     return managerEventOne
00057 
00058 
def collapse_manager_events(rootNode, managerEvents):

def post_process_documentation::collapse_manager_events (   rootNode,
  managerEvents 
)

Definition at line 59 of file post_process_documentation.py.

00059                                                     :
00060     events = {}
00061     for managerEvent in managerEvents:
00062         if (managerEvent.parentNode.nodeName == 'list-elements'
00063             or managerEvent.parentNode.nodeName == 'responses'):
00064             continue
00065         managerEvent.parentNode.removeChild(managerEvent)
00066         attr = managerEvent.getAttribute('name')
00067         if attr in events:
00068             # match, collapse the two managerEvents
00069             events[attr] = collapse_event_pair(events[attr], managerEvent)
00070         else:
00071             events[attr] = managerEvent
00072 
00073     # Combine parameter information and re-add the manager Events
00074     for k, event in events.items():
00075         merge_parameter_information(event)
00076         rootNode.appendChild(event)
00077     return
00078 
00079 
def main(argv=None):

def post_process_documentation::main (   argv = None  ) 

Definition at line 80 of file post_process_documentation.py.

00080                    :
00081 
00082     if argv is None:
00083         argv = sys.argv
00084 
00085     parser = optparse.OptionParser()
00086     parser.add_option('-i', '--input', dest='input_file',
00087                       default='doc/core-full-en_US.xml',
00088                       help='The XML file to process')
00089     parser.add_option('-o', '--output', dest='output_file',
00090                       default='doc/core-en_US.xml',
00091                       help='The XML file to create')
00092     (options, args) = parser.parse_args(argv)
00093 
00094     dom = parse(options.input_file)
00095 
00096     datasource = open(options.output_file, 'w')
00097     docs = dom.getElementsByTagName("docs")[0]
00098     managerEvents = dom.getElementsByTagName("managerEvent")
00099     if (managerEvents):
00100         collapse_manager_events(docs, managerEvents)
00101 
00102     dom.writexml(datasource)
00103     datasource.close()
00104 
00105     return 0
00106 
if __name__ == "__main__":

def post_process_documentation::merge_parameter_information (   managerEvent  ) 

Merge the parameter information across all managerEventInstances
within a managerEvent node 

Definition at line 19 of file post_process_documentation.py.

00019                                              :
00020     ''' Merge the parameter information across all managerEventInstances
00021     within a managerEvent node '''
00022 
00023     def __swap_parameter_documentation(one, two):
00024         # See who has the better documentation and use it
00025         if (one.hasChildNodes() and not two.hasChildNodes()):
00026             two.parentNode.replaceChild(one.cloneNode(True), two)
00027         elif (two.hasChildNodes() and not one.hasChildNodes()):
00028             one.parentNode.replaceChild(two.cloneNode(True), one)
00029 
00030     def __merge_parameter(param, other_instances):
00031         # Compare the parameter to every other instance's set of parameters
00032         for other in other_instances:
00033             other_parameters = other.getElementsByTagName("parameter")
00034             match = [p for p in other_parameters
00035                      if p.getAttribute('name') == param.getAttribute('name')]
00036             if (match):
00037                 # See who has the better documentation and use it
00038                 __swap_parameter_documentation(param, match[0])
00039 
00040     instances = managerEvent.getElementsByTagName("managerEventInstance")
00041     merged = []
00042     for instance in instances:
00043         others = [i for i in instances if i != instance]
00044         parameters = instance.getElementsByTagName("parameter")
00045         for parameter in parameters:
00046             if parameter not in merged:
00047                 merged.append(parameter)
00048                 __merge_parameter(parameter, others)
00049 
00050 
def collapse_event_pair(managerEventOne, managerEventTwo):


Generated on Thu Apr 16 06:41:38 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6