Make the element JSON round trip match the docs (4 small fixes)

Đang mở
#586 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Vedant-200 đang làm issue này rồi.

Từ ngày 12/11/2026.

  • #593 của @Vedant-200 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
backend, testing

Hướng nghiên cứu

Issue #585 adds the round-trip tests in tests/test_element_roundtrip.py; read that file and choose one of the four named cases, then inspect its listed builder or converter entry point. Run the matching test with uv run pytest tests/test_element_roundtrip.py -k <test_name> -v; done means removing that case's strict xfail marker, passing the test, and adding a short entry under [Unreleased] → Fixed in CHANGELOG.md. An open linked pull request (#593) means work is already underway.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement good first issue
What problem would this solve?

Agents write slide JSON from the guides in sdpm/references/guides/. Two things follow from that:

  • Every key the guides document should work in the builder.
  • JSON that pptx_to_json writes should rebuild into the same slide, so the builder must accept whatever the converter emits.

#585 adds round-trip tests for shape, freeform, line, textbox, group and image elements (tests/test_element_roundtrip.py). Four cases where the docs, the converter and the builder disagree are left as xfail(strict=True) tests. Each one is a small, self-contained fix.

Proposed solution

Once #585 is merged, pick any item below. A PR that fixes a single item is welcome.

  • Shape paragraphs accept the documented list key.

    • Now: shape paragraphs only make a bullet from "bullet": true (or a bullet character). The documented form "list": {"type": "disc"} (sdpm/references/guides/slide-json-elements.md, shape section) is ignored, so no bullet is drawn.
    • Expected: list: {type: disc} makes a bullet. Keep bullet as an alias so existing JSON still works.
    • Files: sdpm/sdpm/engine/builder/elements/shape.py (_add_shape, the paragraphs branch). The textbox builder (sdpm/sdpm/engine/builder/elements/textbox.py) already handles list and is a good model.
    • Test: TestShapeText::test_documented_paragraph_list_makes_a_bullet
  • Shape lineOpacity takes effect.

    • Now: lineOpacity is documented for shapes, but only freeforms apply it, and only freeforms extract it.
    • Expected: a shape with line and lineOpacity gets an alpha on its outline colour, and pptx_to_json reads it back. Share the freeform code rather than copying it.
    • Files: sdpm/sdpm/engine/builder/elements/shape.py (line colour branch of _add_shape); freeform logic to reuse is in sdpm/sdpm/engine/builder/formatting.py (_apply_shape_formatting) and sdpm/sdpm/engine/converter/elements/shapes.py (extract_freeform_element → extract_shape_element).
    • Test: TestShapeText::test_line_opacity
  • Fixed paragraph line spacing survives a rebuild.

    • Now: for a paragraph with fixed line spacing (a:spcPts), the converter writes "lineSpacing": <1/100 pt>. The textbox builder reads only lineSpacingPct per paragraph, so the spacing is lost when the JSON is rebuilt.
    • Expected: the builder reads the converter's paragraph-level fixed spacing and writes a:lnSpc/a:spcPts. Before choosing the key, check its naming and units against the element-level lineSpacingPt.
    • Files: sdpm/sdpm/engine/builder/elements/textbox.py (paragraphs loop), sdpm/sdpm/engine/converter/elements/textbox.py (where lineSpacing is written).
    • Test: TestTextboxParagraphs::test_fixed_line_spacing_survives_a_second_build
  • Picture borders are extracted.

    • Now: the builder writes line / lineWidth on raster images, but pptx_to_json drops them, so a bordered picture comes back without its border.
    • Expected: the converter extracts the picture outline as line / lineWidth.
    • Files: sdpm/sdpm/engine/converter/elements/media.py (extract_picture_element). sdpm/sdpm/engine/converter/xml_helpers.py has line helpers already used for shapes.
    • Test: TestImageProperties::test_border_survives

Done when the matching xfail marker is removed and the test passes. Also add a short entry under [Unreleased] → Fixed in CHANGELOG.md.

How to run the tests (no LibreOffice needed):

uv run pytest tests/test_element_roundtrip.py -v
uv run pytest tests/test_element_roundtrip.py -k test_line_opacity -v   # one item
make lint
Which area?

Slide generation / engine (layouts, elements, charts)

Ngôn ngữ chính
Python
Star
136
Fork
13
Merge trung bình
7 giờ 36 phút
Pull request đã merge (30 ngày)
175

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws-samples/sample-spec-driven-presentation-maker

Tất cả issue của aws-samples/sample-spec-driven-presentation-maker

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.