Skip to content

implement reflex docgen#6200

Open
adhami3310 wants to merge 5 commits intomainfrom
implement-reflex-docgen
Open

implement reflex docgen#6200
adhami3310 wants to merge 5 commits intomainfrom
implement-reflex-docgen

Conversation

@adhami3310
Copy link
Member

No description provided.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 20, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing implement-reflex-docgen (7a80407) with main (6767870)

Open in CodSpeed

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 20, 2026

Greptile Summary

This PR introduces a new reflex-docgen sub-package and the underlying infrastructure to support programmatic documentation generation for Reflex components. It adds a doc parameter to ComponentField and the field() helper, then migrates ~95 component files from inline # comment style prop descriptions to field(doc="...") kwargs so those descriptions are available at runtime via get_js_fields(). The new generate_documentation() entry-point returns a structured ComponentDocumentation dataclass containing per-prop PropDocumentation objects.

Key changes:

  • New packages/reflex-docgen package with generate_documentation() / get_component_props() public API
  • ComponentField gains a doc: str | None attribute and BaseComponentMeta now correctly propagates is_javascript and default when rebuilding fields from a bare field(doc=...) call (fixing a pre-existing gap where is_javascript=None could be stored unchecked)
  • uv.lock and pyi_hashes.json updated accordingly; monorepo workspace expanded to include packages/*
  • One minor code-quality issue: four imports in __init__.py (get_type_hints, AnnotationSource, InspectedAnnotation, inspect_annotation) are unused, left over from an earlier implementation that parsed Annotated[..., Doc(...)] type hints directly

Confidence Score: 4/5

  • Safe to merge after cleaning up four unused imports in the new package's init.py.
  • The core logic is straightforward and well-scoped. The component-field migration is mechanical and low-risk. The only notable issue is four unused imports that are dead code from an earlier implementation; everything else looks correct and consistent.
  • packages/reflex-docgen/src/reflex_docgen/init.py — contains unused imports that should be removed before merging.

Important Files Changed

Filename Overview
packages/reflex-docgen/src/reflex_docgen/init.py New docgen module that generates ComponentDocumentation from get_js_fields(); contains four unused imports leftover from a previous implementation.
packages/reflex-docgen/pyproject.toml New package definition for reflex-docgen with appropriate dependencies (reflex, typing-extensions, typing-inspection).
reflex/components/component.py Adds doc parameter to ComponentField and field(), fixes is_javascript/default propagation in BaseComponentMeta, and migrates several inline comments to doc= kwargs; a handful of non-JS fields (library, tag, alias, is_default) retain the old comment style.
pyproject.toml Adds [tool.uv.workspace] section to include packages/* members, integrating the new reflex-docgen package into the monorepo.
pyi_hashes.json Hash updates for all regenerated .pyi stub files as expected after the component field signature changes.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant generate_documentation
    participant get_component_props
    participant ComponentClass
    participant ComponentField

    Caller->>generate_documentation: generate_documentation(MyComponent)
    generate_documentation->>get_component_props: get_component_props(MyComponent)
    get_component_props->>ComponentClass: get_js_fields()
    ComponentClass-->>get_component_props: Mapping[str, ComponentField]
    loop For each (prop_name, component_field)
        get_component_props->>ComponentField: .doc
        ComponentField-->>get_component_props: doc string or None
        Note over get_component_props: Split doc on "Defaults to" / "Default:"<br/>to extract default_value
        get_component_props->>ComponentField: .type_
        ComponentField-->>get_component_props: type annotation
        get_component_props->>get_component_props: Build PropDocumentation
    end
    get_component_props-->>generate_documentation: tuple[PropDocumentation, ...]
    generate_documentation-->>Caller: ComponentDocumentation(name, props)
Loading

Last reviewed commit: "migrate reflex compo..."

@adhami3310
Copy link
Member Author

@greptileai do your thing

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