OpenSite/Reference/Commands/Document commands: Difference between revisions
BathAfrica (talk | contribs) Publish Cursor documentation reconciled with OpenSite source 77c3fee; tests not rerun |
BathAfrica (talk | contribs) Link adjacent OpenSite reference pages in reading order |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__ | |||
{{OpenSite scope}} | |||
{{BathAfrica Command | {{BathAfrica Command | ||
|id=opensite.document | |id=opensite.document | ||
|summary=Create, open, save, close, edit, recompute, undo, and redo a document through the command registry. | |summary=Create, open, save, close, edit, recompute, undo, and redo a document through the command registry. | ||
| Line 50: | Line 51: | ||
== Property expressions == | == Property expressions == | ||
<code>document.set_expression</code> accepts document, object, property, expression and optional language (<code>formula</code> or <code>python</code>). Python evaluation is opt-in; enabling it does not silently run a stored expression. The desktop provides Edit → Enable Python Expressions and Edit → Recalculate Python Expressions. See [[OpenSite/Reference/Features/Quantities and expressions]]. | <code>document.set_expression</code> accepts document, object, property, expression and optional language (<code>formula</code> or <code>python</code>). Python evaluation is opt-in; enabling it does not silently run a stored expression. The desktop provides Edit → Enable Python Expressions and Edit → Recalculate Python Expressions. See [[OpenSite/Reference/Features/Quantities and expressions]]. | ||
== Try this workflow == | |||
[[OpenSite/Guides/First document|First document]] — a worked lesson with expected results. | |||
== Documentation basis == | == Documentation basis == | ||
| Line 61: | Line 65: | ||
[[OpenSite|OpenSite overview]] · [[OpenSite/Reference|Reference]] · [[OpenSite/Guides|Guides]] | [[OpenSite|OpenSite overview]] · [[OpenSite/Reference|Reference]] · [[OpenSite/Guides|Guides]] | ||
[[Category:OpenSite documentation]] | [[Category:OpenSite documentation]] | ||
<div class="os-page-nav">{{Docnav|OpenSite/Reference/Commands/Set a quantity|OpenSite/Reference/Commands/Extension commands|OpenSite/Guides|All guides}}</div> | |||
Latest revision as of 14:14, 29 October 2026
Create, open, save, close, edit, recompute, undo, and redo a document through the command registry.
- Stable identifier
opensite.document
Implementation milestone
Roadmap phases 1 and 4. The CLI wrappers are the cli.document.* pages.
Units
Quantity arguments store the canonical SI value. The unit id is the display unit already registered with the units engine. A content revision is a dimensionless integer.
Terminal example
Python access
opensite.execute('document.create_section', {'width': opensite.QuantityArgument(opensite.parse_quantity('200 mm'), 'mm'), 'height': opensite.QuantityArgument(opensite.parse_quantity('200 mm'), 'mm')})
Output
The Python call returns document, object, and content_revision. The CLI example prints the saved section on stdout.
Errors
invalid_argument for rejected arguments; stale_document for a closed handle; authorization_required when no policy is installed. A protected engineering capability can return account_unavailable with the default production portal. Local document.workspace and recovery operations are permitted by that policy.
Limitations
Undo history is session state and is not saved. Closing with discard=false refuses unsaved edits. The Windows desktop has an object tree, property inspector and dockable Python console. Runtime console completion and current-file editor assistance are different features. Use the shared command registry for an authorized edit; direct C++ access is not an entitlement boundary.
Verification evidence
Repository evidence references (not rerun for this publication): CTest application.commands, cli.document, and python.development. The development script is examples/python/document_edit.py. docs/verification/Phase-4-Acceptance.md and docs/verification/Phase-6-Acceptance.md.
The provider is opensite. Headless hosts are opensite-cli and opensite.execute. Both finish in CommandRegistry::execute.
document.create_section- Optional
labeltext. Requiredwidthandheightquantities. Returns the new document handle, the object id, and the content revision. The default label isRectangle.
document.open- Required
path. Returns the document handle.
document.save- Required document handle and
path.
document.close- Required document handle. Optional
discardboolean. False requires a clean document.
document.set_quantity- Required document handle, object id,
propertyname, andvaluequantity. Returns the content revision.
document.set_boolean,document.set_integer,document.set_real, anddocument.set_string- Required document handle, object id,
propertyname, andvalue. The property must already have that type. Returns the content revision.
document.set_reference- Required document handle, object id,
propertyname, andtargetobject id. Returns the content revision.
document.set_label- Required document handle, object id, and
label. Returns the content revision.
document.recompute- Required document handle. Recomputes in the command's transaction. Returns the content revision.
document.undoanddocument.redo- Required document handle. Returns the content revision.
document.create_section uses document.edit. Open, set, recompute, undo and redo use document.workspace in the reviewed registry. document.save covers save. document.recover covers close. The development CLI installs an allow-all policy. That policy is not a production entitlement.
Property expressions
document.set_expression accepts document, object, property, expression and optional language (formula or python). Python evaluation is opt-in; enabling it does not silently run a stored expression. The desktop provides Edit → Enable Python Expressions and Edit → Recalculate Python Expressions. See OpenSite/Reference/Features/Quantities and expressions.
Try this workflow
First document — a worked lesson with expected results.
Documentation basis
Source-reviewed against development commit 77c3fee13944bcc4b5d487c77eb1f82fbe4c6ea7, branch feature/phase-13c-properties-python-expressions. This review inspected the implementation and repository evidence; it did not run the Windows application or repeat CTest.
src/cli/main.cppsrc/cli/document_commands.cppsrc/cli/preference_commands.cppsrc/application/builtins.cpp