-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
215 commits
Select commit
Hold shift + click to select a range
7664a2d
Add initial Quarto docs assets from experimental branch
nrichers 35c4b37
Save point
nrichers 4a00912
Save point
nrichers 8f6aa8b
Add API tree script
nrichers 11e4db3
Save point
nrichers 7e2daaf
Save point
nrichers 60eb716
Save point before switching to Griffe API
nrichers c549bee
Save point before splitting QMD template
nrichers b61de9d
Merge branch 'nrichers/sc-4660/python-api-with-quarto' of github.com:…
nrichers f20dbee
Interim commit with mostly working reimplementation of template
nrichers 0ff8294
Re-add more content, fix markup issues, and create sidebar template
nrichers eb8bd9a
Save point
nrichers c728bcf
Partially fix nested sidebar entries
nrichers 52cfcc1
Save point
nrichers 8bf70ea
Save ppoint docstring parsing
nrichers a0f8436
Save point before error message fixes
nrichers 031306a
Save point
nrichers 83931b9
Save point
nrichers d2afcf7
Save point
nrichers 876a053
Save point
nrichers 49604b4
Save point for errors
nrichers 3619456
Save point before switching to vm_models
nrichers b67c020
Another save point
nrichers 5e945be
Got vm_models working
nrichers 0b89d1b
Save point with docstring issues
nrichers c13c5e3
Save point with partial sidebar fixes
nrichers 0c55372
Save point with partial sidebar fixes
nrichers 618efe6
Sidebar fragment contains correct file embeds
nrichers 19c25f4
Got sidebar working
nrichers b3bd81c
Save point
nrichers 0951779
Save point
nrichers 4588368
Save point with first complete sidebar
nrichers 5f7559e
Save point with first complete sidebar
nrichers f1efb98
Sidebar works
nrichers f620893
Merge branch 'main' of github.com:validmind/validmind-library into nr…
nrichers f523ec8
Add root-level classes
nrichers 1878dbe
Undo save point
nrichers 68ab754
Sidebar fixes complete
nrichers 0730e47
Add codeblock template comments
nrichers 838a135
Markup fixes
nrichers 4ddbdac
Fix sidebar regression
nrichers 14f9ec6
Fix sidebar regression
nrichers 7129470
Undo stray commit
nrichers c2d2f9c
Save point
nrichers 0d788e5
Save point
nrichers 89c6c4b
Save point
nrichers eb84a06
Likely safe save point
nrichers db05cca
Halfway through switching to better signatures
nrichers fbe9941
Halfway through switching to better signatures
nrichers 8a0cca5
Continue to improve snignature blocks and remove duplication
nrichers ede3cf6
Remove dead code
nrichers b35a72d
More signatures fine-tuning
nrichers 7406204
More signatures fine-tuning
nrichers 1f2d24b
Save point for return annotations
nrichers 5140934
Save point with most return annotations fixed but still getting NoneN…
nrichers 863007d
Save point with most return annotations fixed but still getting NoneN…
nrichers 2dba7c1
Fix docstrings
nrichers 3d91dea
Fix docstrings
nrichers cb66108
Fixed docstring defaults when set to None
nrichers 0a7fe1c
Save point for type annotations rework
nrichers ec84f2f
Undo new processing functions in script
nrichers 38b504f
Fix docstring regression
nrichers e947204
Fix docstrings in Python API
nrichers b63c4ef
Fix Python API docstring
nrichers f9c3611
Fix Python API docstring
nrichers 72951a0
Save point while fixing some docstrings
nrichers 9883d1d
Fixed short and long description regression
nrichers 7e02ac8
Merge branch 'main' of github.com:validmind/validmind-library into nr…
nrichers 352ec37
Minor content update
nrichers 59c0121
Fix type class annotations
nrichers 9d29514
Fix type class annotations
nrichers 89a7045
Save point types fine-tuning
nrichers 5c7aea6
Save point types fine-tuning
nrichers f33043e
Add missing default to docstring and fix grammar
nrichers f1b1443
Fix default handling in docstrings, fix class for type keywords
nrichers 2cd783f
Fix default handling in docstrings, fix class for type keywords
nrichers 40f1168
Fix default handling in docstrings, fix class for type keywords
nrichers 2d74a7c
Fix wording
nrichers f744522
Output class methods on single line and append colon for classes and …
nrichers 4001362
Output class methods on single line and append colon for classes and …
nrichers 9a76661
Remove colons for return annotations
nrichers e33ecb7
Remove colons for return annotations
nrichers 1ba2fc6
Fix variadic and positional parameters
nrichers 5515e2d
Save point
nrichers b1730a4
Fix single line vs multiline signatures regression
nrichers 300dd81
Reapply fix for ExprList
nrichers 8ad52bc
Save point
nrichers fa42eb3
Save point with debug comments in types.jinja2
nrichers 0100faf
Merge branch 'main' of github.com:validmind/validmind-library into nr…
nrichers 8bb20c7
Fixed final raw JSON output for Expr* types
nrichers cf3dcc8
Save point before descending into experimental darkness
nrichers e75ce77
Minor type fix
nrichers a571db7
Interim save point
nrichers f530eb2
Fixed ExprAttribute rendering for inherited members
nrichers 20f4be1
Remove debug statements
nrichers 6fff53b
Save point for class names in signatures for inherited members
nrichers 869d5ad
Fix class for constructors that have multiple parameters
nrichers a503405
Fix raw JSON issue with ExprCall
nrichers ab0485a
Generalize Expr* type handling further
nrichers 6e1544b
Better decorator formatting when >1 decorator
nrichers 281af1d
Add metadata and CSS files
nrichers 51568b7
Fix return annotation None and improve handling of @ in decorators
nrichers 8847951
Fixed display of self in methods
nrichers 1a72190
Fix Python API warnings
nrichers 5da00f0
Save point after fixing Python API, did it work?
nrichers e6e7804
Switch from reference/ to validmind/ path to avoid breaking links
nrichers 13f0327
Merge branch 'main' of github.com:validmind/validmind-library into nr…
nrichers d1a4eb3
CSS rename, latest version
nrichers f403c65
Docstring edits
nrichers 9c73ca9
Generate QMD
nrichers 1485050
Fix CSS embed in metadata file
nrichers bcb5fb0
Fix docstring handling bug with newlines
nrichers 3c01976
Improve alias handling to catch all root-level aliases safely
nrichers 9293f8f
Clarify Torch TensorDataset is supported
nrichers b5dd363
Remove ToC and sidebar decoration to help with long names
nrichers 9a8ddf2
Add special case for vm_models
nrichers 5dfb9a4
Fix return type annotations
nrichers 63b9bd3
Improve type annotation coverage
nrichers e86b74d
Fix for missing vm_model classes and methods
nrichers 9dc854d
Fix inherited members info
nrichers 68d3698
Improve formatting for type_info in docstrings
nrichers 8930be1
Fix ordering for class attributes
nrichers 515a5fa
Add special case for cleaning up tests
nrichers 069f2ba
Try to fix code test errors
nrichers 61ebd4d
Fix more code test errors
nrichers 7c1d7bd
Fix yet more code test errors
nrichers af2a499
Interim save point on better control over ordering
nrichers 70faabd
Remove unused _quarto.yml
nrichers c835224
Fix return annotation for run_test_suite
nrichers 55a7e15
Fix some return annotations
nrichers 22fd453
Minor punctuation fix
nrichers e63ed8a
Fix docstring for inspect()
nrichers 17cc0cf
Remove API tree script I used to explain the API docstrings to myself
nrichers 3223c64
Initial README.md draft
nrichers f7781d6
Move diagram in README.md
nrichers a420724
Start using template for errors
nrichers 00620c3
Update Quarto source
nrichers c7d99e1
Save point for better error messages
nrichers 8511994
Better API error handling
nrichers 435ca43
Error message formatting & fixes
nrichers 15f76aa
Interim save point for fixing inherited BaseError content
nrichers 70baed6
Save point with signature and inherited member improvements
nrichers 9528d7d
Save point for error messages
nrichers 1cc49f2
Interim save point for inherited member fixes
nrichers b9f5c0c
Remove inherited members for errors from test descriptions
nrichers 607c22e
Clean up inherited members
nrichers 80ed22a
Finally fixed the elusive description method for BaseError
nrichers d75f038
Fix minor formatting issue
nrichers 844ec2e
Remove hardcoding
nrichers b2ed0af
Save point before chewing out Sonnet
nrichers a87d5b6
Remove more hardcoded content after a frank discussion with Sonnet
nrichers 7323154
Consolidate signature handling
nrichers 7626997
Improve handling for class param vs params
nrichers f2c2c29
Improve sidebar
nrichers dce652b
Hide test suite class info from main page
nrichers 3eab8ea
Improve filtering out non-public functions
nrichers 5dbe54a
Add version number to sidebar & hide ToC for root function topic
nrichers 987f45a
Add workflow for Quarto docs
nrichers 2c171bd
Add test building Quarto docs to python.yaml
nrichers 7cd9860
Ignore docs/** path in workflows
nrichers 8bdc738
Make version in sidebar fancier
nrichers 2863338
Fix missing RawData children in sidebar
nrichers 80ac81a
Simplify inherited member formatting
nrichers ea11028
Omit inherited members heading when there are none
nrichers 9e9b499
Fix return annotation for pandas.DataFrame
nrichers 095a689
Fix function signatures when async
nrichers 73dd3b4
Handle module-level aliases like describe_test_suite
nrichers 571fed8
Remove debug statement from script
nrichers bdc6d54
ValidMind CSS tweaks
nrichers f50a9d3
Update README.md
nrichers 4b8002e
Update mermaid diagram
nrichers 67c1766
Update mermaid diagram, again
nrichers d1788e7
Update mermaid diagram, take three
nrichers f051480
Update mermaid diagram, take four
nrichers 15da15f
Update mermaid diagram, take five
nrichers cc274cf
Update mermaid diagram, take six
nrichers 5b368b1
Edit README.md
nrichers ef9c4f4
Edit README.md
nrichers 2e23def
Add linter to README.md
nrichers dd317a7
Merge branch 'main' of github.com:validmind/validmind-library into nr…
nrichers 9e53f0e
Readme & CSS tweaks
nrichers 5cf8f48
CSS tweak for codeblocks
nrichers 31238a1
Fix flake8 whitespace error
nrichers 4a399c8
Update Quarto Markdown source
nrichers d175b57
Add dependencies to pyproject.toml and GitHub workflow
nrichers 311c747
Switch .html links in titles to .qmd
nrichers 3770fd5
Class prefix and function suffix CSS experiment
nrichers 97d4529
More class prefix and function suffix CSS experiments
nrichers d5654c0
Save point for sidebar fragment generation fixes after CSS experiments
nrichers becec58
Fix sidebar navigation fragment after CSS changes
nrichers 0812848
Fix headings that link to themselves
nrichers 503c63d
Remove class prefixes from return annotation links
nrichers 00d9079
Improve handling for external types and return annotation linking
nrichers db03bd5
Enable parameter type linking for internal types
nrichers f7d409e
Fix case-sensitive external type link
nrichers 0d97eb1
Add HTML to external types
nrichers b67d32a
Improve TestID handling
nrichers 504c84d
Improve unit metric handling in signatures
nrichers b221786
Update docs/_metadata.yml
nrichers 9da36e4
Fix decorators macro
nrichers c2f29b0
Merge branch 'main' of github.com:validmind/validmind-library into nr…
nrichers 49680b0
Update poetry.lock
nrichers b5aa4c0
Fix unit tests, round 1
nrichers 9a06c3a
Fix unit tests, round 2
nrichers 8ad9b64
Fix unit tests, round 3
nrichers 2f844e3
Apply # noqa: C901 to complex tests
nrichers 4f164fe
Fix invalid table format errors
nrichers c5952c5
Try fixing pandas.io.formats error
nrichers 3720308
Fix TableOutputHandler to address invalid table format errors
nrichers 1a91120
Fix C901 'TableOutputHandler.process' is too complex error
nrichers 25e4858
Refactor test to reduce complexity and undo # noqa: C901
nrichers b62aba4
Fix annotation warnings in utils.py
nrichers 96e038d
Improve sidebar spacing
nrichers 46048af
Found correct global fix for smart quotes
nrichers ad22026
Merge branch 'main' of github.com:validmind/validmind-library into nr…
nrichers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
- prod | ||
- release-v1 | ||
paths-ignore: | ||
- 'docs/_build/**' | ||
- 'docs/**' | ||
|
||
permissions: | ||
contents: read | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# This workflow will install Python dependencies and generate | ||
# Quarto documentation using Griffe for API extraction and | ||
# Jinja2 templates for the docs and navigation. | ||
name: Python Library API docs for Quarto | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release-v1 | ||
paths-ignore: | ||
- 'docs/**' | ||
workflow_dispatch: | ||
inputs: | ||
note: | ||
description: 'Provide a description of the changes' | ||
required: true | ||
default: 'Update quarto docs' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
quarto-docs: | ||
runs-on: | ||
group: ubuntu-vm-large | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GH_TOKEN }} | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
cache: 'poetry' | ||
|
||
- name: Install Dependencies | ||
run: | | ||
poetry env use python3.11 | ||
poetry install -E huggingface -E llm | ||
poetry run pip install torch==2.0.1 --extra-index-url https://download.pytorch.org/whl/cpu | ||
poetry run pip install aequitas fairlearn vl-convert-python | ||
poetry run pip install griffe mdformat docstring_parser | ||
|
||
- name: Generate Quarto Docs | ||
run: make quarto-docs | ||
|
||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
default_author: github_actions | ||
message: 'Generate quarto docs' | ||
add: 'docs/' | ||
remove: 'docs/_build/' | ||
pathspec_error_handling: ignore | ||
push: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,3 +214,6 @@ my_tests/ | |
*.sqlite | ||
*.db | ||
*.db-journal | ||
|
||
# Quarto docs | ||
docs/validmind.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Generating Quarto Markdown for the Python API | ||
|
||
This directory includes templates, macros, CSS, and Quarto Markdown output for generating the ValidMind Library (Python API) reference documentation for our docs site. | ||
|
||
- `templates/` — Jinja2 templates and macros for generating Quarto Markdown | ||
- `validmind.css` — CSS for Python API reference styling | ||
- `_metadata.yml` — Quarto configuration file | ||
- `_sidebar.yml` — Generated sidebar navigation fragment for Quarto | ||
- `validmind.qmd`, `validmind/` — Generated API documentation matching the codebase and pdoc structure | ||
|
||
## Testing locally | ||
|
||
To generate Quarto Markdown locally: | ||
|
||
```sh | ||
make quarto-docs | ||
``` | ||
|
||
## How it works | ||
|
||
1. Griffe extracts API information from the API codebase and dumps it to a JSON file | ||
2. A Python script extracts API information from the JSON, processes it, and passes it to Jinja2 templates | ||
3. Jinja2 templates and shared macros transform this information into Quarto Markdown files | ||
4. A sidebar navigation fragment is generated based on the output file structure | ||
5. CI/CD integration tests the Quarto docs generation and commits the output | ||
6. Documentation repo: Integrates the Quarto files with the docs site source | ||
|
||
```mermaid | ||
flowchart LR | ||
make[make quarto-docs] --> clean[Clean old files] | ||
clean --> mkdir[Create folder structure] | ||
mkdir --> Griffe[Dump API JSON] | ||
Griffe --> processJSON[Process API JSON] | ||
|
||
processJSON --> output[Generate QMD files] | ||
processJSON --> nav[Generate _sidebar.yml] | ||
|
||
subgraph "Templates" | ||
templates[Jinja2 Templates] --> mod_t[module.qmd.jinja2] | ||
templates --> class_t[class.qmd.jinja2] | ||
templates --> func_t[function.qmd.jinja2] | ||
templates --> sidebar_t[sidebar.qmd.jinja2] | ||
templates --> version_t[version.qmd.jinja2] | ||
templates --> errors_t[errors.qmd.jinja2] | ||
templates --> macros[macros/*.jinja2] | ||
end | ||
|
||
templates --> processJSON | ||
|
||
output --> test[Integration tests] | ||
nav --> test | ||
|
||
subgraph "CI/CD" | ||
test --> commit[Commit generated docs] | ||
end | ||
``` | ||
|
||
### `Makefile` | ||
|
||
- `make quarto-docs` — Generates Quarto Markdown from the Python API | ||
- `make python-docs` — In the documentation repo: Clones this repo, copies the generated Quarto Markdown files over into the docs site source | ||
|
||
### GitHub actions | ||
|
||
- `.github/integration.yaml` and `.github/python.yaml` — Tests Quarto Markdown generation | ||
- `.github/quarto-docs.yaml` — Generates and commits Quarto Markdown docs | ||
|
||
### Jinja2 Templates | ||
|
||
Located in `templates/`, these define how Quarto Markdown is output: | ||
|
||
- `module.qmd.jinja2` — Documents Python modules, including functions and classes | ||
- `version.qmd.jinja2` — Displays library version information | ||
- `class.qmd.jinja2` — Details class documentation with inheritance and methods | ||
- `function.qmd.jinja2` — Formats functions, parameters, and return values | ||
- `errors.qmd.jinja2` — Documents error classes with sorting | ||
- `sidebar.qmd.jinja2` — Generates navigation structure | ||
- `macros/docstring.jinja2` — Parses and structures Google-style docstrings | ||
- `macros/signatures.jinja2` — Formats function signatures and parameters | ||
- `macros/types.jinja2` — Handles complex type annotations | ||
- `macros/decorators.jinja2` — Documents function and class decorators | ||
- `macros/navigation.jinja2` — Generates page linking | ||
|
||
### Python script | ||
|
||
Located in `scripts/generate_quarto_docs.py`, handles the Quarto Markdown generation: | ||
|
||
- Extracts API data using Griffe. | ||
- Processes data with Jinja2 templates. | ||
- Lints and writes output to `docs/` | ||
|
||
#### Features | ||
|
||
- **Private/public filtering** — Controls which members are included | ||
- **Root module handling** — Special processing for the `validmind` module | ||
- **Alias resolution** — Maps imported symbols to original definitions | ||
- **Docstring normalization** — Cleans up formatting inconsistencies | ||
- **Inherited members** — Documents inherited methods, especially for error classes | ||
- **Errors module handling** — Sorts and structures error class documentation | ||
- **Class discovery** — Finds and documents classes across modules | ||
- **Test suite handling** — Documents test suites and their aliases | ||
- **VM models handling** — Ensures proper documentation of core model classes | ||
- **Exclusions** — Omits internal utilities and logging helpers | ||
- **Sidebar generation** — Builds hierarchical navigation from module structure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
format: | ||
html: | ||
grid: | ||
sidebar-width: 450px | ||
margin-width: 450px | ||
page-layout: full | ||
from: markdown-smart | ||
css: | ||
- validmind.css | ||
- /developer/developer.css |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.