OpenSite/Reference/Commands/Document commands

From BathAfrica Documentation
Revision as of 13:10, 29 October 2026 by BathAfrica (talk | contribs) (Use BathAfrica sidebar contents without duplicate inline contents box)
Jump to navigation Jump to search


Review notice: Development documentation for OpenSite 0.0.1, source snapshot 77c3fee (Phase 13C). Reviewed against implementation on 29 October 2026. Tests and the Windows desktop were not rerun for this publication; this is not a released-product support claim.

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

opensite-cli document example --output section.osdoc

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 label text. Required width and height quantities. Returns the new document handle, the object id, and the content revision. The default label is Rectangle.
document.open
Required path. Returns the document handle.
document.save
Required document handle and path.
document.close
Required document handle. Optional discard boolean. False requires a clean document.
document.set_quantity
Required document handle, object id, property name, and value quantity. Returns the content revision.
document.set_boolean, document.set_integer, document.set_real, and document.set_string
Required document handle, object id, property name, and value. The property must already have that type. Returns the content revision.
document.set_reference
Required document handle, object id, property name, and target object 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.undo and document.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.

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.cpp
  • src/cli/document_commands.cpp
  • src/cli/preference_commands.cpp
  • src/application/builtins.cpp

OpenSite overview · Reference · Guides