MCPcopy Create free account
hub / github.com/github/spec-kit / _render_toml

Method _render_toml

src/specify_cli/integrations/base.py:977–1001  ·  view source on GitHub ↗

Render a TOML command file from description and body. Uses multiline basic strings (``\"\"\"``) with backslashes escaped, matching the output of the release script. Falls back to multiline literal strings (``'''``) if the body contains ``\"\"\"``, then to an escaped

(description: str, body: str)

Source from the content-addressed store, hash-verified

975
976 @staticmethod
977 def _render_toml(description: str, body: str) -> str:
978 """Render a TOML command file from description and body.
979
980 Uses multiline basic strings (``\"\"\"``) with backslashes
981 escaped, matching the output of the release script. Falls back
982 to multiline literal strings (``'''``) if the body contains
983 ``\"\"\"``, then to an escaped basic string as a last resort.
984
985 The body is ``rstrip("\\n")``'d before rendering, so the TOML
986 value preserves content without forcing a trailing newline. As a
987 result, multiline delimiters appear on their own line only when
988 the rendered value itself ends with a newline.
989 """
990 toml_lines: list[str] = []
991
992 if description:
993 toml_lines.append(
994 f"description = {TomlIntegration._render_toml_string(description)}"
995 )
996 toml_lines.append("")
997
998 body = body.rstrip("\n")
999 toml_lines.append(f"prompt = {TomlIntegration._render_toml_string(body)}")
1000
1001 return "\n".join(toml_lines) + "\n"
1002
1003 def setup(
1004 self,

Callers 1

setupMethod · 0.95

Calls 1

_render_toml_stringMethod · 0.80

Tested by

no test coverage detected