From: Martin Ling Date: Sun, 25 Oct 2015 03:01:30 +0000 (+0000) Subject: java: Add docstrings for enum constants. X-Git-Tag: libsigrok-0.4.0~160 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8fb7efe20311903dd8101962107d21a02a9884ce;p=libsigrok.git java: Add docstrings for enum constants. --- diff --git a/bindings/cxx/enums.py b/bindings/cxx/enums.py index 3ce73bc4..32ef6bc1 100644 --- a/bindings/cxx/enums.py +++ b/bindings/cxx/enums.py @@ -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 EnumValue<%s, enum %s>::_values = {' % ( diff --git a/bindings/java/Doxyfile b/bindings/java/Doxyfile index a32e480b..381136a8 100644 --- a/bindings/java/Doxyfile +++ b/bindings/java/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 4987b6ce..16d9db3e 100644 --- a/bindings/swig/doc.py +++ b/bindings/swig/doc.py @@ -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('%}')