anbeime/skill / skills/pptx-generator/pptx-generator
pptx-generator
Verified产品经理与运营专员在准备汇报展示时,将 JSON 数据一键转换为标准 .pptx 文件。自动应用多种布局、图表与表格样式,快速生成专业 PPT,彻底告别繁琐手工排版,让内容产出与展示更高效!
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.3 KB |
| assets/styles/business.json | config | 167 B |
| assets/styles/minimal.json | config | 169 B |
| assets/styles/modern.json | config | 165 B |
| assets/templates/ppt_data_template.json | config | 749 B |
| references/collaboration_guide.md | markdown | 10.2 KB |
| references/json_format_spec.md | markdown | 4.5 KB |
| references/layout_guide.md | markdown | 6.6 KB |
| scripts/json_validator.py | script | 5.9 KB |
| scripts/pptx_builder.py | script | 9.6 KB |
| scripts/pptx_validator.py | script | 4.4 KB |
scripts/json_validator.py
View on GitHub#!/usr/bin/env python3
"""
JSON Validator - Validate JSON format for PPT generation.
This module validates JSON data to ensure it conforms to the
expected format for PPT generation.
"""
import argparse
import json
import sys
from pathlib import Path
from typing import Any, Dict, List
# =============================================================================
# JSON Validator
# =============================================================================
class JSONValidator:
"""Validator for JSON format."""
def __init__(self):
"""Initialize JSON validator."""
self.errors = []
self.warnings = []
def validate(self, json_path: str) -> bool:
"""
Validate JSON file.
Args:
json_path: Path to JSON file.
Returns:
True if valid, False otherwise.
"""
print(f"验证 JSON 文件: {json_path}\n")
try:
with open(json_path, 'r', encoding='utf-8') as f:
data = json.load(f)
except FileNotFoundError:
self.errors.append(f"文件不存在: {json_path}")
return False
except json.JSONDecodeError as e:
self.errors.append(f"JSON 解析错误: {e}")
return False
# Validate structure
self._validate_structure(data)
# Print results
self._print_results()
return len(self.errors) == 0
def _validate_structure(self, data: Dict[str, Any]) -> None:
"""
Validate JSON structure.
Args:
data: JSON data dictionary.
"""
# Check metadata
if 'metadata' not in data:
self.warnings.append("缺少 'metadata' 字段(推荐)")
else:
self._validate_metadata(data['metadata'])
# Check slides
if 'slides' not in data:
self.errors.append("缺少 'slides' 字段(必需)")
return
if not isinstance(data['slides'], list):
self.errors.append("'slides' 必须是数组")
return
if len(data['slides']) == 0:
self.errors.append("'slides' 数组不能为空")
return
# Validate each slide
for i, slide in enumerate(data['slides'], 1):
self._validate_slide(slide, i)
def _validate_metadata(self, metadata: Dict[str, Any]) -> None:
"""
Validate metadata.
Args:
metadata: Metadata dictionary.
"""
if not isinstance(metadata, dict):
self.errors.append("'metadata' 必须是对象")
return
if 'title' not in metadata:
self.warnings.append("metadata 中缺少 'title' 字段(推荐)")
if 'author' not in metadata:
self.warnings.append("metadata 中缺少 'author' 字段(可选)")
if 'theme' not in metadata:
self.warnings.append("metadata 中缺少 'theme' 字段(可选)")
def _validate_slide(self, slide: Dict[str, Any], index: int) -> None:
"""
Validate a slide.
Args:
slide: Slide data dictionary.
index: Slide index.
"""
if not isinstance(slide, dict):
self.errors.append(f"幻灯片 {index} 必须是对象")
return
# Check title
if 'title' not in slide:
self.errors.append(f"幻灯片 {index} 缺少 'title' 字段(必需)")
elif not isinstance(slide['title'], str):
self.errors.append(f"幻灯片 {index} 的 'title' 必须是字符串")
elif not slide['title'].strip():
self.errors.append(f"幻灯片 {index} 的 'title' 不能为空")
# Check content
if 'content' not in slide:
self.errors.append(f"幻灯片 {index} 缺少 'content' 字段(必需)")
elif not isinstance(slide['content'], list):
self.errors.append(f"幻灯片 {index} 的 'content' 必须是数组")
elif len(slide['content']) == 0:
self.warnings.append(f"幻灯片 {index} 的 'content' 数组为空")
else:
# Validate content items
for j, item in enumerate(slide['content'], 1):
if not isinstance(item, str):
self.errors.append(f"幻灯片 {index} 的 content[{j}] 必须是字符串")
# Check optional fields
if 'layout' in slide and not isinstance(slide['layout'], str):
self.warnings.append(f"幻灯片 {index} 的 'layout' 应该是字符串")
if 'notes' in slide and not isinstance(slide['notes'], str):
self.warnings.append(f"幻灯片 {index} 的 'notes' 应该是字符串")
def _print_results(self) -> None:
"""Print validation results."""
if self.errors:
print(f"❌ 发现 {len(self.errors)} 个错误:\n")
for i, error in enumerate(self.errors, 1):
print(f" {i}. {error}")
print()
if self.warnings:
print(f"⚠️ 发现 {len(self.warnings)} 个警告:\n")
for i, warning in enumerate(self.warnings, 1):
print(f" {i}. {warning}")
print()
if not self.errors and not self.warnings:
print("✓ JSON 格式验证通过!\n")
# =============================================================================
# Main Function
# =============================================================================
def main():
"""Main entry point."""
parser = argparse.ArgumentParser(
description='Validate JSON format for PPT generation'
)
parser.add_argument(
'--input', '-i',
required=True,
help='Input JSON file path'
)
args = parser.parse_args()
# Create validator
validator = JSONValidator()
# Validate
is_valid = validator.validate(args.input)
# Exit with appropriate code
sys.exit(0 if is_valid else 1)
if __name__ == '__main__':
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |