]> sigrok.org Git - libsigrok.git/commitdiff
python: Add docstrings for enum constants.
authorMartin Ling <redacted>
Sun, 25 Oct 2015 12:06:20 +0000 (12:06 +0000)
committerDaniel Elstner <redacted>
Mon, 26 Oct 2015 06:17:01 +0000 (07:17 +0100)
bindings/python/Doxyfile
bindings/swig/doc.py

index 0dd5d070a373f34e147e93e5860f3ec939279c49..3c458475683d1515dab825cddaf1e5e70e329b48 100644 (file)
@@ -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
index 16d9db3e9c760a644dc7ec31e4aa108d730aaff8..ffde9331f6b045e0f253151f13669b5f114c2ab7 100644 (file)
@@ -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}')