Skip to content

Clean Pydantic BaseModel objects out of API docs - #1115

Open
TimMonko wants to merge 4 commits into
napari:mainfrom
TimMonko:fix/api-docs
Open

Clean Pydantic BaseModel objects out of API docs#1115
TimMonko wants to merge 4 commits into
napari:mainfrom
TimMonko:fix/api-docs

Conversation

@TimMonko

@TimMonko TimMonko commented Aug 19, 2026

Copy link
Copy Markdown
Member

References and relevant issues

Closes #964

Description

Pydantic v2 causes every EventedModel-based API page (Viewer, Camera, Colormap, ...) cluttered with inherited BaseModel members. Here we use conf.py to hide them from the tables and the autodoc Details sections.
napari's own overrides (model_dump, json, model_json_schema) are kept. IMO this is desirable because the API docs aren't just for "everything" but should be a bit more opinionated, especially for most users that don't need these.

Dropped from the tables:

  • 20 methods — 11 deprecated v1 (copy, dict, construct, parse_*, schema*, validate, from_orm, update_forward_refs), 8 v2 (model_construct, model_copy, model_dump_json, model_parametrized_name, model_rebuild, model_validate*), and model_post_init
  • 5 attributesmodel_computed_fields, model_config, model_extra, model_fields, model_fields_set

@brisvag brisvag left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to add at least a collapsed section with this, or at least a link to the pydantic docs?

@TimMonko

Copy link
Copy Markdown
Member Author

Is there a way to add at least a collapsed section with this, or at least a link to the pydantic docs?

This is fully generated by Deepseek, but I managed to inject that into such docstrings:

image

Thoughts?

@brisvag

brisvag commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

I like this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Some API docs are much harder to parse with 0.7.0 (pydantic v2?)

2 participants