Filter Fields
This recipe shows how to customize which columns are displayed in the documentation table. You can choose to show only specific fields like column, type, and nullable.
Configuration
In your mkdocs.yml:
plugins:
- sqlalchemy:
base_class: "filter_fields.models.Base"
app_path: "src"
table_style:
fields:
- column
- type
- nullable
Usage
In your markdown file:
# MkDocs SqlAlchemy Plugin
{% sqlalchemy %}
This will generate tables showing only the Column Name, Type, and Nullable status.
Result
Table: posts
| column | type | nullable |
|---|---|---|
id |
INTEGER | ❌ |
title |
VARCHAR(200) | ❌ |
content |
TEXT | ✔️ |
is_published |
BOOLEAN | ✔️ |
user_id |
INTEGER | ✔️ |
created_at |
DATETIME | ✔️ |
updated_at |
DATETIME | ✔️ |
Indexes:
ix_posts_updated_at:updated_at
Constraints:
pk_posts(PrimaryKeyConstraint)fk_posts_user_id_users(ForeignKeyConstraint)
Table: user_profiles
| column | type | nullable |
|---|---|---|
id |
INTEGER | ❌ |
user_id |
INTEGER | ✔️ |
first_name |
VARCHAR(50) | ✔️ |
last_name |
VARCHAR(50) | ✔️ |
bio |
TEXT | ✔️ |
Indexes: None
Constraints:
uq_user_profiles_user_id(UniqueConstraint)fk_user_profiles_user_id_users(ForeignKeyConstraint)pk_user_profiles(PrimaryKeyConstraint)
Table: users
| column | type | nullable |
|---|---|---|
id |
INTEGER | ❌ |
username |
VARCHAR(50) | ❌ |
email |
VARCHAR(120) | ❌ |
is_active |
BOOLEAN | ✔️ |
created_at |
DATETIME | ✔️ |
Indexes: None
Constraints:
uq_users_username(UniqueConstraint)pk_users(PrimaryKeyConstraint)uq_users_email(UniqueConstraint)