office-gobmx/wizards/Package_scriptforge.mk
Jean-Pierre Ledure c5e0c65bd2 ScriptForge - Python typing hints
Python typing hints may be stored either
- inside the original .py source file
- in a separate .pyi source file (aka. STUB).
Choice is made to create a new scriptforge.pyi file
- to allow hiding the private functions
- to specialize each module: technical doc
  vs. user doc
- to allow potential later translation
- to minimize the impact at run-time:
  stubs are active only during code edition.

The new scriptforge.pyi module
- provides the static type checking of all the public
  interfaces (methods/properties) of the ScriptForge API.
- when the user uses an IDE like PyCharm or VSCode,
  (s)he might benefit from the typing hints provided
  by the signatures and docstrings stored
  in the module.

Visually, while editing a user script:
- hovering an object instance, a method or a property
  displays its detailed description
- a "." after an object instance displays a drop-down
  box listing all available interfaces
- brackets after a method-name start code-completion
  by displaying its arguments.

Limitations: SF supports ProperCase, lowercase and
camelCase naming for methods and properties.
Only ProperCase is described in scriptforge.pyi.
Extending to the other 2 notations would be easy
but would also overload needlessly the drop-down lists.

The effective code (scriptforge.py) is completed
with a series of importable variable types,
corresponding roughly with the available service
instance names in uppercase. Example
       from scriptforge import CALC, RANGE
       def userfct(c: CALC, r: RANGE) -> RANGE:
           r1: RANGE = "A1:K10"
Objective: enrich the signatures in user scripts
and benefit from the same hints when the variable
types cannot be derived from the context.

The help documentation should be complemented
with the actual additional feature.

Change-Id: I6c39939a3cdbed94828e9449cd691fe15c24c923
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164867
Reviewed-by: Jean-Pierre Ledure <jp@ledure.be>
Tested-by: Jenkins
2024-03-15 17:27:00 +01:00

62 lines
1.9 KiB
Makefile

# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
$(eval $(call gb_Package_Package,wizards_basicsrvscriptforge,$(SRCDIR)/wizards/source/scriptforge))
$(eval $(call gb_Package_add_files,wizards_basicsrvscriptforge,$(LIBO_SHARE_FOLDER)/basic/ScriptForge,\
SF_Array.xba \
SF_Dictionary.xba \
SF_Exception.xba \
SF_FileSystem.xba \
SF_L10N.xba \
SF_Platform.xba \
SF_PythonHelper.xba \
SF_Region.xba \
SF_Root.xba \
SF_Services.xba \
SF_Session.xba \
SF_String.xba \
SF_TextStream.xba \
SF_Timer.xba \
SF_UI.xba \
SF_Utils.xba \
_CodingConventions.xba \
_ModuleModel.xba \
__License.xba \
dialog.xlb \
dlgConsole.xdl \
dlgProgress.xdl \
script.xlb \
))
$(eval $(call gb_Package_add_files,wizards_basicsrvscriptforge,$(LIBO_SHARE_FOLDER)/Scripts/python,\
python/ScriptForgeHelper.py \
))
$(eval $(call gb_Package_add_files,wizards_basicsrvscriptforge,$(LIBO_SHARE_FOLDER)/basic/ScriptForge/po,\
po/ScriptForge.pot \
po/en.po \
po/pt.po \
))
$(eval $(call gb_Package_add_files,wizards_basicsrvscriptforge,$(LIBO_LIB_PYUNO_FOLDER),\
python/scriptforge.py \
python/scriptforge.pyi \
))
# vim: set noet sw=4 ts=4: