-
Notifications
You must be signed in to change notification settings - Fork 3
Generate Quarto Markdown for Python API #306
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
Conversation
…validmind/validmind-library into nrichers/sc-4660/python-api-with-quarto
I found a fix for a quirk we inherited from our pdoc HTML reference. The issue is that we get a very L-O-N-G list of individual test IDs with no links at all — in the Quarto docs, we just list and link to the test category pages which then list the indidividual tests.
Just how long is that list? Compare this snippet in the signature:
Here's one of the pages we now link to: EDITI did the same for unit metrics, though we currently don't generate separate pages for all the unit metrics to link to — not all test IDs are unit metrics but all unit metrics technically are also test IDs: |
Co-authored-by: Beck <164545837+validbeck@users.noreply.github.com>
…ichers/sc-4660/python-api-with-quarto
57e1788
to
4f164fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incredible 🫡.
One final teeny-tiny detail: the single quotes are rendered weirdly:

i.e. ’
instead of '
.
Other than that it looks really good 👏 amazing!
I would suggest we do a follow up where we try to enforce best practices in terms of naming/typing parameters so documentation stays consistent.
It can start as a "reminder" but I think we can probably somehow add a rule to the linter?
5e022c9
to
46048af
Compare
OK, this is finally fixed via 46048af! It turns out Quarto enables Pandoc smart quotes by default but I tracked down the correct fix after some experimentation. We now get the correct ![]() |
…ichers/sc-4660/python-api-with-quarto
PR SummaryThis pull request introduces significant enhancements to the documentation generation process by integrating Quarto for generating API documentation. The changes include:
These changes collectively enhance the documentation generation process, making it more robust, automated, and aligned with modern documentation practices using Quarto. Test Suggestions
|
Internal Notes for Reviewers
This PR generates Quarto Markdown documentation for our Python API with
make quarto-docs
. These Quarto docs can then be fetched and rendered with the main docs site: LIVE PREVIEWHow
make quarto-docs
works:Relates to: validmind/documentation#640
What is nice about this PR
__init__.py
file, missing type annotations, and docstrings.* Examples:
__version__
, we output the actual version as a link in the sidebar (see the screenshot above)Summary of the changes
Refer to README.md for how Quarto Markdown generation works.
Makefile
make quarto-docs
— Added new action to generate Quarto Markdown from the Python API.github/
integration.yaml
andpython.yaml
— Updated workflows to test Quarto Markdown generation and ignore all ofdocs/
(not justdocs/_build/
)quarto-docs.yaml
— Added new workflow to generate Quarto docs and commit themdocs/
README.md
— Added to explain the Quarto Markdown generation processtemplates/
— Added Quarto templates and macros based on Jinja2validmind.css
— Added CSS styling for Quarto Markdown_metadata.yml
— Added Quarto configuration file_sidebar.yml
— Generated Quarto sidebar navigation fragmentvalidmind.qmd
,validmind/
— Generated Quarto Markdown files for the ValidMind Python APIscripts/
generate_quarto_docs.py
— Added documentation-generating script that:docs/
Features
validmind/
__init__.py
— Reordered__all__
list for better content flow in the public APIvm_models/test_suite/__init__.py
— Added new init file to properly expose module structureOther changes
.gitignore
— Updated to ignore Quarto-specific files we don't want to commitpyproject.toml
— Updated with new dependencies for documentation generationLimitations
Function signatures use HTML elements to work around the
mdformat
linter removing nested[]
brackets even with escaping which breaks some output. You could turn off linting but this then breaks parameter descriptions that do need to escape some Markdown characters. There are ways around this issue in the future.For future reference:
Notes
Fixes to the Python API — PLEASE CHECK CAREFULLY!
There were quite a few times when I hit issues that turned out to originate in our Python API itself.
Simple docstrings fixes
These fixes are generally safe:
Missing
validmind/vm_models/test_suite/__init__.py
I spent about 6 hours trying to figure out why I wasn't getting part of the API in the JSON dump and eventually traced it to a missing init file in a folder, added via c549bee.
(pdoc seems to be quite permissive but Griffe will not inspect this part of the API without an init file.)
JSON dump warnings
These commits fixed the following warnings when dumping the JSON from the API with Griffe:
For example, we now correctly indicate more optional parameters and return annotations:
Output file comparison
The Quarto Markdown files are a drop-in replacements with only minor differences:
Minor differences, FYI
Discrepancies between signatures and docstrings
Here, we render what is in the JSON for the function signature which happens to match the docstring better:
Here, we directly handle the callable kind from the JSON metadata while preserving Python's type hint syntax, unlike the old HTML which fails to resolve the type correctly with a mangled
NoneType
. Also, we don't repeat the link as it's already provided by the return annotation:Here, we're using a common convention when using Plotly — importing the graph_objs module as
go
to make the function signature more concise (note how pdoc runs out of space). Both versions refer to the same underlying Plotly types, just using different import styles:External Release Notes