config_reference
mkdocs_terok.config_reference
¶
Pydantic model rendering engine for config reference documentation.
Provides functions to render Pydantic v2 BaseModel classes as Markdown
tables, annotated YAML examples, and JSON Schema dumps. The consumer keeps
its own models and field docs; only the rendering logic lives here.
.. note:: Pydantic is imported at module level. This module is only useful to consumers that have Pydantic installed — import failure is acceptable for projects that don't use this feature.
render_json_schema(model_class, *, title='')
¶
Render the JSON Schema for a Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_class
|
type[BaseModel]
|
The Pydantic model class. |
required |
title
|
str
|
Optional title to inject into the schema. |
''
|
Returns:
| Type | Description |
|---|---|
str
|
Pretty-printed JSON Schema string. |
Source code in src/mkdocs_terok/config_reference.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
render_model_tables(model_class, *, field_docs=None, heading_level=3)
¶
Render Markdown tables for all sections of a Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_class
|
type[BaseModel]
|
The top-level Pydantic model class. |
required |
field_docs
|
dict[str, str] | None
|
Mapping of |
None
|
heading_level
|
int
|
Starting heading level for section headers. |
3
|
Returns:
| Type | Description |
|---|---|
str
|
Markdown string with section tables. |
Source code in src/mkdocs_terok/config_reference.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
render_yaml_example(model_class, *, field_docs=None)
¶
Render a full annotated YAML example for a Pydantic model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_class
|
type[BaseModel]
|
The Pydantic model class. |
required |
field_docs
|
dict[str, str] | None
|
Mapping of |
None
|
Returns:
| Type | Description |
|---|---|
str
|
YAML string with annotated fields and descriptions. |
Source code in src/mkdocs_terok/config_reference.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |