java: Add docstrings for enum constants.
This commit is contained in:
parent
0bcdeb90c4
commit
8fb7efe203
|
@ -136,19 +136,11 @@ for enum, (classname, classbrief) in classes.items():
|
||||||
classname, classname, trimmed_name, classname, name, trimmed_name),
|
classname, classname, trimmed_name, classname, name, trimmed_name),
|
||||||
file=code)
|
file=code)
|
||||||
|
|
||||||
print('%%typemap(javacode) sigrok::%s %%{' % classname, file=swig)
|
|
||||||
|
|
||||||
# Define public pointers for each enum value
|
# Define public pointers for each enum value
|
||||||
for trimmed_name in trimmed_names:
|
for trimmed_name in trimmed_names:
|
||||||
print('const %s * const %s::%s = &%s::_%s;' % (
|
print('const %s * const %s::%s = &%s::_%s;' % (
|
||||||
classname, classname, trimmed_name, classname, trimmed_name),
|
classname, classname, trimmed_name, classname, trimmed_name),
|
||||||
file=code)
|
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
|
# 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 = {' % (
|
print('template<> const SR_API std::map<const enum %s, const %s * const> EnumValue<%s, enum %s>::_values = {' % (
|
||||||
|
|
|
@ -617,7 +617,7 @@ ENABLED_SECTIONS =
|
||||||
# documentation regardless of this setting.
|
# documentation regardless of this setting.
|
||||||
# Minimum value: 0, maximum value: 10000, default value: 30.
|
# 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
|
# 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
|
# the bottom of the documentation of classes and structs. If set to YES the list
|
||||||
|
|
|
@ -45,14 +45,16 @@ for compound in index.findall('compound'):
|
||||||
elif language == 'java':
|
elif language == 'java':
|
||||||
print('%%typemap(javaclassmodifiers) %s "/** %s */\npublic class"' % (
|
print('%%typemap(javaclassmodifiers) %s "/** %s */\npublic class"' % (
|
||||||
class_name, brief))
|
class_name, brief))
|
||||||
|
constants = []
|
||||||
for section in cls.findall('sectiondef'):
|
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
|
continue
|
||||||
for function in section.findall('memberdef'):
|
for member in section.findall('memberdef'):
|
||||||
function_name = function.find('name').text
|
member_name = member.find('name').text
|
||||||
brief = get_text(function.find('briefdescription'))
|
brief = get_text(member.find('briefdescription')).replace('"', '\\"')
|
||||||
parameters = {}
|
parameters = {}
|
||||||
for para in function.find('detaileddescription').findall('para'):
|
for para in member.find('detaileddescription').findall('para'):
|
||||||
paramlist = para.find('parameterlist')
|
paramlist = para.find('parameterlist')
|
||||||
if paramlist is not None:
|
if paramlist is not None:
|
||||||
for param in paramlist.findall('parameteritem'):
|
for param in paramlist.findall('parameteritem'):
|
||||||
|
@ -65,12 +67,24 @@ for compound in index.findall('compound'):
|
||||||
if language == 'python':
|
if language == 'python':
|
||||||
print(str.join('\n', [
|
print(str.join('\n', [
|
||||||
'%%feature("docstring") %s::%s "%s' % (
|
'%%feature("docstring") %s::%s "%s' % (
|
||||||
class_name, function_name, brief)] + [
|
class_name, member_name, brief)] + [
|
||||||
'@param %s %s' % (name, desc)
|
'@param %s %s' % (name, desc)
|
||||||
for name, desc in parameters.items()]) + '";')
|
for name, desc in parameters.items()]) + '";')
|
||||||
elif language == 'java':
|
elif language == 'java':
|
||||||
print(str.join('\n', [
|
if kind == 'public-func':
|
||||||
'%%javamethodmodifiers %s::%s "/** %s' % (
|
print(str.join('\n', [
|
||||||
class_name, function_name, brief)] + [
|
'%%javamethodmodifiers %s::%s "/** %s' % (
|
||||||
' * @param %s %s' % (name, desc)
|
class_name, member_name, brief)] + [
|
||||||
for name, desc in parameters.items()]) + ' */\npublic"')
|
' * @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('%}')
|
||||||
|
|
Loading…
Reference in New Issue