Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions: overhaul javadoc/doxygen comment parsing #216

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions doc/built-in-extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ extensions.
hawkmoth.ext.javadoc
--------------------

This extension converts Javadoc_ comments to reStructuredText, using the
:event:`hawkmoth-process-docstring` event.
This extension converts Javadoc_ and Doxygen_ comments to reStructuredText,
using the :event:`hawkmoth-process-docstring` event.

.. note::
The most commonly used commands are covered, including some inline markup, using
either \@ or \\ command character. The support is not complete, and mainly
covers the basic API documentation needs.

The Javadoc support is rudimentary at best.
Note that this does not change the comment block format, only the contents of
the comments. Only the ``/** ... */`` format is supported.

.. _Javadoc: https://www.oracle.com/java/technologies/javase/javadoc.html

.. _Doxygen: https://www.doxygen.nl/

Installation and configuration in ``conf.py``:

.. code-block:: python
Expand All @@ -31,14 +36,18 @@ Installation and configuration in ``conf.py``:

Name of the transformation to handle. Defaults to ``'javadoc'``. Only convert
the comment if the ``transform`` option matches this name, otherwise do
nothing.
nothing. Usually there's no need to modify this option.

For example:

.. code-block:: python
:caption: conf.py

extensions.append('hawkmoth.ext.javadoc')
hawkmoth_transform_default = 'javadoc' # Transform everything

:data:`hawkmoth_transform_default` sets the default for the ``transform``
option.

.. code-block:: c
:caption: file.c
Expand All @@ -58,7 +67,6 @@ For example:

.. c:autofunction:: baz
:file: file.c
:transform: javadoc

.. _hawkmoth.ext.napoleon:

Expand All @@ -81,15 +89,16 @@ Installation and configuration in ``conf.py``:

Name of the transformation to handle. Defaults to ``'napoleon'``. Only
convert the comment if the ``transform`` option matches this name, otherwise
do nothing.
do nothing. Usually there's no need to modify this option.

For example:

.. code-block:: python
:caption: conf.py

extensions.append('hawkmoth.ext.napoleon')
hawkmoth_transform_default = 'napoleon'
# Uncomment to transform everything, example below uses :transform: option
# hawkmoth_transform_default = 'napoleon'

.. code-block:: c
:caption: file.c
Expand All @@ -111,6 +120,7 @@ For example:

.. c:autofunction:: baz
:file: file.c
:transform: napoleon

.. _hawkmoth.ext.transformations:

Expand Down
4 changes: 2 additions & 2 deletions doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ Output
:transform: napoleon


Javadoc-style comments
----------------------
Javadoc/Doxygen-style comments
------------------------------

Source
~~~~~~
Expand Down
9 changes: 6 additions & 3 deletions doc/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ source code must be documented using specific documentation comment style, and
the comments must follow reStructuredText markup.

Optionally, the syntax may be :ref:`extended <extending-the-syntax>` to support
e.g. Javadoc and Napoleon style comments.
e.g. Javadoc/Doxygen and Napoleon style comments.

See :ref:`the examples section <examples>` for a quick tour of what's possible,
and read on for documentation comment formatting details.
Expand Down Expand Up @@ -78,11 +78,14 @@ Hawkmoth supports :ref:`extending <extending>` the syntax using :ref:`built-in
reStructuredText.

The :ref:`hawkmoth.ext.javadoc` extension provides limited support for Javadoc_
style comments, and the :ref:`hawkmoth.ext.napoleon` extension provides support
for :external+sphinx:py:mod:`sphinx.ext.napoleon` style comments.
and Doxygen_ style comments, and the :ref:`hawkmoth.ext.napoleon` extension
provides support for :external+sphinx:py:mod:`sphinx.ext.napoleon` style
comments.

.. _Javadoc: https://www.oracle.com/java/technologies/javase/javadoc.html

.. _Doxygen: https://www.doxygen.nl/

.. _cross-referencing:

Cross-Referencing C and C++ Constructs
Expand Down
Loading
Loading