Commit 2f6f839f authored by François Grisez's avatar François Grisez

Enable generation of Java documentation

parent 6d74bab8
{{#make_chapter}}{{{className}}} class{{/make_chapter}}
{{#isNotJava}}
.. {{#write_declarator}}class{{/write_declarator}}:: {{{fullClassName}}}
{{/isNotJava}}
{{#isJava}}
.. java:package:: {{{namespace}}}
.. java:type:: public interface {{{className}}};
{{/isJava}}
{{#briefDoc}}
{{#lines}}
......
......@@ -31,7 +31,7 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx_csharp.csharp']
extensions = ['sphinx_csharp.csharp', 'javasphinx']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
......
......@@ -125,22 +125,23 @@ class RstTools:
class LangInfo:
def __init__(self, langCode):
if langCode not in LangInfo._displayNames:
raise ValueError("Invalid language code '{0}'".format(langCode))
self.langCode = langCode
self.displayName = LangInfo._lang_code_to_display_name(langCode)
self.nameTranslator = metaname.Translator.get(langCode)
self.langTranslator = abstractapi.Translator.get(langCode)
self.docTranslator = metadoc.SphinxTranslator(langCode)
@staticmethod
def _lang_code_to_display_name(langCode):
if langCode == 'C':
return 'C'
elif langCode == 'Cpp':
return 'C++'
elif langCode == 'CSharp':
return 'C#'
else:
raise ValueError("Invalid language code: '{0}'".format(langCode))
@property
def displayName(self):
return LangInfo._displayNames[self.langCode]
_displayNames = {
'C' : 'C',
'Cpp' : 'C++',
'Java' : 'Java',
'CSharp': 'C#'
}
class SphinxPage(object):
......@@ -331,6 +332,14 @@ class ClassPage(SphinxPage):
table.addrow([method['link'], briefDoc])
return table
@property
def isJava(self):
return self.lang.langCode == 'Java'
@property
def isNotJava(self):
return not self.isJava
class DocGenerator:
def __init__(self, api):
......@@ -338,6 +347,7 @@ class DocGenerator:
self.languages = [
LangInfo('C'),
LangInfo('Cpp'),
LangInfo('Java'),
LangInfo('CSharp')
]
......
......@@ -12,6 +12,7 @@ Welcome to Linphone API's documentation!
c/index.rst
cpp/index.rst
java/index.rst
csharp/index.rst
......
......@@ -1262,6 +1262,13 @@ class JavaLangTranslator(CLikeLangTranslator):
def translate_argument(self, arg, native=False, jni=False):
return '{0} {1}'.format(arg.type.translate(self, native=native, jni=jni), arg.name.translate(self.nameTranslator))
def translate_method_as_prototype(self, method, namespace=None):
return 'public interface {returnType} {methodName}({arguments})'.format(
returnType=method.returnType.translate(self),
methodName=method.name.translate(self.nameTranslator),
arguments=', '.join([arg.translate(self) for arg in method.args])
)
class CSharpLangTranslator(CLikeLangTranslator):
def __init__(self):
......
......@@ -559,6 +559,14 @@ class SphinxTranslator(Translator):
self.enumReferencer = 'type'
self.enumeratorReferencer = 'enum'
self.methodReferencer = 'meth'
elif langCode == 'Java':
self.domain = 'java'
self.classDeclarator = 'type'
self.methodDeclarator = 'method'
self.enumDeclarator = 'type'
self.enumeratorDeclarator = 'field'
self.namespaceDeclarator = 'package'
self.methodReferencer = 'meth'
else:
raise ValueError('invalid language code: {0}'.format(langCode))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment