deephaven / deephaven-plugins

Deephaven Plugins
5 stars 12 forks source link

docs: Make autodoc output structured #582

Closed jnumainville closed 23 hours ago

jnumainville commented 1 week ago

Fixes #566

This adds a custom sphinx directive (dhautofunction) that takes the output of sphinx autofunction and extracts relevant data. Here is a snippet of the generated item in the area doc (in the doc it is all on one line)

<ParamTable param={{
  "module_name": "deephaven.plot.express.", 
  "name": "area", 
  "description": "Returns an area chart", 
  "parameters": [{"name": "table", "type": "Table | None", "description": "A table to pull data from.", "default": "None"}, ...], 
  "return_description": "A DeephavenFigure that contains the area chart", 
  "return_type": "DeephavenFigure"}}
 />
dsmmcken commented 4 days ago

Are those keys constant?

Like is it always "module_name" or could that be different if it's not a module?

Note we could also write it as actual params rather then a dict, to remove wrapper if it's any easier.

<ParamTable name="name" description="..." params=[{...}] />
jnumainville commented 3 days ago

module_name was just an alias I created for info extracted from the desc_addname node as it seems like it would generally be the module

all of the keys are constant otherwise, besides default in the params objects, which may or may not be there from what I understand, these nodes, as weirdly structured as they are, do have some consistency. For example, the desc node Contains one or more desc_signature nodes and then a single desc_content node.

I don't think passing params directly would make anything easier on the extension side, but it could be done if it's preferable for the usage side