I use a shared repository partly containing Java and Python code. The code basis mainly stands on python, but some libraries are written in Java.
Is there a possibility to parse or preprocess Java documentation in order to use it later in Python-Sphinx or even a plugin?
The javadoc command allows you to write and use your own doclet classes to generate documentation in whatever form you choose. The output doesn't need to be directly human-readable ... so there's nothing stopping you outputting in a Sphinx compatible format.
However, I couldn't find any existing doclet that does this specific job.
References:
UPDATE
The javasphinx extension may be a better alternative. It allows you to generate Sphinx documentation from javadoc comments embedded in Java source code.
Sphinx does not provide a built-in way to parse JavaDoc, and I do not know of any 3rd party extension for this task.
You'll likely have to write your own documenter for the Sphinx autodoc extension. There are different approaches you may follow:
javasphinx (Github) (Documentation)
It took me way to long to find all the important details to set this up, so here's a brief for all my trouble.
Installation
The pypi version seemed to have broken imports, these issues did not seem to exist in the latest checkout.
Setup & Configuration
Assuming you've got a working sphinx setup already:
Important: add the java "domain" to sphinx, this is embedded in the
javasphinx
package and does not follow the common.ext.
extension-namespace format. (This is the detail I missed for hours):Optional: If you want external javadoc linking:
Generating Documentation
The
javasphinx
package adds the shell tooljavasphinx-apidoc
, if your current environment is active you can call it as justjavasphinx-apidoc
, or use its full path:./env/bin/javasphinx-apidoc
:This tool takes arguments nearly identical to
sphinx-apidoc
:Include Generated Docs in Index
In the output directory of the
javasphinx-apidoc
command there will have been apackages.rst
table-of-contents file generated, you will likely want to include this into your index.html's table of contents like:Compile Documentation (html)
With either your python environment active or your path modified: