-
Notifications
You must be signed in to change notification settings - Fork 235
Improve the display for class attributes of params #4144
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
Conversation
|
|
||
| {% for item in attributes %} | ||
| .. autoproperty:: | ||
| .. autoattribute:: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
|
Currently, attributes are sorted alphabetically, which is not ideal. |
|
/format |
0e1f50b to
3109877
Compare
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Fix #4138.
TODO:
BoxPatternPreview: