Skip to content

Conversation

@seisman seisman added this to the 0.18.0 milestone Oct 8, 2025
@seisman seisman added the documentation Improvements or additions to documentation label Oct 8, 2025

{% for item in attributes %}
.. autoproperty::
.. autoattribute::
Copy link
Member Author

Choose a reason for hiding this comment

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

It should be autoattribute, not autoproperty

Copy link
Member

Choose a reason for hiding this comment

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

Currently, attributes are sorted alphabetically, which is not ideal.

I was able to get the attributes sorted alphabetically using https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#directive-option-autoclass-member-order by adding these lines at L7-8:

    :members:
    :member-order: bysource

Results in something like the below. Note how shade_offset comes before shade_fill

image

However, using :members: here means Figure and other classes are also affected, so not ideal. Might need to create a custom template separately for these class-based params?

Copy link
Member Author

Choose a reason for hiding this comment

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

Might need to create a custom template separately for these class-based params?

Done in 3109877.

>>> fig.show()
"""

#: Set clearances between the embellishment and the box border. It can be either a
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems we should use the #: comment format to document attributes.

xref: https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#doc-comments-and-docstrings

Copy link
Member

Choose a reason for hiding this comment

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

This is pretty cool, it also means we can get a permalink to the attributes like https://pygmt-dev--4144.org.readthedocs.build/en/4144/api/generated/pygmt.params.Box.html#pygmt.params.Box.clearance!

@seisman seisman added the needs review This PR has higher priority and needs review. label Oct 8, 2025
@seisman seisman marked this pull request as ready for review October 9, 2025 00:20
@seisman seisman added skip-changelog Skip adding Pull Request to changelog needs review This PR has higher priority and needs review. and removed needs review This PR has higher priority and needs review. labels Oct 9, 2025
@seisman
Copy link
Member Author

seisman commented Oct 9, 2025

Currently, attributes are sorted alphabetically, which is not ideal.

@seisman seisman marked this pull request as draft October 9, 2025 02:10
@seisman seisman removed the needs review This PR has higher priority and needs review. label Oct 9, 2025
@seisman
Copy link
Member Author

seisman commented Oct 9, 2025

/format

@seisman seisman force-pushed the fix/class-docstring branch from 0e1f50b to 3109877 Compare October 9, 2025 04:35
@seisman seisman changed the title Fix the display for docstrings of class attributes Add an autosummary to improve the display for class attributes of params Oct 9, 2025
@seisman seisman changed the title Add an autosummary to improve the display for class attributes of params Improve the display for class attributes of params Oct 9, 2025
@seisman seisman added the needs review This PR has higher priority and needs review. label Oct 9, 2025
@seisman seisman marked this pull request as ready for review October 9, 2025 04:45
Copy link
Member

Choose a reason for hiding this comment

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

Just realized this is very similar to the doc/_templates/autosummary/enums.rst file added in #3693, except that there's the minigallery here. Not sure if it makes sense to combine them?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but does a minigallery make sense for an Enum class?

Copy link
Member

Choose a reason for hiding this comment

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

I can't seem to render the minigallery locally for some reason, so not sure how it looks like.

Copy link
Member

Choose a reason for hiding this comment

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

Oh actually, it seems like the minigallery won't show up for Enums.

Copy link
Member

Choose a reason for hiding this comment

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

Let's just keep the templates separate then. Feel free to go ahead and merge.

@seisman seisman merged commit beb5670 into main Oct 9, 2025
29 of 30 checks passed
@seisman seisman deleted the fix/class-docstring branch October 9, 2025 05:36
@seisman seisman removed the needs review This PR has higher priority and needs review. label Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty 'Attributes' section in docs page

3 participants