Skip to content

Commit

Permalink
docs: remove extensive config doc due to new pydantic versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikonse committed Aug 26, 2023
1 parent ae962f1 commit 399917d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 53 deletions.
47 changes: 1 addition & 46 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import pydantic
import yaml
from pydantic.fields import ModelField
from pydantic.fields import FieldInfo

HERE = Path(__file__).parent
sys.path[:0] = [str(HERE.parent), str(HERE / "_ext")]
Expand Down Expand Up @@ -115,50 +115,5 @@ def generate_openapi_json():
json.dump(api.api.openapi(), f)


def _generate_config_doc_rec(field: ModelField):
if issubclass(field.type_, pydantic.BaseModel):
sub = {}
for subfield in field.type_.__fields__.values():
sub[subfield.name] = _generate_config_doc_rec(subfield)
return sub

if (
field.outer_type_ is not None
and "List" in str(field.outer_type_)
or "list" in str(field.outer_type_)
):
verbose_type = f"<list[{field.type_.__name__}]>"
else:
verbose_type = f"<{field.type_.__name__}>"

out = f"{verbose_type}"
extra_info = []
# if description := field.metadata.get("description"):
# extra_info.append(description)

if field.default:
extra_info.append(f"default={field.default}")

if field.required is not None and not field.required:
extra_info.append("optional")

if not extra_info:
return out

return f"{out} # {'; '.join(extra_info)}"


def generate_config_doc_yaml():
output = {}
for field in Config.__fields__.values():
output[field.name] = _generate_config_doc_rec(field)

output_string = yaml.dump(output).replace("'", "").replace('"', "")

BUILD_DIR.mkdir(parents=True, exist_ok=True)
with open(BUILD_DIR / "config_schema.yaml", "w+", encoding="utf-8") as f:
f.write(output_string)


generate_openapi_json()
generate_config_doc_yaml()
7 changes: 0 additions & 7 deletions docs/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,3 @@ Possible config options are
"imprintURL": "<string, optional>",
"sourceCodeURL": "https://github.com/SFTtech/abrechnung"
}
All Configuration Options
-------------------------

.. literalinclude :: ../_build/config_schema.yaml
:language: yaml

0 comments on commit 399917d

Please sign in to comment.