Skip to content

implement reflex docgen#6200

Merged
adhami3310 merged 15 commits intomainfrom
implement-reflex-docgen
Mar 24, 2026
Merged

implement reflex docgen#6200
adhami3310 merged 15 commits intomainfrom
implement-reflex-docgen

Conversation

@adhami3310
Copy link
Copy Markdown
Member

No description provided.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 20, 2026

Merging this PR will improve performance by 3.56%

⚡ 1 improved benchmark
✅ 7 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
test_compile_stateful[_stateful_page] 150.9 µs 145.7 µs +3.56%

Comparing implement-reflex-docgen (d953add) with main (fbcae95)

Open in CodSpeed

@greptile-apps
Copy link
Copy Markdown
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..."

Comment thread packages/reflex-docgen/src/reflex_docgen/__init__.py Outdated
Comment thread packages/reflex-docgen/src/reflex_docgen/__init__.py Outdated
@adhami3310
Copy link
Copy Markdown
Member Author

@greptileai do your thing

Comment thread reflex/components/core/html.py Outdated
Comment thread reflex/components/core/window_events.py Outdated
Comment thread reflex/components/datadisplay/dataeditor.py Outdated
masenf
masenf previously approved these changes Mar 23, 2026
@adhami3310 adhami3310 merged commit 64a0bc6 into main Mar 24, 2026
45 of 47 checks passed
@adhami3310 adhami3310 deleted the implement-reflex-docgen branch March 24, 2026 00: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.

2 participants