排版计划
The goal is to recreate a formatting template file (template.docx) based on the formatting specifications of 课程设计格式2026---指导教师2026.6.12.doc (which we have converted to template_source.docx), replacing the text-based sample code inside it with a Carbon-style screenshot of the carbon project itself (E:\AI\antigravity\stady-code\supplement\carbon). We will also align the Python environments and verify the whole skill end-to-end.
User Review Required
Section titled “User Review Required”[!IMPORTANT]
- Code screenshot selection: We plan to take a screenshot of
next.config.js(lines 1 to 28) from thecarbonproject. Let us know if you prefer a different source file.- Carbon screenshot configuration:
- Theme:
one-light(white)- Window Theme:
mac(3-color dots)- Shadow/Border: Disabled (
ds=false, transparent backgroundrgba(255,255,255,0))- Watermark:
user(added in the bottom right corner via post-processing PIL library since Carbon’s own watermark URL query is a binary logo switch)- Template recreation strategy: We will write a script to load the original template paragraphs from the converted docx, find the contiguous paragraph blocks representing Java code, delete those code paragraphs, insert the generated Carbon screenshot at their locations, and save it as
assets/template.docxinside the skill directory.
Open Questions
Section titled “Open Questions”[!NOTE]
- Should we replace all sample Java code blocks (e.g.,
DbUtils,DaoUtils, entity classes, main entry) in the formatting template with the carbon screenshot ofnext.config.js, or did you want specific parts of the carbon project screenshotted for different sections? (We recommend replacing all of them with thenext.config.jsscreenshot as placeholders to show the formatting).- Will the template be saved as
assets/template.docxso the document builder scriptbuild_docx.pycan automatically use it as its styling base? (We recommend this).
Proposed Changes
Section titled “Proposed Changes”Recreate Template and Screenshots
Section titled “Recreate Template and Screenshots”A script to automate the recreation of assets/template.docx from references/template_source.docx by:
- Taking a screenshot of
next.config.jsfrom thecarbonproject usingnode scripts/screenshot.js. - Locating all text-based code blocks in
template_source.docx. - Replacing them with the generated PNG image and appropriate captions.
- Outputting the result as
E:\AI\zcode\object\skills\course-design-report\assets\template.docx.
The final styling and layout template file, containing the correct styles (margins, font sizes, paragraph formats, headers, footers) and having the sample code replaced with Carbon screenshots.
Python Environment Alignment
Section titled “Python Environment Alignment”We will configure the python commands to use the path C:\Users\user\AppData\Local\Programs\Python\Python313\python.exe (which contains python-docx and pillow) or install python-docx in the active environment if desired.
Document Assembly and Screenshot Scripts Verification
Section titled “Document Assembly and Screenshot Scripts Verification”Review and fix any potential bugs in:
- The three-line borders implementation (
_apply_three_line_borders). - TOC domain fields (
add_toc_field). - Header/footer placement.
Ensure:
- The Puppeteer screenshot logic operates correctly when
localhost:3000is active. - The Python post-processing watermark addition handles path escaping correctly in Windows environments.
Verification Plan
Section titled “Verification Plan”Automated Tests
Section titled “Automated Tests”- Carbon Dependency Verification: Wait for
npx yarn installinside the carbon project to finish. - Start Carbon Server: Start the local server with
npx yarn devand verify it serveshttp://localhost:3000. - Screenshot Script Test: Run:
Verify
Terminal window node scripts/screenshot.js --code E:\AI\antigravity\stady-code\supplement\carbon\next.config.js --lang javascript --out test_carbon.pngtest_carbon.pngis generated with theuserwatermark and transparent background. - Template Rebuilding: Run the
rebuild_template.pyscript to generateassets/template.docx. - Document Assembly Test: Run:
Verify that
Terminal window "C:\Users\user\AppData\Local\Programs\Python\Python313\python.exe" scripts/build_docx.py --content test/content.json --out test/test_report.docxtest_report.docxcompiles successfully.
Manual Verification
Section titled “Manual Verification”- Open
assets/template.docxandtest_report.docxto manually verify formatting layout (margins, fonts, three-line tables, code image positioning, header/footer text).