Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC of using sphinx + pydantic #614

Closed
wants to merge 1 commit into from
Closed

Conversation

Tomaz-Vieira
Copy link
Contributor

@Tomaz-Vieira Tomaz-Vieira commented Jun 13, 2024

This demonstrates how we could use sphinx to do documentation, embedding the docstring-based documentation for the pydantic models into the more human-ffriendly, manually written text

image

@FynnBe
Copy link
Member

FynnBe commented Jun 13, 2024

great stuff @Tomaz-Vieira , Thanks!
@esgomezm we should explore this a bit further, don't you think?

@esgomezm
Copy link
Contributor

Hi! It's very similar to what I added in my PR. As said before, I think we should find a way of making this much simpler, organised and human-readable. If you know how to do that with sphinx, I'm happy to help. I couldn't get much further than this

Screenshot 2024-06-13 at 15 27 34

Screenshot 2024-06-13 at 15 27 42

Screenshot 2024-06-13 at 15 28 30

@Tomaz-Vieira
Copy link
Contributor Author

That looks great, @esgomezm ! Whatever I tried on my end it seemed like it would always leave out some fields, but yours looks pretty complete =) I guess even too complete, since we can see also the pydantic-specific fields like model_config and model_fields. I know next to nothing about sphinx (and specially about this pydantic plugin) so I don't have more insights here.

It's nice that we can produce these docs, but I'm skeptical as to how much it'll solve our issue; The user-facing, tutorial-like strings would still have to live somewhere next to the docstrings, but such friendly instructions might feel out of place in the midst of the source code. Also, if we write that documentation somewhere else, then it makes it easier for it to go out of sync with the spec itself.

My interest with this is that I would like to put very polite tooltips in the model builder GUI to orient users into building their models, and in a perfect world I'd be able to fetch some of that text from this endeavor. That might require tagging the text somehow so that it can be later extracted and potentially ignored when creating the more blunt developer documentation

@esgomezm
Copy link
Contributor

Hi @Tomaz-Vieira , I also have no experience with sphinx. It was a quick try =)

In any case, I fully agree with your. This still needs further plain text description for either a GUI or human readable documentation. Unless someone knows very well how to edit sphinx and its descriptions, I would rather generate a json file.
In this json, we could update the "description" added within the docstring in the code when generating it.

For now, by the way, I have some code that creates a drafted json like this:

Screenshot 2024-06-14 at 13 15 49
Screenshot 2024-06-14 at 13 15 19

@Tomaz-Vieira
Copy link
Contributor Author

Well, that does look very friendly. What is your strategy for actually producing the text here? And how does it "attach" to the spec itself?

@esgomezm
Copy link
Contributor

I basically parsed the json schema generated by the pydantic code from the core library. It's the one in gh-pages branch. I can make a PR. Basically it's a loop through the dictionary keys for which we can add any sort of conditions and text :)

@Tomaz-Vieira
Copy link
Contributor Author

I wonder if we couldn't attach this information directly to the pydantic models, so that we skip one (potentially lossy) transformation to the Json schema, and so that it's harder for the extra text to go out of sync with the spec

@FynnBe
Copy link
Member

FynnBe commented Oct 10, 2024

closing in favor of #630 and #617

@FynnBe FynnBe closed this Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants