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

Process docstring event v2 #131

Merged
merged 13 commits into from
Jan 29, 2023
Merged

Process docstring event v2 #131

merged 13 commits into from
Jan 29, 2023

Conversation

jnikula
Copy link
Owner

@jnikula jnikula commented Jan 29, 2023

v2 of #129 hopefully with all the comments resolved.

I've added some commits cleaning up related documentation, and expanded on the built-in extension usage. There's more to do, surely, but I'm hoping this is a good first step.

I also pushed the rebased but otherwise unchanged version of #129 to process-docstring-event-v1-rebased which may be helpful in comparing the differences between the two.

Add hawkmoth-process-docstring event that other Sphinx extensions can
connect to, and enable extending the docstring processing using
extensions instead of cautodoc_transformations.

This is similar to the autodoc-process-docstring event [1].

Fixes #52.

[1] https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#event-autodoc-process-docstring
It's difficult to document events properly with rst syntax. Sphinx
documentation uses a custom 'event' object type, but the full
implementation of it is a bit much. Just define the type, and use
py:function for the event signature within the event description. It's a
bit hackish, but gets the job done.

(It's not possible to use py:function on the event directly, because the
hyphens don't work in the function name.)
If the transformation is handled using an extension via event, it's okay
to a) not have cautodoc_transformations defined, and b) not have the
transform present in cautodoc_transformations.

The flip side is that this is slightly less user friendly for
cautodoc_transformations users with misconfiguration.
Transformations via cautodoc_transformations will be deprecated in some
future release of Hawkmoth in favor of using hawkmoth-process-docstring
event.

However, we can already move cautodoc_transformations handling to an
extension that is, for now, setup by default. In the future, we can
still keep the extension, but have users explicitly set it up in conf.py
if they need it. And later on, we can remove the extension from Hawkmoth
altogether.

This also marks the beginning of built-in extensions to Hawkmoth in
hawkmoth.ext.
directly instead of :py:data:`cautodoc_transformations`. This built-in
extension provides backward compatibility for the functionality.

For now, this extension is loaded by default, and the below installation step
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The installation step below*

The extension has a few configuration options that can be set in ``conf.py``.

See also additional configuration options in the :ref:`built-in extensions
<built-in-extensions>`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really nitpicking here, but this feels inferior to the admonition style example I made. Particularly, it's less direct in stating that there is a specific extension which is temporarily enabled by default and thus its configuration variables are a non-negotiable addition to these ones. I think it's that extension that we need a reference for here, not the whole set.

Than again... meh.

@BrunoMSantos
Copy link
Collaborator

I was expecting some notice of unstable API for the event. After what we discussed I think it would be a good idea, even if it will be relatively easy to support these APIs well into the future. I'll trust your judgment on that one though.

Found a tiny grammatical and one other nitpick, but it's good really. Certainly no need for another round.

This project is starting to shape up :)

Add a Sphinx and Hawkmoth extension for docstring processing via the
hawkmoth-process-docstring event to handle javadoc comments.
Add a proxy extension for processing napoleon formatted docstrings. It
sets up napoleon properly, including its configuration options.
Stop using cautodoc_transformations and switch to using the built-in
hawkmoth-process-docstring extensions for the transformations instead.
@jnikula jnikula merged commit 66f4c63 into master Jan 29, 2023
@jnikula
Copy link
Owner Author

jnikula commented Jan 29, 2023

I was expecting some notice of unstable API for the event. After what we discussed I think it would be a good idea, even if it will be relatively easy to support these APIs well into the future. I'll trust your judgment on that one though.

Found a tiny grammatical and one other nitpick, but it's good really. Certainly no need for another round.

I fixed the grammar, and merged this. We can tweak the rest before the next release if we want.

Thanks for the review!

This project is starting to shape up :)

👍

@jnikula jnikula deleted the process-docstring-event-v2 branch January 29, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants