svn rev #25058: trunk/doc/rst_tools/
tsitkova@MIT.EDU
tsitkova at MIT.EDU
Tue Jul 26 13:35:20 EDT 2011
http://src.mit.edu/fisheye/changelog/krb5/?cs=25058
Commit By: tsitkova
Log Message:
Added #define processing
Changed Files:
A trunk/doc/rst_tools/define_document.tmpl
U trunk/doc/rst_tools/docmodel.py
U trunk/doc/rst_tools/doxybuilder_funcs.py
U trunk/doc/rst_tools/doxybuilder_types.py
Added: trunk/doc/rst_tools/define_document.tmpl
===================================================================
--- trunk/doc/rst_tools/define_document.tmpl (rev 0)
+++ trunk/doc/rst_tools/define_document.tmpl 2011-07-26 17:35:19 UTC (rev 25058)
@@ -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 at mit.edu?subject=$msg_subject
+
Modified: trunk/doc/rst_tools/docmodel.py
===================================================================
--- trunk/doc/rst_tools/docmodel.py 2011-07-26 11:37:24 UTC (rev 25057)
+++ trunk/doc/rst_tools/docmodel.py 2011-07-26 17:35:19 UTC (rev 25058)
@@ -48,6 +48,7 @@
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 @@
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')
Modified: trunk/doc/rst_tools/doxybuilder_funcs.py
===================================================================
--- trunk/doc/rst_tools/doxybuilder_funcs.py 2011-07-26 11:37:24 UTC (rev 25057)
+++ trunk/doc/rst_tools/doxybuilder_funcs.py 2011-07-26 17:35:19 UTC (rev 25058)
@@ -302,7 +302,12 @@
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':
Modified: trunk/doc/rst_tools/doxybuilder_types.py
===================================================================
--- trunk/doc/rst_tools/doxybuilder_types.py 2011-07-26 11:37:24 UTC (rev 25057)
+++ trunk/doc/rst_tools/doxybuilder_types.py 2011-07-26 17:35:19 UTC (rev 25058)
@@ -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 @@
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 @@
'definition': t_definition,
'name': t_name,
'Id': t_Id,
+ 'initializer': '',
'type': t_type[1],
'short_description': t_brief,
'long_description': t_detailed,
@@ -154,17 +158,56 @@
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()
for p in node.xpath("./para"):
@@ -265,14 +308,14 @@
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 @@
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)
More information about the cvs-krb5
mailing list