config_reference
mkdocs_terok.config_reference
¶
Pydantic model rendering engine for config reference documentation.
Renders 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
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
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
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
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
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |