CerebusOSS / ella

A streaming time-series datastore for low-latency applications
https://docs.rs/ella/
Apache License 2.0
2 stars 0 forks source link

Python API documentation #21

Open sydduckworth opened 1 year ago

sydduckworth commented 1 year ago

ella's Python bindings are generated from Rust using pyo3/maturin. Unfortunately it seems that it's difficult to effectively create API documentation and type definitions for generated code.

Requirements

Implementation

So far I haven't been able to find a single approach that satisfies all of these requirements. To meet all of them it seems like information would need to be duplicated or even triplicated.

For the actual documentation, the three options would be to put the documentation:

Method pyright sphinx mkdocs pdoc
Rust docstrings
Stub docstrings
Dedicated files

For type hints, the two options would be to put the type information:

Method pyright sphinx mkdocs pdoc
stubs ✅*
docstring args ✅*

* the free version of mkdocstrings (the API generator tool for mkdocs) doesn't support hyperlinks/cross-references in the function signature, although it does in parameter blocks.

Conclusions

There isn't a single implementation that meets all use cases. I think the best option for now is to use pdoc as the documentation generator with Rust docstrings and type stub files. This doesn't get us docstrings in Pylance but it does get us type information at least. It may not be too difficult to write a script that copies the Rust docstrings into the stub files.

pawamoy commented 1 year ago

A few corrections/details: mkdocstrings does support getting docstrings from stubs. And the public version also supports cross-references (what you call hyperlinks here I assume), but in parameters sections (and the like), not directly in the rendered signature.

sydduckworth commented 1 year ago

@pawamoy thanks for the info! Clearly I didn't spend enough time exploring mkdocs.