commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11173 - gnuradio/trunk/grc/src/platforms/python/utils


From: jblum
Subject: [Commit-gnuradio] r11173 - gnuradio/trunk/grc/src/platforms/python/utils
Date: Wed, 3 Jun 2009 21:22:22 -0600 (MDT)

Author: jblum
Date: 2009-06-03 21:22:21 -0600 (Wed, 03 Jun 2009)
New Revision: 11173

Modified:
   gnuradio/trunk/grc/src/platforms/python/utils/extract_docs.py
Log:
improved gr doc extraction from doxygen xml

Modified: gnuradio/trunk/grc/src/platforms/python/utils/extract_docs.py
===================================================================
--- gnuradio/trunk/grc/src/platforms/python/utils/extract_docs.py       
2009-06-03 16:41:22 UTC (rev 11172)
+++ gnuradio/trunk/grc/src/platforms/python/utils/extract_docs.py       
2009-06-04 03:22:21 UTC (rev 11173)
@@ -26,17 +26,19 @@
 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 @@
                        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)
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]