MCPcopy
hub / github.com/github/spec-kit / _render_yaml

Method _render_yaml

src/specify_cli/integrations/base.py:1165–1192  ·  view source on GitHub ↗

Render a YAML recipe file from title, description, and body. Produces a Goose-compatible recipe with a literal block scalar for the prompt content. Uses ``yaml.safe_dump()`` for the header fields to ensure proper escaping.

(cls, title: str, description: str, body: str, source_id: str)

Source from the content-addressed store, hash-verified

1163
1164 @classmethod
1165 def _render_yaml(cls, title: str, description: str, body: str, source_id: str) -> str:
1166 """Render a YAML recipe file from title, description, and body.
1167
1168 Produces a Goose-compatible recipe with a literal block scalar
1169 for the prompt content. Uses ``yaml.safe_dump()`` for the
1170 header fields to ensure proper escaping.
1171 """
1172 header = cls._build_yaml_header(title, description)
1173
1174 header_yaml = yaml.safe_dump(
1175 header,
1176 sort_keys=False,
1177 allow_unicode=True,
1178 default_flow_style=False,
1179 ).strip()
1180
1181 # Indent the body for YAML block scalar
1182 indented = "\n".join(f" {line}" for line in body.split("\n"))
1183
1184 lines = [
1185 header_yaml,
1186 "prompt: |",
1187 indented,
1188 "",
1189 f"# Source: {source_id}",
1190 ]
1191
1192 return "\n".join(lines) + "\n"
1193
1194
1195 def setup(

Callers 2

setupMethod · 0.95
render_yaml_commandMethod · 0.80

Calls 1

_build_yaml_headerMethod · 0.80

Tested by

no test coverage detected