diff options
author | jblum | 2009-06-04 03:22:21 +0000 |
---|---|---|
committer | jblum | 2009-06-04 03:22:21 +0000 |
commit | 7a55873a0215f5cbb85f0d745318255014617dd1 (patch) | |
tree | 7c24c19b205d185de9e2e2ff53d19f159b92d292 /grc/src/platforms | |
parent | a9d3e26b408dcfe53ac07c9a1e9c4efd692dede8 (diff) | |
download | gnuradio-7a55873a0215f5cbb85f0d745318255014617dd1.tar.gz gnuradio-7a55873a0215f5cbb85f0d745318255014617dd1.tar.bz2 gnuradio-7a55873a0215f5cbb85f0d745318255014617dd1.zip |
improved gr doc extraction from doxygen xml
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11173 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'grc/src/platforms')
-rw-r--r-- | grc/src/platforms/python/utils/extract_docs.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/grc/src/platforms/python/utils/extract_docs.py b/grc/src/platforms/python/utils/extract_docs.py index b3695a953..523519f97 100644 --- a/grc/src/platforms/python/utils/extract_docs.py +++ b/grc/src/platforms/python/utils/extract_docs.py @@ -26,17 +26,19 @@ DOXYGEN_NAME_XPATH = '/doxygen/compounddef/compoundname' DOXYGEN_BRIEFDESC_GR_XPATH = '/doxygen/compounddef/briefdescription' DOXYGEN_DETAILDESC_GR_XPATH = '/doxygen/compounddef/detaileddescription' -def extract_txt(xml, parent_text=None): +def extract_txt(xml): """ Recursivly pull the text out of an xml tree. @param xml the xml tree - @param parent_text the text of the parent element @return a string """ - text = xml.text or '' - tail = parent_text and xml.tail or '' + text = (xml.text or '').replace('\n', '') + tail = (xml.tail or '').replace('\n', '') + if xml.tag == 'para': tail += '\n\n' + if xml.tag == 'linebreak': text += '\n' + if xml.tag == 'parametername': text += ': ' return text + ''.join( - map(lambda x: extract_txt(x, text), xml) + map(lambda x: extract_txt(x), xml) ) + tail def _extract(key): @@ -61,16 +63,16 @@ def _extract(key): xml_file = os.path.join(docs_dir, match) xml = etree.parse(xml_file) #extract descriptions - comp_name = extract_txt(xml.xpath(DOXYGEN_NAME_XPATH)[0]).strip('\n') + comp_name = extract_txt(xml.xpath(DOXYGEN_NAME_XPATH)[0]).strip() comp_name = ' --- ' + comp_name + ' --- ' if re.match('(gr|usrp2|trellis)_.*', key): - brief_desc = extract_txt(xml.xpath(DOXYGEN_BRIEFDESC_GR_XPATH)[0]).strip('\n') - detailed_desc = extract_txt(xml.xpath(DOXYGEN_DETAILDESC_GR_XPATH)[0]).strip('\n') + brief_desc = extract_txt(xml.xpath(DOXYGEN_BRIEFDESC_GR_XPATH)[0]).strip() + detailed_desc = extract_txt(xml.xpath(DOXYGEN_DETAILDESC_GR_XPATH)[0]).strip() else: brief_desc = '' detailed_desc = '' #combine - doc_strs.append('\n'.join([comp_name, brief_desc, detailed_desc]).strip('\n')) + doc_strs.append('\n\n'.join([comp_name, brief_desc, detailed_desc]).strip()) except IndexError: pass #bad format return '\n\n'.join(doc_strs) |