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

Method _extract_description

src/specify_cli/integrations/base.py:891–913  ·  view source on GitHub ↗

Extract the ``description`` value from YAML frontmatter. Parses the YAML frontmatter so block scalar descriptions (``|`` and ``>``) keep their YAML semantics instead of being treated as raw text.

(content: str)

Source from the content-addressed store, hash-verified

889
890 @staticmethod
891 def _extract_description(content: str) -> str:
892 """Extract the ``description`` value from YAML frontmatter.
893
894 Parses the YAML frontmatter so block scalar descriptions (``|``
895 and ``>``) keep their YAML semantics instead of being treated as
896 raw text.
897 """
898
899 frontmatter_text, _ = TomlIntegration._split_frontmatter(content)
900 if not frontmatter_text:
901 return ""
902 try:
903 frontmatter = yaml.safe_load(frontmatter_text) or {}
904 except yaml.YAMLError:
905 return ""
906
907 if not isinstance(frontmatter, dict):
908 return ""
909
910 description = frontmatter.get("description", "")
911 if isinstance(description, str):
912 return description
913 return ""
914
915 @staticmethod
916 def _split_frontmatter(content: str) -> tuple[str, str]:

Calls 2

_split_frontmatterMethod · 0.45
getMethod · 0.45