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

🐛 Hide from_public from TOC #135

Merged
merged 10 commits into from
Oct 23, 2024
Merged

🐛 Hide from_public from TOC #135

merged 10 commits into from
Oct 23, 2024

Conversation

Zethson
Copy link
Member

@Zethson Zethson commented Oct 23, 2024

Fixes #134

Things I Tried That Didn't Work:

  1. __getattr__ on the Class: This only works for instance attributes, not class methods like from_public. It didn't intercept class-level method calls.

  2. Metaclass Solution: Adding a custom metaclass (BioRecordMeta) caused conflicts with existing metaclasses used by Django models, resulting in a "metaclass conflict" error.

  3. Removing the Docstring (__doc__ = None): While this removed the method's documentation, from_public still showed up in Sphinx's table of contents (TOC) since the method itself was still present.

  4. __dir__ Override: Hiding the method via __dir__ didn't prevent Sphinx from listing from_public because Sphinx relies on more than just dir() for introspection.

  5. Sphinx Event Hook: Registering the autodoc-skip-member event handler required access to conf.py.

What Finally Worked:

  • Using __init_subclass__: This method was overridden to dynamically add the from_public method to each subclass only when Sphinx was not running. This ensures that from_public is available for backward compatibility at runtime but hidden from Sphinx documentation.

Signed-off-by: zethson <lukas.heumos@posteo.net>
Signed-off-by: zethson <lukas.heumos@posteo.net>
Copy link

github-actions bot commented Oct 23, 2024

@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 13:55 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 15:03 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 15:12 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 15:21 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 15:35 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 16:02 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 16:35 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 16:46 Inactive
Signed-off-by: zethson <lukas.heumos@posteo.net>
@github-actions github-actions bot temporarily deployed to pull request October 23, 2024 16:59 Inactive
@Zethson Zethson marked this pull request as ready for review October 23, 2024 16:59
@Zethson Zethson changed the title 🐛 Deprecate from_public correctly 🐛 Hide from_public from TOC Oct 23, 2024
@Zethson Zethson merged commit 8cf7f06 into main Oct 23, 2024
4 checks passed
@Zethson Zethson deleted the fix/hide_from_public branch October 23, 2024 17:05
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.

Remove from_public
1 participant