Open mocobeta opened 11 months ago
The current workflow is I log into readthedocs on my own personal account and click "sync". I'm not happy with this, but I don't currently have enough permissions on this github repo to get the webhook working. Once the webhook is setup, docs deployment will be automatic.
@cjrh do you know which permission you need?
@fmassot I think either I need "write" access, or I can add you or another admin to the readthedocs site and you can generate the integration there. Long term that is probably best anyway, so that I am not the only one with access to the readthedocs site.
This is the page where the integration can be performed:
When I click "resync" it fails:
If you create a login on readthedocs (make sure to use your github OAuth login), I can add your account to the tantivy-py project on readthedocs, and then you will be able to successfully click that Resync webhook
button, which should work because it'll use the permissions on your github OAuth token. Then I won't need any permissions change on tantivy-py.
Just let me know your login name on readthedocs and I'll add it to the project.
@mocobeta This example at mkdocs shows integration of pdoc into a mkdocs build: https://github.com/mitmproxy/pdoc/tree/main/examples/mkdocs/
There is a comment that says:
mkdocstrings is a great alternative to pdoc if you are in the mkdocs ecosystem anyways.
Do you have personal experience that supports sticking with pdoc over mkdocstrings?
I tried a few things, and it seems that mkdocstrings doesn't do a good job of pulling out the docstrings from the rust source. So I guess that means pdoc is better.
I didn't know mkdocstrings, but it seems to parse the Python code with Griffle parser (https://mkdocstrings.github.io/griffe/docstrings/) and try to directly extract the docstring from the source instead of pulling it from __doc__
. So unfortunatelly this wouldn't be a help for our purposes.
Chiming in: it's actually possible to use dynamic analysis with Griffe, to use __doc__
and the like instead of reading sources. It's actually done by default for compiled modules which do not have Python sources :slightly_smiling_face: The edges might still be a bit rough around these use-cases, happy to get features requests / feedback :smile:
@pawamoy I guess the mkdocstrings is not using that feature then. It would likely be a high value improvement if you could help them to make it work with dynamic docstrings :)
I've ran some experiments and identified a couple issues in Griffe that will be fixed in the next version. This will allow you to collect API docs from your Python module compiled from Rust. However there's another issue that I cannot fix on my side: classes like DocAddress
and others say their module is tantivy
, which is incorrect, as they are actually imported from tantivy.tantivy
. I'm not familiar with Pyo3 but the following seems to work:
#[pyclass(frozen, module = "tantivy.tantivy")]
In other words: your compiled module ends up as tantivy/tantivy.cpython-blabla.so
, so it is important that classes defined within it report their parent module as tantivy.tantivy
, not just tantivy
, even if in the end they are publicly exposed from there. Their __module__
attribute must be the canonical location, not the public one.
Also some other classes (Rust structs IIUC) don't even declare their parent module, like SchemaBuilder
or Query
. They must declare it for Griffe to correctly understand them.
Then you can get something like this generated by mkdocstings:
Note that the module has to be built and installed to build the docs, since Griffe actually imports it.
Feel free to mark as off-topic and move my comment in another issue :slightly_smiling_face:
That's good feedback, thank you for looking into this 😄 . This is the correct issue IMO. I'll try to find some time to fix up the module references next weekend.
I added a PR here to fix only the module declarations: https://github.com/quickwit-oss/tantivy-py/pull/190. After that is merged I will return to make a second PR using your example showing the mkdocstrings implementation.
Now we have
.pyi
file (#167), we can generate API docs by pdoc.For example, the following commands generate static HTML files in
apidoc
dir if you havetantivy
module in your python path.Generated HTML looks very neat because PyO3 exposes comments in
.rs
files as docstrings of tantivy module, then pdoc collects all of them throughout the stubs and type hints!Perhaps we can publish the API doc to https://tantivy-py.readthedocs.io/en/latest/. I'm not familiar with the CI pipeline to publish the docs site. Is there any suggestions about that?