penguin.penguin_config.gen_docs module

class penguin.penguin_config.gen_docs.DocsField(type_, merge_behavior, title, description, default, examples)[source]

Bases: object

Information about a field of the config, for generating docs

Parameters:
  • type_ (type)

  • merge_behavior (str | None)

  • title (str | None)

  • description (str | None)

  • default (PydanticUndefinedType | Any)

  • examples (tuple[Any])

default: PydanticUndefinedType | Any
description: str | None
examples: tuple[Any]
from_field()[source]

Create a DocsField from a Pydantic Field

Return type:

DocsField

from_type()[source]

Create a DocsField from a Python type, which should probably inherit BaseModel or RootModel

Parameters:

type_ (type)

Return type:

DocsField

merge(other)[source]

Create a DocsField by combining two DocsFields, using the second to fill in gaps in the first.

Parameters:

other (DocsField)

Return type:

DocsField

merge_behavior: str | None
title: str | None
type_: type
penguin.penguin_config.gen_docs.gen_docs(path=[], docs_field=DocsField(type_=<class 'penguin.penguin_config.structure.Main'>, merge_behavior=None, title='Penguin Configuration', description='Configuration file for config-file-based rehosting with IGLOO', default=PydanticUndefined, examples=[]))[source]

Generate docs for config format starting from the field at the given path

penguin.penguin_config.gen_docs.gen_docs_compact_field_table(fields)[source]

For fields that do not have any nested structure and only simple types, generate a compact table to make the docs easier to read.

penguin.penguin_config.gen_docs.gen_docs_field(path, docs_field, include_type=True)[source]

Generate docs for a single field of the config

penguin.penguin_config.gen_docs.gen_docs_literal_arg(a)[source]
penguin.penguin_config.gen_docs.gen_docs_type_name(t)[source]

Convert the Python type t to a string for use in generated docs.

penguin.penguin_config.gen_docs.gen_docs_yaml_dump(x)[source]

Convert x to YAML for use in generated docs.

We can’t use yaml.dump(x) alone for this, because it appends “

… “.

penguin.penguin_config.gen_docs.main()[source]
penguin.penguin_config.gen_docs.type_has_simple_name(ty)[source]

Determine whether a type is a regular Python type and not a Pydantic model class.