render#

Render the settings as TOML, YAML, or JSON text.

FORMATS = ('toml', 'yaml', 'json')#

Formats in which the example can be rendered.

render(settings: Sequence[Entry], fmt: str = 'toml') → str[source]#

Render the example as plain text.

>>> from sphinx_config_schema.schema import Setting
>>> settings = [Setting(("tool", "demo"), "transport", "auto", "")]
>>> print(render(settings))
[tool.demo]
transport = "auto"
>>> print(render(settings, "yaml"))
tool:
  demo:
    transport: auto
to_toml_value(value: Any) → str[source]#

Render a JSON value as an inline TOML value.

>>> to_toml_value({"name": "demo", "paths": ["a", "b"], "strict": True})
'{ name = "demo", paths = ["a", "b"], strict = true }'
to_yaml_value(value: Any) → str[source]#

Render a JSON value as a YAML flow value.

>>> to_yaml_value({"name": "demo", "paths": ["a", "b"], "strict": True, "v": "1.0"})
'{name: demo, paths: [a, b], strict: true, v: "1.0"}'