Every python-pptx MSO_SHAPE preset round-trips to the ECMA-376 <a:prstGeom/@prst> token recorded on the enum member's xml_value. This manifest is a parameterised family: one manifest file expands into one case per MSO_SHAPE member (~180 cases), each backed by a distinct fixture pptx/shape-preset-geometry--<id>.pptx generated from the same gen_shape_preset_geometry.py script parameterised by --preset MSO_SHAPE_NAME.
Library verdicts: python-pptx: — pptxjs: pass
| Feature id | pptx/shape-preset-geometry--corner |
|---|---|
| Format | pptx |
| Category | shapes |
| Family | pptx/shape-preset-geometry |
| Axis values | preset=corner |
| Spec | ecma-376-5-part-1 § 20.1.9.18 a:prstGeom |
| ID / part | Predicate | XPath | python-pptx | pptxjs |
|---|---|---|---|---|
prst-is-cornerppt/slides/slide1.xml | equal = cornerThe slide's auto-shape must declare <a:prstGeom prst="corner"/>, matching MSO_SHAPE.CORNER.xml_value. | //a:prstGeom/@prst | — | — |
| ID | Predicate | Selector | python-pptx | pptxjs |
|---|---|---|---|---|
shape-preset-corner-dom-present | css_selector/ existA DOM node annotated as a shape (via data-shape-preset='corner', .pptx-shape, or generic data-kind='sp') must exist. pptxjs renderer support for preset geometries is weak; this assertion records whatever the renderer exposes and falls back to any descendant under a slide section. | [data-shape-preset='corner'], .pptx-shape, [data-kind='sp'], section[data-slide] *, section.slide * | — | pass |
scripts/gen_shape_preset_geometry.py
#!/usr/bin/env python3
"""Generate a single ``fixtures/pptx/shape-preset-geometry--<id>.pptx``.
Parameterised generator: the ``features/pptx/shape-preset-geometry.json``
manifest expands to one case per :class:`pptx.enum.shapes.MSO_SHAPE`
member, and the conformance runner invokes this script once per case
with ``--preset <MSO_SHAPE_NAME> --out <path>``.
Each invocation produces a single-slide presentation containing one
auto-shape added via ``shapes.add_shape(MSO_SHAPE.<name>, ...)``. The
underlying ``<a:prstGeom/@prst>`` token is whatever python-pptx emits
for that enum member; the manifest asserts that this token matches
``MSO_SHAPE.<name>.xml_value``.
"""
from __future__ import annotations
import argparse
import datetime as _dt
from pathlib import Path
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE
from pptx.util import Inches
_REPO_ROOT = Path(__file__).resolve().parent.parent
_REPRODUCIBLE_DT = _dt.datetime(2000, 1, 1, 0, 0, 0)
def _write(preset_name: str, out: Path) -> None:
shape_enum = getattr(MSO_SHAPE, preset_name)
prs = Presentation()
# "Title Only" layout — a title placeholder we leave empty plus our shape.
slide = prs.slides.add_slide(prs.slide_layouts[5])
slide.shapes.add_shape(shape_enum, Inches(1), Inches(1), Inches(2), Inches(2))
out.parent.mkdir(parents=True, exist_ok=True)
prs.save(out, zip_date_time=_REPRODUCIBLE_DT)
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument(
"--preset",
required=True,
help="MSO_SHAPE member name, e.g. RECTANGLE",
)
parser.add_argument(
"--out",
required=True,
help="Output fixture path (absolute or repo-relative)",
)
args = parser.parse_args()
out_path = Path(args.out)
if not out_path.is_absolute():
out_path = _REPO_ROOT / out_path
_write(args.preset, out_path)
print(out_path)
return 0
if __name__ == "__main__":
raise SystemExit(main())
{
"$schema": "../manifest.schema.json",
"id": "pptx/shape-preset-geometry--corner",
"kind": "literal",
"title": "Shape preset geometry",
"format": "pptx",
"category": "shapes",
"summary": "Every python-pptx MSO_SHAPE preset round-trips to the ECMA-376 <a:prstGeom/@prst> token recorded on the enum member's xml_value. This manifest is a parameterised family: one manifest file expands into one case per MSO_SHAPE member (~180 cases), each backed by a distinct fixture pptx/shape-preset-geometry--<id>.pptx generated from the same gen_shape_preset_geometry.py script parameterised by --preset MSO_SHAPE_NAME.",
"spec": {
"source": "ecma-376-5-part-1",
"clause": "20.1.9.18",
"element": "a:prstGeom",
"rnc_reference": "spec/ecma-376-5/part-1/rnc/DrawingML.rnc",
"xsd_reference": "spec/ecma-376-5/part-1/xsd/dml-shape.xsd",
"notes": "DrawingML <a:prstGeom prst=\"...\"/> selects one of the ~180 preset auto-shape geometries enumerated in the ST_ShapeType simple type. python-pptx exposes these via pptx.enum.shapes.MSO_SHAPE, where each enum member's xml_value attribute holds the prst token emitted into the XML. This family asserts the identity: for every MSO_SHAPE member, shapes.add_shape(member, ...) emits <a:prstGeom prst=\"member.xml_value\"/>."
},
"fixtures": {
"machine": "pptx/shape-preset-geometry--corner"
},
"generator": {
"python": "scripts/gen_shape_preset_geometry.py",
"arg_template": "--preset {preset.mso} --out fixtures/pptx/shape-preset-geometry--{preset.id}.pptx"
},
"_expansion": {
"parent_id": "pptx/shape-preset-geometry",
"bindings": {
"preset": "corner"
}
},
"assertions": [
{
"id": "prst-is-corner",
"part": "ppt/slides/slide1.xml",
"namespaces": {
"p": "http://schemas.openxmlformats.org/presentationml/2006/main",
"a": "http://schemas.openxmlformats.org/drawingml/2006/main"
},
"xpath": "//a:prstGeom/@prst",
"must": "equal",
"value": "corner",
"description": "The slide's auto-shape must declare <a:prstGeom prst=\"corner\"/>, matching MSO_SHAPE.CORNER.xml_value."
}
],
"render_assertions": [
{
"id": "shape-preset-corner-dom-present",
"kind": "css_selector",
"selector": "[data-shape-preset='corner'], .pptx-shape, [data-kind='sp'], section[data-slide] *, section.slide *",
"must": "exist",
"description": "A DOM node annotated as a shape (via data-shape-preset='corner', .pptx-shape, or generic data-kind='sp') must exist. pptxjs renderer support for preset geometries is weak; this assertion records whatever the renderer exposes and falls back to any descendant under a slide section."
}
]
}
