Skip to content

docs: ensure that PlotAccessor is included in the API reference#17513

Open
tswast wants to merge 1 commit into
mainfrom
plot-accessor-docs
Open

docs: ensure that PlotAccessor is included in the API reference#17513
tswast wants to merge 1 commit into
mainfrom
plot-accessor-docs

Conversation

@tswast

@tswast tswast commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Currently, this page is blank.

image

After this change:

image

🦕

@tswast tswast requested review from a team as code owners June 18, 2026 19:55
@tswast tswast requested review from TrevorBergeron and removed request for a team June 18, 2026 19:55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request exposes PlotAccessor in the public typing API and updates its references in the documentation templates and docstrings. It also updates the docstring decorator in _tools/docs.py to copy docstrings to property getters. The review feedback recommends making the decorator more robust by separating the docstring assignment of the descriptor from its underlying callable, preventing an AttributeError on the descriptor from skipping the getter's docstring assignment, and extending support to other descriptors like classmethod and cached_property.

Comment on lines 32 to 40
try:
target_item.__doc__ = source_item.__doc__
if isinstance(target_item, property) and target_item.fget:
try:
target_item.fget.__doc__ = source_item.__doc__
except AttributeError:
pass
except AttributeError:
pass

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If target_item.__doc__ = source_item.__doc__ raises an AttributeError (which can happen for certain read-only descriptors like classmethod or staticmethod in some Python versions), the execution jumps directly to the outer except AttributeError block, skipping the logic to set the docstring on the underlying getter or function.

To make this decorator more robust and reusable across the codebase, we should:

  1. Separate the docstring assignment of the descriptor itself from the assignment of the underlying callable.
  2. Extend support to other common descriptors like classmethod/staticmethod (which wrap functions in __func__) and cached_property (which wrap functions in func).
Suggested change
try:
target_item.__doc__ = source_item.__doc__
if isinstance(target_item, property) and target_item.fget:
try:
target_item.fget.__doc__ = source_item.__doc__
except AttributeError:
pass
except AttributeError:
pass
try:
target_item.__doc__ = source_item.__doc__
except AttributeError:
pass
underlying = None
if isinstance(target_item, property):
underlying = target_item.fget
elif hasattr(target_item, "__func__"):
underlying = target_item.__func__
elif hasattr(target_item, "func"):
underlying = getattr(target_item, "func", None)
if underlying is not None:
try:
underlying.__doc__ = source_item.__doc__
except AttributeError:
pass

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.

1 participant