Added #define processing
authorZhanna Tsitkov <tsitkova@mit.edu>
Tue, 26 Jul 2011 17:35:19 +0000 (17:35 +0000)
committerZhanna Tsitkov <tsitkova@mit.edu>
Tue, 26 Jul 2011 17:35:19 +0000 (17:35 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25058 dc483132-0cff-0310-8789-dd5450dbe970

doc/rst_tools/define_document.tmpl [new file with mode: 0644]
doc/rst_tools/docmodel.py
doc/rst_tools/doxybuilder_funcs.py
doc/rst_tools/doxybuilder_types.py

diff --git a/doc/rst_tools/define_document.tmpl b/doc/rst_tools/define_document.tmpl
new file mode 100644 (file)
index 0000000..f3260a6
--- /dev/null
@@ -0,0 +1,43 @@
+.. highlightlang:: c
+
+.. $composite.macro_reference($composite.name):
+
+
+
+#if $composite.short_description is not None and len($composite.short_description)
+       #set $title = $composite.name + ' - ' + $composite.short_description
+#else
+       #set $title = $composite.name
+#end if
+$title
+#echo ''.join(['=']*len($title)) #
+
+
+
+:krb5doxy:`Doxygen reference to $composite.name  <$composite.name>`
+
+..
+.. data:: $composite.name
+..
+
+#echo ''.join(['=']*len($composite.name)) + '== ======================' #
+$composite.name       $composite.initializer
+#echo ''.join(['=']*len($composite.name)) + '== ======================' #
+
+
+$composite.long_description
+
+#if $composite.Id is not None 
+
+
+#end if
+
+
+Feedback
+----------
+
+#set $msg_subject = 'Documentation___' + $composite.name 
+
+Please, provide your feedback on this document at krb5-bugs@mit.edu?subject=$msg_subject
index 5ab26781d5e764875fc84c6d126294c3d06ec251..acfc1440e389e94c09a5040127a2080296b13e6b 100644 (file)
@@ -48,6 +48,7 @@ class CompositeType():
         self.definition = argkw.get('definition')
         self.name = argkw.get('name')
         self.Id = argkw.get('Id')
+        self.initializer = argkw.get('initializer')
         self.active = argkw.get('active', False)
         self.version = argkw.get('version')
         self.return_type = argkw.get('return_type')
@@ -85,6 +86,12 @@ class CompositeType():
         
         return result
 
+    def macro_reference(self, name):
+        result = re.sub(r'_', '-', name)
+        result = '_%s-data' % result
+        
+        return result
+
 class Parameter(object):
     def __init__(self, **argkw):
         self.seqno = argkw.get('seqno')
index 3f0b9c00cdeb6efae94476ecf036f9d3dd254a91..fb403f375606c9d79f24e006a93edc94ceda6ce8 100644 (file)
@@ -302,7 +302,12 @@ class DoxyFuncs(XML2AST):
             if node.attributes['kind'] == 'return':
                 return None
         elif node.name == 'ref':
-            return ':c:func:' + '`' + value + '`'
+            if value.find('()') >= 0:
+                # functions
+                return ':c:func:' + '`' + value + '`'
+            else:
+                # macro's
+                return ':data:' + '`' + value + '`'
         elif node.name == 'emphasis':
             return '*' + value + '*'
         elif node.name == 'itemizedlist':
index bf76c1d77891a68e6ae383ad9ffbd1ff00c65f56..cbdb8aa96e29d171a49ec218e311b9ee80feef72 100644 (file)
@@ -21,6 +21,7 @@
   this software for any purpose.  It is provided "as is" without express
   or implied warranty.
 '''
+
 import sys
 import os
 import re
@@ -82,6 +83,8 @@ class DoxyTypes(object):
                     data = self._process_typedef_node(node)
                 elif kind == 'variable':
                     data = self._process_variable_node(node)
+                elif kind == 'define':
+                    data = self._process_define_node(node)
                 result.append(data)
         print "\nnumber of types processed ==> " , len(result)    
         return result
@@ -111,6 +114,7 @@ class DoxyTypes(object):
                          'definition': t_definition,
                          'name': t_name,
                          'Id': t_Id,
+                         'initializer': '',
                          'type': t_type[1],
                          'short_description': t_brief,
                          'long_description': t_detailed,
@@ -154,16 +158,55 @@ class DoxyTypes(object):
         v_definition = re.sub('\*', '\\*', v_definition)
         
         variable_descr = {'category': 'variable',
-                         'definition': v_definition,
+                          'definition': v_definition,
                           'name': v_name,
                           'Id': v_Id,
+                          'initializer': '',
                           'type': v_type[1],
                           'short_description': v_brief,
-                          'long_description': detailed_description
+                          'long_description': detailed_description,
+                          'attributes': list()
                           }
 
         return variable_descr
 
+    def _process_define_node(self, node):
+        d_name = node.xpath('./name/text()')[0]
+        print  d_name
+        d_initializer = ''
+        d_type = ''
+        if len(node.xpath('./initializer')) > 0:
+            len_ref = len(node.xpath('./initializer/ref'))
+            if len(node.xpath('./initializer/ref')) > 0:
+                d_type = self._process_type_node(node.xpath("./initializer/ref")[0])        
+            if len(d_type) > 0:
+                len_text = len(node.xpath('./initializer/text()'))
+                if len(node.xpath('./initializer/text()')[0]) > 0:
+                    d_initializer = node.xpath('./initializer/text()')[0] + d_type[1]
+                if len_text > 1:
+                    if node.xpath('./initializer/text()')[1] is not None:
+                        d_initializer = d_initializer + node.xpath('./initializer/text()')[1]
+            else: 
+                d_initializer = node.xpath('./initializer/text()')[0]
+        d_Id = node.attrib['id']
+        brief_node = node.xpath('./briefdescription')[0]
+        d_brief = self._get_brief_description(brief_node)
+        details_node = node.xpath('./detaileddescription')[0]
+        detailed_description = self._get_detailed_description(details_node)
+
+        define_descr = {'category': 'composite',
+                        'definition': '',
+                        'name': d_name,
+                        'Id': d_Id,
+                        'initializer': d_initializer,
+                        'type': '',
+                        'short_description': d_brief,
+                        'long_description': detailed_description,
+                        'attributes': list()
+                        }
+
+        return define_descr
+
 
     def _get_brief_description(self, node):
         result = list()
@@ -265,14 +308,14 @@ class DoxyTypesTest(DoxyTypes):
         super(DoxyTypesTest,self).__init__(xmlpath)
 
     def run_tests(self):
+        print "Process typedef's"
         self.test_process_typedef_node()
+        print "Process define's"
+        self.test_process_define_node()
         
-    # TESTS
-
     def test_run(self):
         filename = 'krb5_8hin.xml'
         self.run(filename)
-
         
     def test_process_variable_node(self):
         filename = 'struct__krb5__octet__data.xml'
@@ -289,10 +332,18 @@ class DoxyTypesTest(DoxyTypes):
             obj = DocModel(**t)
             self.save(obj, self.templates, target_dir)
 
-    def test_run_compound(self):
-        filename = 'struct__krb5__context.xml'
-        result = self.run_compound(filename)
-        
+    def test_process_define_node(self):
+        # run parser for define's
+        filename = 'krb5_8hin.xml'
+        result = self.run(filename, include=['define'])
+        target_dir = '%s/macros' % (self.target_dir)
+        if not os.path.exists(target_dir):
+            os.makedirs(target_dir, 0755)
+        for t in result:
+            obj = DocModel(**t)
+            tmpl = {'composite': 'define_document.tmpl'}
+            self.save(obj, tmpl, target_dir)
+
 if __name__ == '__main__':
     
     tester = DoxyTypesTest( xml_inpath, rst_outpath)