Repository navigation
✨ Extract YAML Reference from String
🚀 Overview
You can now extract a YAML reference section directly from a string that contains both descriptive text and YAML content. This makes it much easier to work with mixed-format reference files and streamlines the process of loading and validating custom references.
📝 How It Works
You can pass a string (e.g., REFERENCE_CONTENT) that includes both text and a YAML block. The function extract_reference_from_str will automatically find and extract the YAML section, returning it as a Python object.
# SECTION: extract reference from string
extracted_reference = extract_reference_from_str(REFERENCE_CONTENT)
print(extracted_reference)
extract_status, extracted_content = extracted_reference
print(f"Extract Status: {extract_status}")
print(f"Extracted Content: {extracted_content_}")🔍 What You Get
extract_status: Indicates if the extraction was successful.extracted_content: Contains the parsed YAML data, ready to use in your workflow.
💡 Why It Matters
This feature allows you to:
- Work with reference files that mix documentation and YAML without manual editing.
- Directly use the extracted YAML for further processing (e.g., checking references, initializing databases).
📂 See Example
For a complete usage example, check:
examples/configs/load & check str.py
This script demonstrates how to use extract_reference_from_str and process the extracted YAML reference in your workflow.