3 from docs.doc_template
import ClassDoc, Doc, Docs, FreeDoc
5 import xml.etree.ElementTree
as ET
7 DOXYGEN_CONF =
'doxygen.conf' 10 def parse(input_path, output_path, quiet=False, generate_xml_flag=True):
11 '''Parse the files for documentation and store it in templates. 14 input_path -- path to the input folder or file 15 output_path -- path to the output folder 16 quiet -- turn on/off the messages that are generated to standard output by 17 Doxygen (default = False) 18 generate_xml -- use Doxygen to generate xml (default = True) 21 A Docs template storing all the documentation in the input. 29 for root, dirs, files
in os.walk(output_path):
31 if f.endswith(
'.xml'):
32 file_path = path.join(root, f)
36 class_docs[file_path] = doc
38 return Docs(class_docs, free_docs)
42 '''Parse the file for documentation and output it as in an xml format''' 44 print(
'--------------Generating XML--------------')
46 input_path = path.relpath(input_path, os.getcwd())
47 conf_path = path.relpath(path.join(path.dirname(__file__), DOXYGEN_CONF))
48 output_path = path.relpath(output_path)
50 if not path.isdir(output_path):
53 command =
'( cat {conf_path} ; echo "INPUT={input_path}" ; echo "OUTPUT_DIRECTORY={output_path}" ; echo "EXTRACT_ALL={quiet}" ) | doxygen -'.format(
55 input_path=input_path,
56 output_path=output_path,
57 quiet=
'YES' if quiet
else 'NO' 64 '''Determine the type of the object the xml tree represents. 67 tree -- an xml tree or path to xml string 74 if first_compound_def
is None:
75 return first_compound_def
77 return first_compound_def.get(
'kind')
81 '''Initialize documentation given its type. 83 Categorize the xml tree at file_path and initiliaze the corresponding doc 84 type with the xml tree and other relevant information. 87 file_path -- path to the xml tree 92 tree = ET.parse(file_path)
96 if category ==
'class':
101 if tree.getroot().tag == tag:
102 return tree.getroot()
104 return tree.find(
'.//{}'.format(tag))
108 return tree.find(
'.//{}'.format(tag))
112 element = method.find(name)
117 out =
'' if element.text
is None else element.text
119 for e
in list(element):
void print(const Matrix &A, const string &s, ostream &stream)
def generate_xml(input_path, output_path, quiet=False)
def find_first_element_with_tag(tree, tag)
bool isinstance(handle obj)
def find_method_element_text(method, name)
def find_all_elements(tree, name, tag)
def parse(input_path, output_path, quiet=False, generate_xml_flag=True)