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

index 3ce73bc43f4eaab3fcc9706b70306870e89544ed..32ef6bc175f5eaa57ee4e6f683d236de25051974 100644 (file)
@@ -136,19 +136,11 @@ for enum, (classname, classbrief) in classes.items():
             classname, classname, trimmed_name, classname, name, trimmed_name),
             file=code)
 
-    print('%%typemap(javacode) sigrok::%s %%{' % classname, file=swig)
-
     # Define public pointers for each enum value
     for trimmed_name in trimmed_names:
         print('const %s * const %s::%s = &%s::_%s;' % (
             classname, classname, trimmed_name, classname, trimmed_name),
             file=code)
-        print('public static final %s %s = new %s(classesJNI.%s_%s_get(), false);' % (
-            classname, trimmed_name, classname, classname, trimmed_name),
-            file=swig)
-
-    print ('%}', file=swig)
-
 
     # Define map of enum values to constants
     print('template<> const SR_API std::map<const enum %s, const %s * const> EnumValue<%s, enum %s>::_values = {' % (
index a32e480b7a616cfebd0667ee79c901277ad5e71d..381136a8abd5e106265851635580e8367dc945e8 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 4987b6ceb656a468bacae19e926e7a181008d8ae..16d9db3e9c760a644dc7ec31e4aa108d730aaff8 100644 (file)
@@ -45,14 +45,16 @@ for compound in index.findall('compound'):
         elif language == 'java':
             print('%%typemap(javaclassmodifiers) %s "/** %s */\npublic class"' % (
             class_name, brief))
+    constants = []
     for section in cls.findall('sectiondef'):
-        if section.attrib['kind'] != 'public-func':
+        kind = section.attrib['kind']
+        if kind not in ('public-func', 'public-static-attrib'):
             continue
-        for function in section.findall('memberdef'):
-            function_name = function.find('name').text
-            brief = get_text(function.find('briefdescription'))
+        for member in section.findall('memberdef'):
+            member_name = member.find('name').text
+            brief = get_text(member.find('briefdescription')).replace('"', '\\"')
             parameters = {}
-            for para in function.find('detaileddescription').findall('para'):
+            for para in member.find('detaileddescription').findall('para'):
                 paramlist = para.find('parameterlist')
                 if paramlist is not None:
                     for param in paramlist.findall('parameteritem'):
@@ -65,12 +67,24 @@ for compound in index.findall('compound'):
                 if language == 'python':
                     print(str.join('\n', [
                         '%%feature("docstring") %s::%s "%s' % (
-                            class_name, function_name, brief)] + [
+                            class_name, member_name, brief)] + [
                         '@param %s %s' % (name, desc)
                             for name, desc in parameters.items()]) + '";')
                 elif language == 'java':
-                    print(str.join('\n', [
-                        '%%javamethodmodifiers %s::%s "/** %s' % (
-                            class_name, function_name, brief)] + [
-                        '   * @param %s %s' % (name, desc)
-                            for name, desc in parameters.items()]) + ' */\npublic"')
+                    if 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))
+    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('%}')