from xml.etree import ElementTree
import sys, os
-language, input_file = sys.argv[1:]
+language, input_file = sys.argv[1:3]
+if len(sys.argv) == 4:
+ mode = sys.argv[3]
input_dir = os.path.dirname(input_file)
index = ElementTree.parse(input_file)
def get_text(node):
paras = node.findall('para')
- return str.join('\n\n', [p.text.rstrip() for p in paras if p.text])
+ return str.join('\n\n', [("".join(l)).rstrip() for l in [list(p.itertext()) for p in paras] if l])
for compound in index.findall('compound'):
if compound.attrib['kind'] != 'class':
if brief:
if language == 'python':
print('%%feature("docstring") %s "%s";' % (class_name, brief))
+ elif language == 'ruby':
+ print('%%feature("docstring") %s "/* Document-class: %s\\n%s */\\n";' % (class_name, class_name.replace("sigrok", "Sigrok", 1), brief))
elif language == 'java':
print('%%typemap(javaclassmodifiers) %s "/** %s */\npublic class"' % (
class_name, brief))
class_name, member_name, brief)] + [
'@param %s %s' % (name, desc)
for name, desc in parameters.items()]) + '";')
+ if language == 'ruby' and kind == 'public-func':
+ print(str.join('\n', [
+ '%%feature("docstring") %s::%s "/* %s' % (
+ class_name, member_name, brief)] + [
+ '@param %s %s' % (name, desc)
+ for name, desc in parameters.items()]) + ' */\\n";')
elif language == 'java' and kind == 'public-func':
print(str.join('\n', [
'%%javamethodmodifiers %s::%s "/** %s' % (
trimmed_name, member_name))
print('%}')
elif language == 'python' and constants:
- print('%%extend %s {\n%%pythoncode %%{' % class_name)
+ if mode == 'start':
+ print('%%extend %s {\n%%pythoncode %%{' % class_name)
+ for member_name, brief in constants:
+ print(' ## @brief %s\n %s = None' % (brief, member_name))
+ print('%}\n}')
+ elif mode == 'end':
+ print('%pythoncode %{')
+ for member_name, brief in constants:
+ print('%s.%s.__doc__ = """%s"""' % (
+ trimmed_name, member_name, brief))
+ print('%}')
+ elif language == 'ruby' and constants:
for member_name, brief in constants:
- print(' ## @brief %s\n %s = None' % (brief, member_name))
- print('%}\n}')
+ print('%%feature("docstring") %s::%s "/* %s */\\n";' % (class_name, member_name, brief))