Closed jgunstone closed 1 year ago
implemented something closest to the the ipydatagrid approach described above here: https://github.com/maxfordham/ipyautoui/pull/125
did it for AutoUi / AutoObject only... need to apply the same rationale throughout the repo
throughout the package traits are now used rather than init args. most similar to ipydatagrid. still interested in the the reacton generate function for nesting this in solara world
merged to main in this PR https://github.com/maxfordham/ipyautoui/pull/199
hwo to deal with: docstrings,
__init__
*args and **kwargs and traitletsgenerally within the ipywidget universe, arguments are just traitlets that are piped to the Javascript side of the UI where they are observed to trigger events on_change, this means they can also be edited during the lifetime of the object.
For this reason, I guess, the arguments are defined something like:
^ kwargs then set the traitlets on instantiation.
how do others do it?
ipycanvas
in ipycanvas it looks like something clever is happening as documentation accompanies the traitlets definitions in the source code:
https://github.com/martinRenou/ipycanvas/blob/d9ee0a16cf0011978b5a5eedb165dbca564eb8c4/ipycanvas/canvas.py#L462-L483
i.e. the
#:
lines in the code above which then makes it into the API Documentationipydatagrid
https://github.com/bloomberg/ipydatagrid/blob/848238356083575c1cef4b150137edfdf5c04b16/ipydatagrid/datagrid.py#L213-L323
the above simply documents all the traitlets attributes in the docstring. this is nice and simple, and would also make it easier to document traitlets from child classes. This isn't being used to produce API documentation though.
One annoying thing about both of these approaches is that intellisense doesn't work as because the args aren't explicitly defined in the function call.
In reacton-ipycanvas there is a
generate
function that appears to read the ipycanvas package and convert the traitlets definition into function calls, thus supporting intellisense.