Skip to content

Conversation

@masenf
Copy link
Collaborator

@masenf masenf commented Sep 6, 2025

Ensure that props/fields are correctly rendered in the autogenerated API reference.

Ensure that props/fields are correctly rendered in the autogenerated API reference.
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR extends the auto-generated API reference documentation system to properly handle dataclass fields alongside existing Pydantic model support. The changes enable comprehensive documentation generation for classes that use Python's @dataclass decorator, which is becoming increasingly common in the Reflex codebase.

The core enhancement involves modifying the Source class in source.py to detect dataclasses using dataclasses.is_dataclass() and extract their fields using dataclasses.fields(). This required handling different attribute patterns between dataclasses and Pydantic models - specifically managing type_ vs type attributes and handling dataclasses.MISSING as a default value indicator.

To support complex class hierarchies, the PR introduces an extra_fields parameter to the generate_docs() function, allowing fields from multiple related classes to be merged into a single documentation page. This is demonstrated in apiref.py where rx.Config is changed from a simple module reference to a tuple (rx.Config, rx.config.BaseConfig), enabling the system to pull fields from both the main class and its base configuration class.

The implementation maintains backward compatibility by preserving the existing logic for rx.Base subclasses while adding parallel support for dataclasses. This ensures that all field types across the Reflex framework are properly documented in the API reference, providing developers with complete information about available properties and their types.

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it adds functionality without breaking existing documentation generation
  • Score reflects well-structured code changes that handle edge cases appropriately, though the complexity of supporting multiple field extraction patterns introduces some risk
  • Pay close attention to the field formatting logic in source.py to ensure all attribute access patterns are handled correctly

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@carlosabadia carlosabadia merged commit 636525e into main Sep 8, 2025
9 checks passed
@carlosabadia carlosabadia deleted the masenf/apiref-dataclass branch September 8, 2025 13:07
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.

3 participants