Skip to main content

sphinx-java

A Sphinx domain for documenting Java APIs. It is a continuation of javasphinx, which is no longer maintained, without the javasphinx-apidoc tool.

Usage

Install using pip:

pip install sphinx-java

Enable the extension in your conf.py:

extensions = ['sphinx_java']

Document a type and its members with the java directives:

.. java:package:: com.example.shapes

.. java:import:: java.util List

.. java:type:: public abstract class Polygon<P extends Point> implements Shape

   A shape with straight sides.

   :param P: The type of the vertices.

   .. java:constructor:: public Polygon(List<P> vertices)

      :param vertices: The vertices, in order.
      :throws IllegalArgumentException: If there are too many vertices.

   .. java:method:: public <S extends Shape> boolean contains(S shape)

      :param S shape: The shape.
      :return: Whether the polygon contains the shape.

   .. java:field:: public static final int MAX_SIDES = 100

See tests/roots/test-basic/index.rst for more examples.

Directives

  • java:package: sets the package of the directives and references that follow, and is the target of references to the package. A package on several pages links to the first page by name. Add :no-index: to set the package without a target.
  • java:import: declares the package of a type, as in .. java:import:: java.util List. References to the type and its nested types, such as Map.Entry, then link to that package's docs. Import a nested type as in .. java:import:: java.util Map.Entry, and then refer to it as Entry.
  • java:type: a class, interface, enum, record or annotation. Document type parameters with param fields.
  • java:constructor and java:method: document parameters with param and exceptions with throws. A method also takes return.
  • java:field: one field.
  • java:enumconstant: one enum constant, such as RED or RED(0xFF0000). The java:field role links to it.

A constructor, method or field outside a java:type directive takes the :outertype: option to name its type. Every object directive takes :package: to override the current package, and the standard :no-index: options.

Type parameters and primitive types are plain text. The package of a qualified name, such as java.util in java.util.List, is one link to the package.

Roles

Reference an object with java:type, java:meth, java:construct, java:field or java:package, or with java:ref for any object type:

:java:type:`Polygon`, :java:meth:`Polygon.contains(S)`, :java:ref:`~com.example.shapes.Polygon`

A leading ~ shows only the last part of the name. A method reference with parameter types links to that overload. The any role also finds Java objects.

External Docs

A reference that matches no local object links to external Javadoc. Map packages to their docs with javadoc_url_map in your conf.py:

javadoc_url_map = {
    'org.javatuples': ('https://www.javatuples.org/apidocs/', 'javadoc'),
}

Each value is a base URL and a docs type. The longest matching package is used. The docs types are:

  • javadoc: Javadoc before Java 8.
  • javadoc8: Javadoc from Java 8, which changed the method anchors.
  • javadoc11: Java SE docs from Java 11, which put module names in the paths.
  • sphinx: docs generated by javasphinx-apidoc.

The java, javax, org.ietf, org.w3c and org.xml packages link to the Java SE 25 docs, unless the map has them. Choose another Java SE version, 8 or 11 and later, with javadoc_java_se_version:

javadoc_java_se_version = 21

Link to external docs explicitly with the java:extdoc role:

:java:extdoc:`java.util.Map.Entry`

Migrating From javasphinx

Change the extension name in your conf.py from javasphinx to sphinx_java. The directives, roles and javadoc_url_map are the same. javasphinx linked to the Java SE 8 docs. Set javadoc_java_se_version = 8 to keep those links.

License

Apache 2.0, from javasphinx.

Metadata

Release files for sphinx-java 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-java 1.0.0
File Size Uploaded Provenance Actions
sphinx_java-1.0.0.tar.gz 31.7 kB With provenance Details for sphinx_java-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-java 1.0.0
File Interpreter ABI Platform Actions
sphinx_java-1.0.0-py3-none-any.whl Python 3 none any Details for sphinx_java-1.0.0-py3-none-any.whl

Total release size: 56.4 kB

Release files / sphinx_java-1.0.0.tar.gz

Download URL sphinx_java-1.0.0.tar.gz
Size 31.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6f90cb2bbdb71a6b9be61fd59404c5c066eee85548ce92589d947697c6be01dc
BLAKE2b-256 checksum
How to use checksums
0ccd1088b718de64884c7a940b610f0a8493bd9c7ae9b3c407910e77d31f858c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / sphinx_java-1.0.0-py3-none-any.whl

Download URL sphinx_java-1.0.0-py3-none-any.whl
Size 24.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39d7d62624244946b5ebf65dfe951b93a129c9de63900698a9798401a7a214e2
BLAKE2b-256 checksum
How to use checksums
911c437aa91d73a7a0e967e1e2e2927cd0269cb78abf908eb1e8880b740965ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for sphinx-java 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sphinx_java-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page