feat(templates): document templating system for .kc files #306
Reference in New Issue
Block a user
Delete Branch "feat/document-templates"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add a document templating system integrated with Silo's new-item creation flow. Users can create parts and assemblies from pre-configured
.kctemplate files, and save existing documents as reusable templates.Changes
Template Use (New Item form)
templates.py(new) — template discovery, filtering,TemplateInfodataclass,inject_template_json()helper, 3-tier search pathsschema_form.py— template combo picker in the Identity section, filtered by item type and categorysilo_commands.py—SiloSync.create_document_from_template()copies template.kc, strips identity, stamps Silo properties;_on_createdroutingTemplate Creation (Save as Template)
SaveAsTemplateDialog— modal dialog capturing name, description, item types, categories, author, and tagsSilo_SaveAsTemplatecommand — copies current doc, strips Silo identity, injectssilo/template.json, optionally uploads to Silo for team sharingInitGui.py— registered in Silo menuTemplate Search Paths (3-tier, later shadows earlier by name)
mods/silo/freecad/templates/— system templates shipped with addon~/.local/share/FreeCAD/Templates/— personal templates (sister toMacro/)~/projects/templates/— org-shared project templatesDocumentation
docs/src/guide/templates.md— full user guide covering usage, creation, search paths, descriptor schema, and CLI toolingdocs/src/guide/silo.md— updated command table and directory structuredocs/src/SUMMARY.md— added Templates page to navigationHow it works
A template is a normal
.kcfile with an extrasilo/template.jsondescriptor inside the ZIP. The copy-and-stamp approach avoids complex object-by-object cloning:.kcto the canonical file pathsilo/template.jsonandsilo/manifest.jsonfrom the copykc_format.pyauto-creates a fresh manifestTesting
create_document_for_item()