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

refactor(docs): move enum documentation to docstrings #1243

Merged
merged 11 commits into from
Dec 29, 2024

Conversation

shiftinv
Copy link
Member

Summary

This moves all1 the previous enum documentation from the api/*.rst files into docstrings of their respective enum class, and uses autodoc for them instead. The point of this is allowing IDEs to show descriptions on enum members.

The built result isn't much different, with only a few minor changes:

  • The order of attributes now inherently matches the source and api docs; this was already the case 95% of the time
  • Minor whitespace/punctuation/grammar issues have been fixed, whenever I noticed them
  • An unnecessary operations block on MessageType has been removed

The purpose of the sphinx extension is to hide the enum values, i.e. making enum member headers just category instead of category = 4, matching the previous docs.
It also patches _EnumValueBase.__repr__ to use the __str__ representation instead, which is what sphinx would've done automatically if we were using stdlib enums. This only affects how enum default values are rendered within signatures:
image
image

ref: #1188 (comment)

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running pdm lint
    • I have type-checked the code by running pdm pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

Footnotes

  1. only AuditLogAction remains where it was, as it alone is ~1400-1500 lines of documentation (more than all other enums combined), and enums.py is already large enough

@shiftinv shiftinv added t: documentation Improvements or additions to documentation/examples t: refactor/typing/lint Refactors, typing changes and/or linting changes p: low Low priority labels Nov 19, 2024
@shiftinv shiftinv added this to the disnake v2.10 milestone Dec 28, 2024
@shiftinv shiftinv merged commit 3e3b27b into master Dec 29, 2024
28 checks passed
@shiftinv shiftinv deleted the docs/enum-docstrings branch December 29, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: low Low priority t: documentation Improvements or additions to documentation/examples t: refactor/typing/lint Refactors, typing changes and/or linting changes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant