From: Martin Ling Date: Sun, 25 Oct 2015 12:06:20 +0000 (+0000) Subject: python: Add docstrings for enum constants. X-Git-Tag: libsigrok-0.4.0~159 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=ef9643a2bbb9f3c9a93a7a8c54100e32c1b3d3da python: Add docstrings for enum constants. --- diff --git a/bindings/python/Doxyfile b/bindings/python/Doxyfile index 0dd5d070..3c458475 100644 --- a/bindings/python/Doxyfile +++ b/bindings/python/Doxyfile @@ -617,7 +617,7 @@ ENABLED_SECTIONS = # documentation regardless of this setting. # Minimum value: 0, maximum value: 10000, default value: 30. -MAX_INITIALIZER_LINES = 30 +MAX_INITIALIZER_LINES = 0 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated at # the bottom of the documentation of classes and structs. If set to YES the list diff --git a/bindings/swig/doc.py b/bindings/swig/doc.py index 16d9db3e..ffde9331 100644 --- a/bindings/swig/doc.py +++ b/bindings/swig/doc.py @@ -36,6 +36,7 @@ for compound in index.findall('compound'): class_name = compound.find('name').text if not class_name.startswith('sigrok::'): continue + trimmed_name = class_name.split('::')[1] doc = ElementTree.parse("%s/%s.xml" % (input_dir, compound.attrib['refid'])) cls = doc.find('compounddef') brief = get_text(cls.find('briefdescription')) @@ -64,27 +65,30 @@ for compound in index.findall('compound'): if description: parameters[name] = description if brief: - if language == 'python': + if language == 'python' 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()]) + '";') - elif language == 'java': - if kind == 'public-func': + elif language == 'java' and kind == 'public-func': print(str.join('\n', [ '%%javamethodmodifiers %s::%s "/** %s' % ( class_name, member_name, brief)] + [ ' * @param %s %s' % (name, desc) for name, desc in parameters.items()]) + ' */\npublic"') - elif kind == 'public-static-attrib': - constants.append((member_name, brief)) + elif kind == 'public-static-attrib': + constants.append((member_name, brief)) if language == 'java' and constants: print('%%typemap(javacode) %s %%{' % class_name) for member_name, brief in constants: - trimmed_name = class_name.split('::')[1] print(' /** %s */\n public static final %s %s = new %s(classesJNI.%s_%s_get(), false);\n' % ( brief, trimmed_name, member_name, trimmed_name, trimmed_name, member_name)) print('%}') + elif language == 'python' and constants: + print('%%extend %s {\n%%pythoncode %%{' % class_name) + for member_name, brief in constants: + print(' ## @brief %s\n %s = None' % (brief, member_name)) + print('%}\n}')