def test_get_free_docs_keys_list(self): docs = Docs(self.CLASS_DOCS, self.FREE_DOCS) free_doc_keys = list(self.FREE_DOCS) docs_list = docs.get_free_docs_keys_list() self.assertEqual(len(self.FREE_DOCS), len(docs_list)) for key in free_doc_keys: self.assertIn(key, docs_list)
def test_get_free_docs_values_list(self): docs = Docs(self.CLASS_DOCS, self.FREE_DOCS) docs_list = docs.get_free_docs_values_list() self.assertEqual(len(self.FREE_DOCS), len(docs_list)) self.assertIn(tree_root, docs_list) self.assertIn(tree_left, docs_list) self.assertIn(tree_right, docs_list) self.assertIn(tree_leaf, docs_list) self.assertIn(tree_recursive, docs_list)
def run(self, quiet=True): """Run the Doxygen XML parser. Arguments: quiet -- turn on/off the messages that are generated to standard output by Doxygen (default = True) Returns: A Docs template storing all the class and free documentation in the file. """ class_docs = {} free_docs = {} for root, dirs, files in os.walk(self.output_path): for f in files: if f.endswith('.xml'): file_path = path.join(root, f) tree = ET.parse(file_path) if tree.getroot().tag == 'compounddef': first_compound_def = tree.getroot() else: first_compound_def = tree.find( './/{}'.format('compounddef')) if first_compound_def is None: continue category = first_compound_def.get('kind') if category == 'class': class_docs[file_path] = ClassDoc(tree) return Docs(class_docs, free_docs)
def test_get_free_docs(self): docs = Docs(self.CLASS_DOCS, self.FREE_DOCS) for doc_name in self.FREE_DOCS.keys(): self.assertIs(self.FREE_DOCS.get(doc_name), docs.get_free_docs(doc_name))
def test_docs(self): """Test Docs template constructor""" docs = Docs(self.CLASS_DOCS, self.FREE_DOCS) self.assertIs(docs.class_docs, self.CLASS_DOCS) self.assertIs(docs.free_docs, self.FREE_DOCS)