snippet_fmt.config

Read and parse snippet-fmt configuration.

Classes:

SnippetFmtConfigDict

typing.TypedDict representing the configuration mapping parsed from formate.toml or similar.

Functions:

load_toml(filename)

Load the snippet-fmt configuration mapping from the given TOML file.

typeddict SnippetFmtConfigDict[source]

Bases: TypedDict

typing.TypedDict representing the configuration mapping parsed from formate.toml or similar.

Required Keys
  • languages (Dict[str, Dict[str, Any]]) – The languages to reformat. The keys correspond to the value after .. code-block::, including matching case. The values are key: value mappings giving language-specific options. The exact options vary, but each has a reformat option which defaults to False. If set to True the code snippets in that language will be reformatted, otherwise they will only be syntax checked. For example, the following code block has a value of 'TOML': .. code-block:: rst .. code-block:: TOML key = “value” Different capitalisation (e.g. JSON vs json) can be used to apply different settings to different groups of code blocks. For example, JSON code blocks could have and indent of 2, but json blocks have no indentation.

  • directives (List[str]) – The directive types to reformat, such as 'code-block' for .. code-block::. The values are case sensitive.

load_toml(filename)[source]

Load the snippet-fmt configuration mapping from the given TOML file.

Parameters

filename (Union[str, Path, PathLike])

Return type

SnippetFmtConfigDict