plotly / dash-labs

Work-in-progress technical previews of potential future Dash features.
MIT License
139 stars 39 forks source link

Pages.py rewrite #69

Closed ruxi closed 2 years ago

ruxi commented 2 years ago

I refactored Pages.py to use absolute paths. The motivation of the enable interactive work when not at the package root . Please kindly review and consider

---------------------
InstallPluginToModule
---------------------
attaches plug-in methods either
(i) directly to module (dash) - (original behaviour),
or
(ii) add namespace to module with methods - (new behaviour)

i.e.

example 1:
InstallPluginToModule(dash, namespace = 'pages')  -(creates)->
    dash.pages
        |_ .register_pages
        |_ {registry}

example 2:
InstallPluginToModule(dash, namespace = None)  -(creates)->
    dash
        |_ .register_pages
        |_ {registry}

rationale:
    easier to make namespace changes using a factory.

----------------------------------------------
PageRegistryRecord & inject_record_to_registry
----------------------------------------------
refactored `register_page`

the task of creating registry records and
injecting the data to the registry is decoupled
for portability

`PageRegistryRecord` is the dataclass schema
`inject_record_to_registry` is a decorator

----------------
AutoRegisterPage
----------------
The auto-import function from `plug` was split off to
`AutoRegisterPage`, added option to configure PAGES_PATH

-----------
other notes
-----------
_match_case_filename_image_table 
    requires py3.10 since it uses the new pattern matching syntax
    (did it for learning purposes)
AnnMarieW commented 2 years ago

Hi @ruxi

Thanks for this PR. However, I'm not sure what you mean by "enable interactive work when not at the package root". Could you please elaborate and provide some examples? Can you say more about your use-case?

AnnMarieW commented 2 years ago

Hi @ruxi There is now a pull request to move pages to dash and further development on the pages feature will continue there. I'll be closing this PR, but if you still have an issue, please feel free to comment on the pull request in Dash.