From 3755d1f722df201e49043e731030b6809e7fe811 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 15:32:55 +0200 Subject: [PATCH 01/17] base modules --- pyrevitlib/pyrevit/__init__.py | 24 +++-- pyrevitlib/pyrevit/api.py | 4 +- pyrevitlib/pyrevit/compat.py | 6 +- pyrevitlib/pyrevit/framework.py | 4 +- pyrevitlib/pyrevit/script.py | 169 ++++++++++++++++++------------- pyrevitlib/pyrevit/userconfig.py | 36 ++++--- 6 files changed, 143 insertions(+), 100 deletions(-) diff --git a/pyrevitlib/pyrevit/__init__.py b/pyrevitlib/pyrevit/__init__.py index 3cfe94241..3acbceac5 100644 --- a/pyrevitlib/pyrevit/__init__.py +++ b/pyrevitlib/pyrevit/__init__.py @@ -1,14 +1,16 @@ """pyRevit root level config for all pyrevit sub-modules. Examples: - >>> from pyrevit import DB, UI - >>> from pyrevit import PyRevitException, PyRevitIOError - - >>> # pyrevit module has global instance of the - >>> # _HostAppPostableCommand and _ExecutorParams classes already created - >>> # import and use them like below - >>> from pyrevit import HOST_APP - >>> from pyrevit import EXEC_PARAMS + ''' + from pyrevit import DB, UI + from pyrevit import PyRevitException, PyRevitIOError + + # pyrevit module has global instance of the + # _HostAppPostableCommand and _ExecutorParams classes already created + # import and use them like below + from pyrevit import HOST_APP + from pyrevit import EXEC_PARAMS + ''' """ #pylint: disable=W0703,C0302,C0103,C0413,raise-missing-from import sys @@ -180,8 +182,10 @@ class _HostApplication(object): postable commands, and other functionality. Examples: - >>> hostapp = _HostApplication() - >>> hostapp.is_newer_than(2017) + ''' + hostapp = _HostApplication() + hostapp.is_newer_than(2017) + ''' """ def __init__(self): diff --git a/pyrevitlib/pyrevit/api.py b/pyrevitlib/pyrevit/api.py index a7e87cb56..a60adca6b 100644 --- a/pyrevitlib/pyrevit/api.py +++ b/pyrevitlib/pyrevit/api.py @@ -1,7 +1,9 @@ """Provide access to Revit API. Examples: - >>> from pyrevit.api import AdWindows + ''' + from pyrevit.api import AdWindows + ''' """ import os.path as op diff --git a/pyrevitlib/pyrevit/compat.py b/pyrevitlib/pyrevit/compat.py index d336e1f39..c42e13e0e 100644 --- a/pyrevitlib/pyrevit/compat.py +++ b/pyrevitlib/pyrevit/compat.py @@ -1,8 +1,10 @@ """python engine compatibility module. Examples: - >>> from pyrevit.compat import IRONPY277 - >>> from pyrevit.compat import safe_strtype + ''' + from pyrevit.compat import IRONPY277 + from pyrevit.compat import safe_strtype + ''' """ import sys diff --git a/pyrevitlib/pyrevit/framework.py b/pyrevitlib/pyrevit/framework.py index d771b77f3..c7a928b62 100644 --- a/pyrevitlib/pyrevit/framework.py +++ b/pyrevitlib/pyrevit/framework.py @@ -1,7 +1,9 @@ """Provide access to DotNet Framework. Examples: - >>> from pyrevit.framework import Assembly, Windows + ''' + from pyrevit.framework import Assembly, Windows + ''' """ #pylint: disable=W0703,C0302,C0103,W0614,E0401,W0611,C0413,ungrouped-imports diff --git a/pyrevitlib/pyrevit/script.py b/pyrevitlib/pyrevit/script.py index b5f5a8d18..3ed299626 100644 --- a/pyrevitlib/pyrevit/script.py +++ b/pyrevitlib/pyrevit/script.py @@ -1,10 +1,12 @@ """Provide basic utilities for pyRevit scripts. Examples: - >>> from pyrevit import script - >>> script.clipboard_copy('some text') - >>> data = script.journal_read('data-key') - >>> script.exit() + ''' + from pyrevit import script + script.clipboard_copy('some text') + data = script.journal_read('data-key') + script.exit() + ''' """ #pylint: disable=consider-using-f-string @@ -203,10 +205,14 @@ def get_universal_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{file_id}.{file_ext}`` Examples: - >>> script.get_universal_data_file('mydata', 'data') - '.../pyRevit_mydata.data' - >>> script.get_universal_data_file('mydata', 'data', add_cmd_name=True) - '.../pyRevit_Command Name_mydata.data' + ''' + script.get_universal_data_file('mydata', 'data') + ''' + '/pyRevit_mydata.data' + ''' + script.get_universal_data_file('mydata', 'data', add_cmd_name=True) + ''' + '/pyRevit_Command Name_mydata.data' Universal data files are not cleaned up at pyRevit startup. Script should manage cleaning up these files. @@ -234,10 +240,15 @@ def get_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{Revit Version}_{file_id}.{file_ext}`` Examples: - >>> script.get_data_file('mydata', 'data') - '.../pyRevit_2018_mydata.data' - >>> script.get_data_file('mydata', 'data', add_cmd_name=True) - '.../pyRevit_2018_Command Name_mydata.data' + ''' + script.get_data_file('mydata', 'data') + ''' + '/pyRevit_2018_mydata.data' + ''' + script.get_data_file('mydata', 'data', add_cmd_name=True) + ''' + '/pyRevit_2018_Command Name_mydata.data' + Data files are not cleaned up at pyRevit startup. Script should manage cleaning up these files. @@ -265,10 +276,14 @@ def get_instance_data_file(file_id, add_cmd_name=False): ``pyRevit_{Revit Version}_{Process Id}_{file_id}.{file_ext}`` Examples: - >>> script.get_instance_data_file('mydata') - '.../pyRevit_2018_6684_mydata.tmp' - >>> script.get_instance_data_file('mydata', add_cmd_name=True) - '.../pyRevit_2018_6684_Command Name_mydata.tmp' + ''' + script.get_instance_data_file('mydata') + ''' + '/pyRevit_2018_6684_mydata.tmp' + ''' + script.get_instance_data_file('mydata', add_cmd_name=True) + ''' + '/pyRevit_2018_6684_Command Name_mydata.tmp' Instance data files are cleaned up at pyRevit startup. @@ -294,10 +309,14 @@ def get_document_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{Revit Version}_{file_id}_{Project Name}.{file_ext}`` Examples: - >>> script.get_document_data_file('mydata', 'data') - '.../pyRevit_2018_mydata_Project1.data' - >>> script.get_document_data_file('mydata', 'data', add_cmd_name=True) - '.../pyRevit_2018_Command Name_mydata_Project1.data' + ''' + script.get_document_data_file('mydata', 'data') + ''' + '/pyRevit_2018_mydata_Project1.data' + ''' + script.get_document_data_file('mydata', 'data', add_cmd_name=True) + ''' + '/pyRevit_2018_Command Name_mydata_Project1.data' Document data files are not cleaned up at pyRevit startup. Script should manage cleaning up these files. @@ -550,7 +569,9 @@ def get_envvar(envvar): (Any): object stored in environment variable Examples: - >>> script.get_envvar('ToolActiveState') + ''' + script.get_envvar('ToolActiveState') + ''' True """ return envvars.get_pyrevit_env_var(envvar) @@ -569,8 +590,10 @@ def set_envvar(envvar, value): value (any): value of environment variable Examples: - >>> script.set_envvar('ToolActiveState', False) - >>> script.get_envvar('ToolActiveState') + ''' + script.set_envvar('ToolActiveState', False) + script.get_envvar('ToolActiveState') + ''' False """ return envvars.set_pyrevit_env_var(envvar, value) @@ -637,32 +660,34 @@ def store_data(slot_name, data, this_project=True): this_project (bool): data belongs to this project only Examples: - >>> from pyrevit import revit - ... from pyrevit import script - ... - ... - ... class CustomData(object): - ... def __init__(self, count, element_ids): - ... self._count = count - ... # serializes the Revit native objects - ... self._elmnt_ids = [revit.serialize(x) for x in element_ids] - ... - ... @property - ... def count(self): - ... return self._count - ... - ... @property - ... def element_ids(self): - ... # de-serializes the Revit native objects - ... return [x.deserialize() for x in self._elmnt_ids] - ... - ... - ... mydata = CustomData( - ... count=3, - ... element_ids=[, , ] - ... ) - ... - ... script.store_data("Selected Elements", mydata) + ''' + from pyrevit import revit + from pyrevit import script + + + class CustomData(object): + def __init__(self, count, element_ids): + self._count = count + # serializes the Revit native objects + self._elmnt_ids = [revit.serialize(x) for x in element_ids] + + @property + def count(self): + return self._count + + @property + def element_ids(self): + # de-serializes the Revit native objects + return [x.deserialize() for x in self._elmnt_ids] + + + mydata = CustomData( + count=3, + element_ids=[, , ] + ) + + script.store_data("Selected Elements", mydata) + ''' """ # for this specific project? @@ -696,28 +721,30 @@ def load_data(slot_name, this_project=True): (object): stored data Examples: - >>> from pyrevit import revit - ... from pyrevit import script - ... - ... - ... class CustomData(object): - ... def __init__(self, count, element_ids): - ... self._count = count - ... # serializes the Revit native objects - ... self._elmnt_ids = [revit.serialize(x) for x in element_ids] - ... - ... @property - ... def count(self): - ... return self._count - ... - ... @property - ... def element_ids(self): - ... # de-serializes the Revit native objects - ... return [x.deserialize() for x in self._elmnt_ids] - ... - ... - ... mydata = script.load_data("Selected Elements") - ... mydata.element_ids + ''' + from pyrevit import revit + from pyrevit import script + + + class CustomData(object): + def __init__(self, count, element_ids): + self._count = count + # serializes the Revit native objects + self._elmnt_ids = [revit.serialize(x) for x in element_ids] + + @property + def count(self): + return self._count + + @property + def element_ids(self): + # de-serializes the Revit native objects + return [x.deserialize() for x in self._elmnt_ids] + + + mydata = script.load_data("Selected Elements") + mydata.element_ids + ''' [, , ] """ # for this specific project? diff --git a/pyrevitlib/pyrevit/userconfig.py b/pyrevitlib/pyrevit/userconfig.py index 6fba6b4ea..b8958969f 100644 --- a/pyrevitlib/pyrevit/userconfig.py +++ b/pyrevitlib/pyrevit/userconfig.py @@ -8,11 +8,13 @@ All other modules use this module to query user config. Examples: - >>> from pyrevit.userconfig import user_config - >>> user_config.add_section('newsection') - >>> user_config.newsection.property = value - >>> user_config.newsection.get_option('property', default_value) - >>> user_config.save_changes() + ''' + from pyrevit.userconfig import user_config + user_config.add_section('newsection') + user_config.newsection.property = value + user_config.newsection.get_option('property', default_value) + user_config.save_changes() + ''' The user_config object is also the destination for reading and writing @@ -23,11 +25,13 @@ :pyobject: get_config Examples: - >>> from pyrevit import script - >>> cfg = script.get_config() - >>> cfg.property = value - >>> cfg.get_option('property', default_value) - >>> script.save_config() + ''' + from pyrevit import script + cfg = script.get_config() + cfg.property = value + cfg.get_option('property', default_value) + script.save_config() + ''' """ #pylint: disable=C0103,C0413,W0703 import os @@ -65,11 +69,13 @@ class PyRevitConfig(configparser.PyRevitConfigParser): config_type (str): type of config file Examples: - >>> cfg = PyRevitConfig(cfg_file_path) - >>> cfg.add_section('sectionname') - >>> cfg.sectionname.property = value - >>> cfg.sectionname.get_option('property', default_value) - >>> cfg.save_changes() + ''' + cfg = PyRevitConfig(cfg_file_path) + cfg.add_section('sectionname') + cfg.sectionname.property = value + cfg.sectionname.get_option('property', default_value) + cfg.save_changes() + ''' """ def __init__(self, cfg_file_path=None, config_type='Unknown'): From 231901b502f8f577df144b32daa7a4eb634826e3 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 15:44:55 +0200 Subject: [PATCH 02/17] version manager module --- pyrevitlib/pyrevit/versionmgr/__init__.py | 10 ++++++---- pyrevitlib/pyrevit/versionmgr/about.py | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pyrevitlib/pyrevit/versionmgr/__init__.py b/pyrevitlib/pyrevit/versionmgr/__init__.py index 68c4d5052..09372f73f 100644 --- a/pyrevitlib/pyrevit/versionmgr/__init__.py +++ b/pyrevitlib/pyrevit/versionmgr/__init__.py @@ -1,10 +1,12 @@ """Utility functions for managing pyRevit versions. Examples: - >>> from pyrevit import versionmgr - >>> v = versionmgr.get_pyrevit_version() - >>> v.get_formatted() - ... '4.10-beta2' + ''' + from pyrevit import versionmgr + v = versionmgr.get_pyrevit_version() + v.get_formatted() + ''' + '4.10-beta2' """ import os.path as op diff --git a/pyrevitlib/pyrevit/versionmgr/about.py b/pyrevitlib/pyrevit/versionmgr/about.py index f7689dfe9..2ab3a50d8 100644 --- a/pyrevitlib/pyrevit/versionmgr/about.py +++ b/pyrevitlib/pyrevit/versionmgr/about.py @@ -2,12 +2,12 @@ """Utility module for pyRevit project information. Examples: - >>> from pyrevit.versionmgr import about - >>> a = about.get_pyrevit_about() - >>> a.subtitle - ... 'python RAD Environment for Autodesk Revit®' - >>> a.copyright - ... '© 2014-2023 Ehsan Iran-Nejad' + ''' + from pyrevit.versionmgr import about + a = about.get_pyrevit_about() + a.subtitle + ''' + 'python RAD Environment for Autodesk Revit®'a.copyright'© 2014-2023 Ehsan Iran-Nejad' """ from collections import namedtuple From 83cbe81359c78cfbef498b760b033de9900e0ffb Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 15:47:20 +0200 Subject: [PATCH 03/17] unittests module --- pyrevitlib/pyrevit/unittests/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyrevitlib/pyrevit/unittests/__init__.py b/pyrevitlib/pyrevit/unittests/__init__.py index 5a7830606..5154d821f 100644 --- a/pyrevitlib/pyrevit/unittests/__init__.py +++ b/pyrevitlib/pyrevit/unittests/__init__.py @@ -1,4 +1,5 @@ -"""The main pyRevit test is the startup test which is done by launching Revit. +""" +The main pyRevit test is the startup test which is done by launching Revit. This module is created to provide a platform to perform complete tests on different components of pyRevit. @@ -6,6 +7,7 @@ suite to test the full functionality of that module, although only a subset of functions are used during startup and normal operations of pyRevit. +''' from unittest import TestCase class TestWithIndependentOutput(TestCase): def setUp(self): @@ -16,6 +18,7 @@ def tearDown(self): def doCleanups(self): pass +''' """ import warnings From c8ef7fea715dadeea66532568cd67cc29df96b12 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 15:49:23 +0200 Subject: [PATCH 04/17] telemetry module --- pyrevitlib/pyrevit/telemetry/__init__.py | 12 +++++++++--- pyrevitlib/pyrevit/telemetry/record.py | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pyrevitlib/pyrevit/telemetry/__init__.py b/pyrevitlib/pyrevit/telemetry/__init__.py index 5965c8ddd..5c1ccd519 100644 --- a/pyrevitlib/pyrevit/telemetry/__init__.py +++ b/pyrevitlib/pyrevit/telemetry/__init__.py @@ -1,12 +1,18 @@ """This module manages the telemetry system. This function is used to setup the telemetry system on pyRevit startup: ->>> setup_telemetry() + ''' + setup_telemetry() + ''' These functions are used to query information about the logging system: ->>> get_telemetry_state() + ''' + get_telemetry_state() + ''' ->>> get_apptelemetry_state() + ''' + get_apptelemetry_state() + ''' This module also provides a wrapper class around the command results dictionary that is included with the telemetry record. diff --git a/pyrevitlib/pyrevit/telemetry/record.py b/pyrevitlib/pyrevit/telemetry/record.py index f0dedbf00..98bdd850b 100644 --- a/pyrevitlib/pyrevit/telemetry/record.py +++ b/pyrevitlib/pyrevit/telemetry/record.py @@ -13,7 +13,9 @@ class CommandCustomResults(object): to use wrapper around it. Examples: - >>> CommandCustomResults().returnparam = 'some return value' + ''' + CommandCustomResults().returnparam = 'some return value' + ''' """ From 30a39037271303892c9c09351590347e838c3d4b Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 15:53:55 +0200 Subject: [PATCH 05/17] runtime module --- pyrevitlib/pyrevit/runtime/__init__.py | 28 ++++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/pyrevitlib/pyrevit/runtime/__init__.py b/pyrevitlib/pyrevit/runtime/__init__.py index 7c732f7a3..da1cee751 100644 --- a/pyrevitlib/pyrevit/runtime/__init__.py +++ b/pyrevitlib/pyrevit/runtime/__init__.py @@ -408,19 +408,21 @@ def create_type(modulebuilder, type_class, class_name, custom_attr_list, *args): (type): returns created dotnet type Examples: - >>> asm_builder = AppDomain.CurrentDomain.DefineDynamicAssembly( - ... win_asm_name, AssemblyBuilderAccess.RunAndSave, filepath - ... ) - >>> module_builder = asm_builder.DefineDynamicModule( - ... ext_asm_file_name, ext_asm_full_file_name - ... ) - >>> create_type( - ... module_builder, - ... runtime.ScriptCommand, - ... "PyRevitSomeCommandUniqueName", - ... runtime.create_ext_command_attrs(), - ... [scriptpath, atlscriptpath, searchpath, helpurl, name, - ... bundle, extension, uniquename, False, False]) + ''' + asm_builder = AppDomain.CurrentDomain.DefineDynamicAssembly( + win_asm_name, AssemblyBuilderAccess.RunAndSave, filepath + ) + module_builder = asm_builder.DefineDynamicModule( + ext_asm_file_name, ext_asm_full_file_name + ) + create_type( + module_builder, + runtime.ScriptCommand, + "PyRevitSomeCommandUniqueName", + runtime.create_ext_command_attrs(), + [scriptpath, atlscriptpath, searchpath, helpurl, name, + bundle, extension, uniquename, False, False]) + ''' """ # create type builder From a5069aae35211338932a1bf8177add873fee4e40 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 15:57:27 +0200 Subject: [PATCH 06/17] routes module --- pyrevitlib/pyrevit/routes/__init__.py | 14 ++++++++------ pyrevitlib/pyrevit/routes/server/router.py | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pyrevitlib/pyrevit/routes/__init__.py b/pyrevitlib/pyrevit/routes/__init__.py index 44489d61d..0654b2586 100644 --- a/pyrevitlib/pyrevit/routes/__init__.py +++ b/pyrevitlib/pyrevit/routes/__init__.py @@ -12,12 +12,14 @@ class API(object): name (str): URL-safe unique root name of the API Examples: - >>> from pyrevit import routes - >>> api = routes.API("pyrevit-core") - >>> @api.route('/sessions/', methods=['POST']) - >>> def reload_pyrevit(uiapp): - ... new_session_id = sessionmgr.reload_pyrevit() - ... return {"session_id": new_session_id} + ''' + from pyrevit import routes + api = routes.API("pyrevit-core") + @api.route('/sessions/', methods=['POST']) + def reload_pyrevit(uiapp): + new_session_id = sessionmgr.reload_pyrevit() + return {"session_id": new_session_id} + ''' """ def __init__(self, name): self.name = name diff --git a/pyrevitlib/pyrevit/routes/server/router.py b/pyrevitlib/pyrevit/routes/server/router.py index 35be74566..d9b7bac6a 100644 --- a/pyrevitlib/pyrevit/routes/server/router.py +++ b/pyrevitlib/pyrevit/routes/server/router.py @@ -94,8 +94,10 @@ def extract_route_params(route_pattern, request_path): """Extracts route params from request path based on pattern. Examples: - >>> extract_route_params('api/v1/posts/', 'api/v1/posts/12') - ... [] + ''' + extract_route_params('api/v1/posts/', 'api/v1/posts/12') + ''' + [] """ finder_pattern = _make_finder_pattern(route_pattern) route_params = [] @@ -127,7 +129,6 @@ def get_routes(api_name): Args: api_name (str): unique name of the api - Returns: (dict[str, Caller[]]): registered routes From 2fe49ab913f1001e0322405b7181926155774717 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:03:31 +0200 Subject: [PATCH 07/17] output and preflight modules --- pyrevitlib/pyrevit/output/__init__.py | 104 +++++++++++++++---------- pyrevitlib/pyrevit/output/linkmaker.py | 8 +- 2 files changed, 69 insertions(+), 43 deletions(-) diff --git a/pyrevitlib/pyrevit/output/__init__.py b/pyrevitlib/pyrevit/output/__init__.py index ff12e9108..a8e1fb98d 100644 --- a/pyrevitlib/pyrevit/output/__init__.py +++ b/pyrevitlib/pyrevit/output/__init__.py @@ -6,8 +6,10 @@ uses the `pyrevit.output` module to get access to the output wrapper. Examples: - >>> from pyrevit import script - >>> output = script.get_output() + ''' + from pyrevit import script + output = script.get_output() + ''' Here is the source of :func:`pyrevit.script.get_output`. As you can see this functions calls the :func:`pyrevit.output.get_output` to receive the @@ -178,10 +180,12 @@ def inject_to_head(self, element_tag, element_contents, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - >>> output = pyrevit.output.get_output() - >>> output.inject_to_head('script', - '', # no script since it's a link - {'src': js_script_file_path}) + ''' + output = pyrevit.output.get_output() + output.inject_to_head('script', + '', # no script since it's a link + {'src': js_script_file_path}) + ''' """ html_element = self.renderer.Document.CreateElement(element_tag) if element_contents: @@ -206,10 +210,12 @@ def inject_to_body(self, element_tag, element_contents, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - >>> output = pyrevit.output.get_output() - >>> output.inject_to_body('script', - '', # no script since it's a link - {'src': js_script_file_path}) + ''' + output = pyrevit.output.get_output() + output.inject_to_body('script', + '', # no script since it's a link + {'src': js_script_file_path}) + ''' """ html_element = self.renderer.Document.CreateElement(element_tag) if element_contents: @@ -234,9 +240,11 @@ def inject_script(self, script_code, attribs=None, body=False): body (bool, optional): injects script into body instead of head Examples: - >>> output = pyrevit.output.get_output() - >>> output.inject_script('', # no script since it's a link - {'src': js_script_file_path}) + ''' + output = pyrevit.output.get_output() + output.inject_script('', # no script since it's a link + {'src': js_script_file_path}) + ''' """ if body: self.inject_to_body('script', script_code, attribs=attribs) @@ -251,8 +259,10 @@ def add_style(self, style_code, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - >>> output = pyrevit.output.get_output() - >>> output.add_style('body { color: blue; }') + ''' + output = pyrevit.output.get_output() + output.add_style('body { color: blue; }') + ''' """ self.inject_to_head('style', style_code, attribs=attribs) @@ -407,9 +417,11 @@ def update_progress(self, cur_value, max_value): max_value (float): total value e.g. 100 Examples: - >>> output = pyrevit.output.get_output() - >>> for i in range(100): - >>> output.update_progress(i, 100) + ''' + output = pyrevit.output.get_output() + for i in range(100): + output.update_progress(i, 100) + ''' """ if self.window: self.window.UpdateActivityBar(cur_value, max_value) @@ -490,8 +502,10 @@ def print_html(html_str): """Add the html code to the output window. Examples: - >>> output = pyrevit.output.get_output() - >>> output.print_html('Title') + ''' + output = pyrevit.output.get_output() + output.print_html('Title') + ''' """ print(coreutils.prepare_html_str(html_str), end="") @@ -501,8 +515,10 @@ def print_code(code_str): """Print code to the output window with special formatting. Examples: - >>> output = pyrevit.output.get_output() - >>> output.print_code('value = 12') + ''' + output = pyrevit.output.get_output() + output.print_code('value = 12') + ''' """ code_div = '
{}
' print( @@ -519,8 +535,10 @@ def print_md(md_str): """Process markdown code and print to output window. Examples: - >>> output = pyrevit.output.get_output() - >>> output.print_md('### Title') + ''' + output = pyrevit.output.get_output() + output.print_md('### Title') + ''' """ tables_ext = 'pyrevit.coreutils.markdown.extensions.tables' markdown_html = markdown.markdown(md_str, extensions=[tables_ext]) @@ -540,17 +558,19 @@ def print_table(self, table_data, columns=None, formats=None, last_line_style (str): css style of last row Examples: - >>> data = [ - ... ['row1', 'data', 'data', 80 ], - ... ['row2', 'data', 'data', 45 ], - ... ] - >>> output.print_table( - ... table_data=data, - ... title="Example Table", - ... columns=["Row Name", "Column 1", "Column 2", "Percentage"], - ... formats=['', '', '', '{}%'], - ... last_line_style='color:red;' - ... ) + ''' + data = [ + ['row1', 'data', 'data', 80 ], + ['row2', 'data', 'data', 45 ], + ] + output.print_table( + table_data=data, + title="Example Table", + columns=["Row Name", "Column 1", "Column 2", "Percentage"], + formats=['', '', '', '{}%'], + last_line_style='color:red;' + ) + ''' """ if not columns: columns = [] @@ -604,8 +624,10 @@ def print_image(self, image_path): r"""Prints given image to the output. Examples: - >>> output = pyrevit.output.get_output() - >>> output.print_image(r'C:\image.gif') + ''' + output = pyrevit.output.get_output() + output.print_image(r'C:\image.gif') + ''' """ self.print_html( "".format( @@ -640,9 +662,11 @@ def linkify(element_ids, title=None): (str): clickable link Examples: - >>> output = pyrevit.output.get_output() - >>> for idx, elid in enumerate(element_ids): - >>> print('{}: {}'.format(idx+1, output.linkify(elid))) + ''' + output = pyrevit.output.get_output() + for idx, elid in enumerate(element_ids): + print('{}: {}'.format(idx+1, output.linkify(elid))) + '''00 """ return coreutils.prepare_html_str( linkmaker.make_link(element_ids, contents=title) diff --git a/pyrevitlib/pyrevit/output/linkmaker.py b/pyrevitlib/pyrevit/output/linkmaker.py index 3d4adea4c..cda0b6737 100644 --- a/pyrevitlib/pyrevit/output/linkmaker.py +++ b/pyrevitlib/pyrevit/output/linkmaker.py @@ -42,9 +42,11 @@ def make_link(element_ids, contents=None): method. Examples: - >>> output = pyrevit.output.get_output() - >>> for idx, elid in enumerate(element_ids): - >>> print('{}: {}'.format(idx+1, output.linkify(elid))) + ''' + output = pyrevit.output.get_output() + for idx, elid in enumerate(element_ids): + print('{}: {}'.format(idx+1, output.linkify(elid))) + ''' """ try: try: From 4a6e49f177a0e78e7bee0787e0cd85a7493c674b Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:07:39 +0200 Subject: [PATCH 08/17] loader module --- pyrevitlib/pyrevit/loader/sessioninfo.py | 4 +++- pyrevitlib/pyrevit/loader/sessionmgr.py | 14 +++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pyrevitlib/pyrevit/loader/sessioninfo.py b/pyrevitlib/pyrevit/loader/sessioninfo.py index 13769d0a8..22d7e177e 100644 --- a/pyrevitlib/pyrevit/loader/sessioninfo.py +++ b/pyrevitlib/pyrevit/loader/sessioninfo.py @@ -79,7 +79,9 @@ def get_runtime_info(): (RuntimeInfo): runtime info tuple Examples: - >>> sessioninfo.get_runtime_info() + ''' + sessioninfo.get_runtime_info() + ''' """ # FIXME: add example output return RuntimeInfo( diff --git a/pyrevitlib/pyrevit/loader/sessionmgr.py b/pyrevitlib/pyrevit/loader/sessionmgr.py index cbd70be69..7e24a15c3 100644 --- a/pyrevitlib/pyrevit/loader/sessionmgr.py +++ b/pyrevitlib/pyrevit/loader/sessionmgr.py @@ -255,8 +255,10 @@ def load_session(): through interactions with .extensions, .loader.asmmaker, and .loader.uimaker. Examples: - >>> from pyrevit.loader.sessionmgr import load_session - >>> load_session() # start loading a new pyRevit session + ''' + from pyrevit.loader.sessionmgr import load_session + load_session() # start loading a new pyRevit session + ''' Returns: (str): sesion uuid @@ -470,9 +472,11 @@ def find_pyrevitcmd(pyrevitcmd_unique_id): instantiated before use. Examples: - >>> cmd = find_pyrevitcmd('pyRevitCorepyRevitpyRevittoolsReload') - >>> command_instance = cmd() - >>> command_instance.Execute() # Provide commandData, message, elements + ''' + cmd = find_pyrevitcmd('pyRevitCorepyRevitpyRevittoolsReload') + command_instance = cmd() + command_instance.Execute() # Provide commandData, message, elements + ''' Args: pyrevitcmd_unique_id (str): Unique name for the command From e803dba8dcb824129ad42fbe988f6aa3b7adeabe Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:09:12 +0200 Subject: [PATCH 09/17] interop module From 1a0e665363c62a69d14026ac3f76b9a927d84e94 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:14:01 +0200 Subject: [PATCH 10/17] extensions module --- pyrevitlib/pyrevit/extensions/parser.py | 2 ++ pyrevitlib/pyrevit/interop/xl.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pyrevitlib/pyrevit/extensions/parser.py b/pyrevitlib/pyrevit/extensions/parser.py index a2e0d2872..116d5831b 100644 --- a/pyrevitlib/pyrevit/extensions/parser.py +++ b/pyrevitlib/pyrevit/extensions/parser.py @@ -39,8 +39,10 @@ def _create_subcomponents(search_dir, create_from_search_dir (bool, optional): whether to create the _get_component objects, default to False Examples: + '''python _create_subcomponents(search_dir, [LinkButton, PushButton, or ToggleButton]) + ''' this method creates LinkButton, PushButton, or ToggleButton for the parsed sub-directories under search_dir with matching .type_id identifiers in their names. (e.g. "folder.LINK_BUTTON_POSTFIX") diff --git a/pyrevitlib/pyrevit/interop/xl.py b/pyrevitlib/pyrevit/interop/xl.py index f222c30f6..68a91ff90 100644 --- a/pyrevitlib/pyrevit/interop/xl.py +++ b/pyrevitlib/pyrevit/interop/xl.py @@ -1,4 +1,4 @@ -"""Read and Write Excel Files.""" +0"""Read and Write Excel Files.""" #pylint: disable=import-error import xlrd import xlsxwriter From 1e66ba5cb57803eb50c92ecc355e3caadb25cdfc Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:27:27 +0200 Subject: [PATCH 11/17] coreutils init.py --- pyrevitlib/pyrevit/coreutils/__init__.py | 172 ++++++++++++++++------- 1 file changed, 123 insertions(+), 49 deletions(-) diff --git a/pyrevitlib/pyrevit/coreutils/__init__.py b/pyrevitlib/pyrevit/coreutils/__init__.py index b6b6ac468..f34f77da1 100644 --- a/pyrevitlib/pyrevit/coreutils/__init__.py +++ b/pyrevitlib/pyrevit/coreutils/__init__.py @@ -1,8 +1,10 @@ """Misc Helper functions for pyRevit. Examples: - >>> from pyrevit import coreutils - >>> coreutils.cleanup_string('some string') + '''python + from pyrevit import coreutils + coreutils.cleanup_string('some string') + ''' """ #pylint: disable=invalid-name import os @@ -79,10 +81,14 @@ class ScriptFileParser(object): but can work for any python script. Examples: - >>> finder = ScriptFileParser('/path/to/coreutils/__init__.py') - >>> finder.docstring() - ... "Misc Helper functions for pyRevit." - >>> finder.extract_param('SomeValue', []) + '''python + finder = ScriptFileParser('/path/to/coreutils/__init__.py') + finder.docstring() + ''' + "Misc Helper functions for pyRevit." + '''python + finder.extract_param('SomeValue', []) + ''' [] """ @@ -160,8 +166,10 @@ class FileWatcher(object): its timestamp. Examples: - >>> watcher = FileWatcher('/path/to/file.ext') - >>> watcher.has_changed + ''' + watcher = FileWatcher('/path/to/file.ext') + watcher.has_changed + ''' True """ @@ -192,10 +200,12 @@ class SafeDict(dict): key values. Examples: - >>> string = '{target} {attr} is {color}.' - >>> safedict = SafeDict({'target': 'Apple', - ... 'attr': 'Color'}) - >>> string.format(safedict) # will not fail with missing 'color' key + '''python + string = '{target} {attr} is {color}.' + safedict = SafeDict({'target': 'Apple', + 'attr': 'Color'}) + string.format(safedict) # will not fail with missing 'color' key + ''' 'Apple Color is {color}.' """ @@ -319,8 +329,10 @@ def cleanup_string(input_str, skip=None): skip (Container[str]): special characters to keep Examples: - >>> src_str = 'TEST@Some*' - >>> cleanup_string(src_str) + '''python + src_str = 'TEST@Some*' + cleanup_string(src_str) + ''' "TESTATSomeSTARvalue" """ # remove spaces and special characters from strings @@ -349,7 +361,9 @@ def run_process(proc, cwd='C:'): cwd (str): current working directory Exmaple: - >>> run_process('notepad.exe', 'c:/') + '''python + run_process('notepad.exe', 'c:/') + ''' """ import subprocess return subprocess.Popen(proc, @@ -403,7 +417,9 @@ def make_canonical_name(*args): (str): dot separated unique name Examples: - >>> make_canonical_name('somename', 'someid', 'txt') + '''python + make_canonical_name('somename', 'someid', 'txt') + ''' "somename.someid.txt" """ return '.'.join(args) @@ -419,7 +435,9 @@ def get_canonical_parts(canonical_string): (list[str]): list of composing parts Examples: - >>> get_canonical_parts("Config.SubConfig") + '''python + get_canonical_parts("Config.SubConfig") + ''' ['Config', 'SubConfig'] """ return canonical_string.split('.') @@ -460,7 +478,9 @@ def calculate_dir_hash(dir_path, dir_filter, file_filter): (str): hash value as string Examples: - >>> calculate_dir_hash(source_path, '\.extension', '\.json') + '''python + calculate_dir_hash(source_path, '\.extension', '\.json') + ''' "1a885a0cae99f53d6088b9f7cee3bf4d" """ mtime_sum = 0 @@ -488,7 +508,9 @@ def prepare_html_str(input_string): input_string (str): input html string Examples: - >>> prepare_html_str('

Some text

') + '''python + prepare_html_str('

Some text

') + ''' "&clt;p&cgt;Some text&clt;/p&cgt;" """ return input_string.replace('<', '&clt;').replace('>', '&cgt;') @@ -508,7 +530,9 @@ def reverse_html(input_html): input_html (str): input codified html string Examples: - >>> prepare_html_str('&clt;p&cgt;Some text&clt;/p&cgt;') + '''python + prepare_html_str('&clt;p&cgt;Some text&clt;/p&cgt;') + ''' "

Some text

" """ return input_html.replace('&clt;', '<').replace('&cgt;', '>') @@ -666,10 +690,14 @@ def cleanup_filename(file_name, windows_safe=False): (str): cleaned up file name Examples: - >>> cleanup_filename('Myfile-(3).txt') + '''python + cleanup_filename('Myfile-(3).txt') + ''' "Myfile(3).txt" - >>> cleanup_filename('Perforations 1/8" (New)') + '''python + cleanup_filename('Perforations 1/8" (New)') + ''' "Perforations 18 (New).txt" """ if windows_safe: @@ -691,7 +719,9 @@ def _inc_or_dec_string(str_id, shift, refit=False, logger=None): (str): modified identifier Examples: - >>> _inc_or_dec_string('A319z') + '''python + _inc_or_dec_string('A319z') + ''' 'A320a' """ # if no shift, return given string @@ -793,7 +823,9 @@ def increment_str(input_str, step=1, expand=False): (str): modified identifier Examples: - >>> increment_str('A319z') + '''python + increment_str('A319z') + ''' 'A320a' """ return _inc_or_dec_string(input_str, abs(step), refit=expand) @@ -811,7 +843,9 @@ def decrement_str(input_str, step=1, shrink=False): (str): modified identifier Examples: - >>> decrement_str('A310a') + '''python + decrement_str('A310a') + ''' 'A309z' """ return _inc_or_dec_string(input_str, -abs(step), refit=shrink) @@ -829,9 +863,13 @@ def extend_counter(input_str, upper=True, use_zero=False): (str): extended identifier Examples: - >>> extend_counter('A310') + '''python + extend_counter('A310') + ''' 'A310A' - >>> extend_counter('A310A', use_zero=True) + '''python + extend_counter('A310A', use_zero=True) + ''' 'A310A0' """ if input_str[-1].isdigit(): @@ -862,7 +900,9 @@ def reverse_dict(input_dict): (defaultdict): reversed dictionary Examples: - >>> reverse_dict({1: 2, 3: 4}) + '''python + reverse_dict({1: 2, 3: 4}) + ''' defaultdict(, {2: [1], 4: [3]}) """ output_dict = defaultdict(list) @@ -878,7 +918,9 @@ def timestamp(): (str): timestamp in string format Examples: - >>> timestamp() + '''python + timestamp() + ''' '01003075032506808' """ return datetime.datetime.now().strftime("%m%j%H%M%S%f") @@ -893,7 +935,9 @@ def current_time(): (str): formatted current time. Examples: - >>> current_time() + '''python + current_time() + ''' '07:50:53' """ return datetime.datetime.now().strftime("%H:%M:%S") @@ -908,7 +952,9 @@ def current_date(): (str): formatted current date. Examples: - >>> current_date() + '''python + current_date() + ''' '2018-01-03' """ return datetime.datetime.now().strftime("%Y-%m-%d") @@ -924,7 +970,9 @@ def is_blank(input_string): (bool): True if string is blank Examples: - >>> is_blank(' ') + '''python + is_blank(' ') + ''' True """ if input_string and input_string.strip(): @@ -942,7 +990,9 @@ def is_url_valid(url_string): (bool): True if URL is in valid format Examples: - >>> is_url_valid('https://www.google.com') + '''python + is_url_valid('https://www.google.com') + ''' True """ regex = re.compile( @@ -972,9 +1022,11 @@ def reformat_string(orig_str, orig_format, new_format): (str): Reformatted string Examples: - >>> reformat_string('150 - FLOOR/CEILING - WD - 1 HR - FLOOR ASSEMBLY', + '''python + reformat_string('150 - FLOOR/CEILING - WD - 1 HR - FLOOR ASSEMBLY', '{section} - {loc} - {mat} - {rating} - {name}', '{section}:{mat}:{rating} - {name} ({loc})')) + ''' '150:WD:1 HR - FLOOR ASSEMBLY (FLOOR/CEILING)' """ # find the tags @@ -1019,8 +1071,10 @@ def dletter_to_unc(dletter_path): (str): UNC path Examples: - >>> # assuming J: is mapped to //filestore/server/jdrive - >>> dletter_to_unc('J:/somefile.txt') + '''python + # assuming J: is mapped to //filestore/server/jdrive + dletter_to_unc('J:/somefile.txt') + ''' '//filestore/server/jdrive/somefile.txt' """ drives = get_mapped_drives_dict() @@ -1040,8 +1094,10 @@ def unc_to_dletter(unc_path): (str): drive letter path Examples: - >>> # assuming J: is mapped to //filestore/server/jdrive - >>> unc_to_dletter('//filestore/server/jdrive/somefile.txt') + '''python + # assuming J: is mapped to //filestore/server/jdrive + unc_to_dletter('//filestore/server/jdrive/somefile.txt') + ''' 'J:/somefile.txt' """ drives = get_mapped_drives_dict() @@ -1064,7 +1120,9 @@ def random_hex_color(): """Return a random color in hex format. Examples: - >>> random_hex_color() + '''python + random_hex_color() + ''' '#FF0000' """ return '#%02X%02X%02X' % (random_color(), @@ -1076,7 +1134,9 @@ def random_rgb_color(): """Return a random color in rgb format. Examples: - >>> random_rgb_color() + '''python + random_rgb_color() + ''' 'rgb(255, 0, 0)' """ return 'rgb(%d, %d, %d)' % (random_color(), @@ -1088,7 +1148,9 @@ def random_rgba_color(): """Return a random color in rgba format. Examples: - >>> random_rgba_color() + '''python + random_rgba_color() + ''' 'rgba(255, 0, 0, 0.5)' """ return 'rgba(%d, %d, %d, %.2f)' % (random_color(), @@ -1115,11 +1177,17 @@ def extract_range(formatted_str, max_range=500): (list[str]): names in the specified range Examples: - >>> exract_range('A103:A106') + '''python + exract_range('A103:A106') + ''' ['A103', 'A104', 'A105', 'A106'] - >>> exract_range('S203-S206') + '''python + exract_range('S203-S206') + ''' ['S203', 'S204', 'S205', 'S206'] - >>> exract_range('M00A,M00B') + '''python + exract_range('M00A,M00B') + ''' ['M00A', 'M00B'] """ for rchar, rchartype in {'::': 'range', '--': 'range', @@ -1340,8 +1408,10 @@ def get_reg_key(key, subkey): (PyHKEY): registry key if found, None if not found Examples: - >>> get_reg_key(wr.HKEY_CURRENT_USER, 'Control Panel/International') - ... + '''python + get_reg_key(wr.HKEY_CURRENT_USER, 'Control Panel/International') + ''' + """ try: return wr.OpenKey(key, subkey, 0, wr.KEY_READ) @@ -1356,7 +1426,9 @@ def kill_tasks(task_name): task_name (str): task name Examples: - >>> kill_tasks('Revit.exe') + '''python + kill_tasks('Revit.exe') + ''' """ os.system("taskkill /f /im %s" % task_name) @@ -1384,8 +1456,10 @@ def split_words(input_string): (list[str]): split string Examples: - >>> split_words("UIApplication_ApplicationClosing") - ... ['UIApplication', 'Application', 'Closing'] + '''python + split_words("UIApplication_ApplicationClosing") + ''' + ['UIApplication', 'Application', 'Closing'] """ parts = [] part = "" From 42c915f7e18676592a7237e6092f10bb83336048 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:30:44 +0200 Subject: [PATCH 12/17] app data applocales charts modules --- pyrevitlib/pyrevit/coreutils/appdata.py | 6 ++++-- pyrevitlib/pyrevit/coreutils/applocales.py | 12 +++++++----- pyrevitlib/pyrevit/coreutils/charts.py | 12 +++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pyrevitlib/pyrevit/coreutils/appdata.py b/pyrevitlib/pyrevit/coreutils/appdata.py index 47a2c1bb8..15c41ad05 100644 --- a/pyrevitlib/pyrevit/coreutils/appdata.py +++ b/pyrevitlib/pyrevit/coreutils/appdata.py @@ -5,8 +5,10 @@ the necessary and consistent mechanism for creating and maintaining such files. Examples: - >>> from pyrevit.coreutils import appdata - >>> appdata.list_data_files() + '''python + from pyrevit.coreutils import appdata + appdata.list_data_files() + ''' """ import os diff --git a/pyrevitlib/pyrevit/coreutils/applocales.py b/pyrevitlib/pyrevit/coreutils/applocales.py index c8c8419a6..787c4fef8 100644 --- a/pyrevitlib/pyrevit/coreutils/applocales.py +++ b/pyrevitlib/pyrevit/coreutils/applocales.py @@ -220,11 +220,13 @@ def get_locale_string(string_dict): (str): string in correct locale Examples: - >>> data = {"en_us":"Hello", "chinese_s":"你好"} - >>> from pyrevit.coreutils import applocales - >>> # assuming running Revit is Chinese - >>> applocales.get_locale_string(data) - ... "你好" + '''python + data = {"en_us":"Hello", "chinese_s":"你好"} + from pyrevit.coreutils import applocales + # assuming running Revit is Chinese + applocales.get_locale_string(data) + ''' + "你好" """ applocale = get_applocale_by_local_code(user_config.user_locale) if applocale: diff --git a/pyrevitlib/pyrevit/coreutils/charts.py b/pyrevitlib/pyrevit/coreutils/charts.py index 04510fbdb..fccd1b274 100644 --- a/pyrevitlib/pyrevit/coreutils/charts.py +++ b/pyrevitlib/pyrevit/coreutils/charts.py @@ -56,7 +56,9 @@ def set_color(self, *args): Arguments are expected to be R, G, B, A values. Examples: - >>> dataset_obj.set_color(0xFF, 0x8C, 0x8D, 0.8) + '''python + dataset_obj.set_color(0xFF, 0x8C, 0x8D, 0.8) + ''' """ if len(args) == 4: self.backgroundColor = 'rgba({},{},{},{})'.format(args[0], @@ -83,7 +85,9 @@ def new_dataset(self, dataset_label): (PyRevitOutputChartDataset): dataset wrapper object Examples: - >>> chart.data.new_dataset('set_a') + '''python + chart.data.new_dataset('set_a') + ''' """ new_dataset = PyRevitOutputChartDataset(dataset_label) self.datasets.append(new_dataset) @@ -211,7 +215,9 @@ def set_style(self, html_style): html_style (str): inline html css styling string Examples: - >>> chart.set_style('height:150px') + '''python + chart.set_style('height:150px') + ''' """ self._style = html_style From 1bd4f779f492cc2528c92e0be35150b7987103fd Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:39:23 +0200 Subject: [PATCH 13/17] coreutils module minus markdown --- pyrevitlib/pyrevit/coreutils/colors.py | 14 ++++--- pyrevitlib/pyrevit/coreutils/envvars.py | 16 ++++--- pyrevitlib/pyrevit/coreutils/logger.py | 6 ++- pyrevitlib/pyrevit/coreutils/mathnet.py | 4 +- pyrevitlib/pyrevit/coreutils/pyutils.py | 56 +++++++++++++++---------- pyrevitlib/pyrevit/coreutils/ribbon.py | 8 ++-- 6 files changed, 67 insertions(+), 37 deletions(-) diff --git a/pyrevitlib/pyrevit/coreutils/colors.py b/pyrevitlib/pyrevit/coreutils/colors.py index 68d2e3e99..4fc59ffbb 100644 --- a/pyrevitlib/pyrevit/coreutils/colors.py +++ b/pyrevitlib/pyrevit/coreutils/colors.py @@ -5,11 +5,15 @@ elements formatted: COLORS[colorname] = CONSTANT. Examples: - >>> from pyrevit.coreutils import colors - >>> colors.COLORS['black'] - ... - >>> colors.BLACK - ... + '''python + from pyrevit.coreutils import colors + colors.COLORS['black'] + ''' + + '''python + colors.BLACK + ''' + """ from collections import OrderedDict diff --git a/pyrevitlib/pyrevit/coreutils/envvars.py b/pyrevitlib/pyrevit/coreutils/envvars.py index 139978f69..c35a66609 100644 --- a/pyrevitlib/pyrevit/coreutils/envvars.py +++ b/pyrevitlib/pyrevit/coreutils/envvars.py @@ -19,16 +19,22 @@ scripts is strongly prohibited. Examples: - >>> from pyrevit.coreutils import envvars - >>> envvars.set_pyrevit_env_var('MY_SCRIPT_STATUS', True) - >>> envvars.set_pyrevit_env_var('MY_SCRIPT_CONFIG', {'someconfig': True}) + '''python + from pyrevit.coreutils import envvars + envvars.set_pyrevit_env_var('MY_SCRIPT_STATUS', True) + envvars.set_pyrevit_env_var('MY_SCRIPT_CONFIG', {'someconfig': True}) + ''' Then another script or same script when executed later within the same session can query the shared environment variable: - >>> envvars.get_pyrevit_env_vars('MY_SCRIPT_STATUS') + '''python + envvars.get_pyrevit_env_vars('MY_SCRIPT_STATUS') + ''' True - >>> envvars.get_pyrevit_env_vars('MY_SCRIPT_CONFIG') + '''python + envvars.get_pyrevit_env_vars('MY_SCRIPT_CONFIG') + ''' {'someconfig': True} """ diff --git a/pyrevitlib/pyrevit/coreutils/logger.py b/pyrevitlib/pyrevit/coreutils/logger.py index dd952ea38..71f96cfe2 100644 --- a/pyrevitlib/pyrevit/coreutils/logger.py +++ b/pyrevitlib/pyrevit/coreutils/logger.py @@ -337,8 +337,10 @@ def get_logger(logger_name): (LoggerWrapper): logger object wrapper python's native logger Examples: - >>> get_logger('my command') - ... + '''python + get_logger('my command') + ''' + """ if loggers.get(logger_name): return loggers.get(logger_name) diff --git a/pyrevitlib/pyrevit/coreutils/mathnet.py b/pyrevitlib/pyrevit/coreutils/mathnet.py index b1a1e90cc..3eaad4de6 100644 --- a/pyrevitlib/pyrevit/coreutils/mathnet.py +++ b/pyrevitlib/pyrevit/coreutils/mathnet.py @@ -3,7 +3,9 @@ See https://www.mathdotnet.com for documentation. Examples: - >>> from pyrevit.coreutils.mathnet import MathNet + '''python + from pyrevit.coreutils.mathnet import MathNet + ''' """ #pylint: disable=W0703,C0302,C0103 from pyrevit import EXEC_PARAMS diff --git a/pyrevitlib/pyrevit/coreutils/pyutils.py b/pyrevitlib/pyrevit/coreutils/pyutils.py index 69d8ce0ed..aa06c31c2 100644 --- a/pyrevitlib/pyrevit/coreutils/pyutils.py +++ b/pyrevitlib/pyrevit/coreutils/pyutils.py @@ -22,13 +22,15 @@ class DefaultOrderedDict(OrderedDict): to it so in that regards it functions similar to OrderedDict. Examples: - >>> from pyrevit.coreutils import pyutils - >>> od = pyutils.DefaultOrderedDict(list) - >>> od['A'] = [1, 2, 3] - >>> od['B'] = [4, 5, 6] - >>> od['C'].extend([7, 8, 9]) - >>> for k, v in od.items(): - ... print(k, v) + '''python + from pyrevit.coreutils import pyutils + od = pyutils.DefaultOrderedDict(list) + od['A'] = [1, 2, 3] + od['B'] = [4, 5, 6] + od['C'].extend([7, 8, 9]) + for k, v in od.items(): + print(k, v) + ''' ('A', [1, 2, 3]) ('B', [4, 5, 6]) ('C', [7, 8, 9]) @@ -89,11 +91,17 @@ def pairwise(iterable, step=2): (Iterable[Any]): list of pairs Examples: - >>> pairwise([1, 2, 3, 4, 5]) + '''python + pairwise([1, 2, 3, 4, 5]) + ''' [(1, 2), (3, 4)] # 5 can not be paired - >>> pairwise([1, 2, 3, 4, 5, 6]) + '''python + pairwise([1, 2, 3, 4, 5, 6]) + ''' [(1, 2), (3, 4), (5, 6)] - >>> pairwise([1, 2, 3, 4, 5, 6], step=1) + '''python + pairwise([1, 2, 3, 4, 5, 6], step=1) + ''' [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)] """ if step == 1: @@ -117,7 +125,9 @@ def safe_cast(val, to_type, default=None): default (any): value to rerun on conversion exception Examples: - >>> safe_cast('name', int, default=0) + '''python + safe_cast('name', int, default=0) + ''' 0 """ try: @@ -136,7 +146,9 @@ def isnumber(token): (bool): True of token is int or float Examples: - >>> isnumber('12.3') + '''python + isnumber('12.3') + ''' True """ if token: @@ -173,15 +185,17 @@ def merge(d1, d2): (dict[Any, Any]): updated d1 Examples: - >>> d1 = {1: 1, 2: "B" , 3: {1:"A", 2:"B"}, 4: "b" , 5: ["a", "b"]} - >>> d2 = {1: 1, 2: {1:"A"}, 3: {1:"S", 3:"C"}, 4: ["a"], 5: ["c"]} - >>> merge(d1, d2) - ... { 1:1, - ... 2:{1:'A', 2:'B'}, - ... 3:{1:'S', 2:'B', 3:'C'}, - ... 4:['a','b'], - ... 5: ['c', 'a', 'b'] - ... } + '''python + d1 = {1: 1, 2: "B" , 3: {1:"A", 2:"B"}, 4: "b" , 5: ["a", "b"]} + d2 = {1: 1, 2: {1:"A"}, 3: {1:"S", 3:"C"}, 4: ["a"], 5: ["c"]} + merge(d1, d2) + ''' + { 1:1, + 2:{1:'A', 2:'B'}, + 3:{1:'S', 2:'B', 3:'C'}, + 4:['a','b'], + 5: ['c', 'a', 'b'] + } """ if not (isinstance(d1, dict) and isinstance(d2, dict)): raise Exception('Both inputs must be of type dict') diff --git a/pyrevitlib/pyrevit/coreutils/ribbon.py b/pyrevitlib/pyrevit/coreutils/ribbon.py index c12ed7685..84e7acc69 100644 --- a/pyrevitlib/pyrevit/coreutils/ribbon.py +++ b/pyrevitlib/pyrevit/coreutils/ribbon.py @@ -1691,9 +1691,11 @@ def get_current_ui(all_native=False): Returned class provides min required functionality for user interaction Examples: - >>> current_ui = pyrevit.session.current_ui() - >>> this_script = pyrevit.session.get_this_command() - >>> current_ui.update_button_icon(this_script, new_icon) + '''python + current_ui = pyrevit.session.current_ui() + this_script = pyrevit.session.get_this_command() + current_ui.update_button_icon(this_script, new_icon) + ''' Returns: (_PyRevitUI): wrapper around active ribbon gui From 465a0136e3e3b4ba2e6aa05f02df8ca07f43b80e Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 16:42:52 +0200 Subject: [PATCH 14/17] markdown From 32f5fd538753015203056b18c495d21ef3b405a5 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 22:01:21 +0200 Subject: [PATCH 15/17] db module --- pyrevitlib/pyrevit/revit/db/transaction.py | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/pyrevitlib/pyrevit/revit/db/transaction.py b/pyrevitlib/pyrevit/revit/db/transaction.py index db391c613..38642cf84 100644 --- a/pyrevitlib/pyrevit/revit/db/transaction.py +++ b/pyrevitlib/pyrevit/revit/db/transaction.py @@ -23,13 +23,15 @@ class Transaction(): before and after the context. Automatically rolls back if exception is raised. - >>> with Transaction('Move Wall'): - >>> wall.DoSomething() - - >>> with Transaction('Move Wall') as action: - >>> wall.DoSomething() - >>> assert action.status == ActionStatus.Started # True - >>> assert action.status == ActionStatus.Committed # True + '''python + with Transaction('Move Wall'): + wall.DoSomething() + + with Transaction('Move Wall') as action: + wall.DoSomething() + assert action.status == ActionStatus.Started # True + assert action.status == ActionStatus.Committed # True + ''' """ def __init__(self, name=None, doc=None, @@ -165,11 +167,14 @@ def carryout(name, doc=None): name (str): Name of the Transaction doc (Document): Revit document - >>> @doc.carryout('Do Something') - >>> def set_some_parameter(wall, value): - >>> wall.parameters['Comments'].value = value - >>> - >>> set_some_parameter(wall, value) + '''python + @doc.carryout('Do Something') + def set_some_parameter(wall, value): + wall.parameters['Comments'].value = value + + + set_some_parameter(wall, value) + ''' """ from functools import wraps From 159f2d7944c778ac350670f2c2511260426057e7 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 22:06:07 +0200 Subject: [PATCH 16/17] revit module --- pyrevitlib/pyrevit/revit/__init__.py | 12 +++++++----- pyrevitlib/pyrevit/revit/serverutils.py | 16 ++++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pyrevitlib/pyrevit/revit/__init__.py b/pyrevitlib/pyrevit/revit/__init__.py index a290cfef3..a466c1fd6 100644 --- a/pyrevitlib/pyrevit/revit/__init__.py +++ b/pyrevitlib/pyrevit/revit/__init__.py @@ -138,11 +138,13 @@ class ErrorSwallower(): """Suppresses warnings during script execution. Examples: - >>> with ErrorSwallower() as swallower: - >>> for fam in families: - >>> revit.doc.EditFamily(fam) - >>> if swallower.get_swallowed(): - >>> logger.warn("Warnings swallowed") + '''python + with ErrorSwallower() as swallower: + for fam in families: + revit.doc.EditFamily(fam) + if swallower.get_swallowed(): + logger.warn("Warnings swallowed") + ''' """ def __init__(self, log_errors=True): diff --git a/pyrevitlib/pyrevit/revit/serverutils.py b/pyrevitlib/pyrevit/revit/serverutils.py index 127381757..d730fda21 100644 --- a/pyrevitlib/pyrevit/revit/serverutils.py +++ b/pyrevitlib/pyrevit/revit/serverutils.py @@ -29,9 +29,11 @@ def get_server_path(doc, path_dict): path_dict (dict): dict of RSN paths and their directory paths Examples: - >>> rsn_paths = {'RSN://SERVERNAME': '//servername/filestore'} - >>> get_server_path(doc, rsn_paths) - ... "//servername/filestore/path/to/model.rvt" + '''python + rsn_paths = {'RSN://SERVERNAME': '//servername/filestore'} + get_server_path(doc, rsn_paths) + ''' + "//servername/filestore/path/to/model.rvt" """ model_path = doc.GetWorksharingCentralModelPath() path = DB.ModelPathUtils.ConvertModelPathToUserVisiblePath(model_path) @@ -51,9 +53,11 @@ def get_model_sync_history(server_path): (list[SyncHistory]): list of SyncHistory instances Examples: - >>> get_model_sync_history("//servername/path/to/model.rvt") - ... [SyncHistory(index=498, userid="user", - ... timestamp="2017-12-13 19:56:20")] + '''python + get_model_sync_history("//servername/path/to/model.rvt") + ''' + [SyncHistory(index=498, userid="user", + timestamp="2017-12-13 19:56:20")] """ db_path = server_path + MODEL_HISTORY_SQLDB conn = sqlite3.connect(db_path) From a71cade262a3df4d0f850b91cb8843022d2fda07 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 22:14:29 +0200 Subject: [PATCH 17/17] touch up --- pyrevitlib/pyrevit/__init__.py | 4 ++-- pyrevitlib/pyrevit/api.py | 2 +- pyrevitlib/pyrevit/compat.py | 2 +- pyrevitlib/pyrevit/framework.py | 2 +- pyrevitlib/pyrevit/loader/sessioninfo.py | 2 +- pyrevitlib/pyrevit/loader/sessionmgr.py | 4 ++-- pyrevitlib/pyrevit/output/__init__.py | 26 +++++++++++----------- pyrevitlib/pyrevit/output/linkmaker.py | 2 +- pyrevitlib/pyrevit/routes/__init__.py | 2 +- pyrevitlib/pyrevit/routes/server/router.py | 2 +- pyrevitlib/pyrevit/runtime/__init__.py | 2 +- pyrevitlib/pyrevit/script.py | 26 +++++++++++----------- pyrevitlib/pyrevit/telemetry/__init__.py | 6 ++--- pyrevitlib/pyrevit/telemetry/record.py | 2 +- pyrevitlib/pyrevit/unittests/__init__.py | 2 +- pyrevitlib/pyrevit/userconfig.py | 6 ++--- pyrevitlib/pyrevit/versionmgr/__init__.py | 2 +- pyrevitlib/pyrevit/versionmgr/about.py | 2 +- 18 files changed, 48 insertions(+), 48 deletions(-) diff --git a/pyrevitlib/pyrevit/__init__.py b/pyrevitlib/pyrevit/__init__.py index 3acbceac5..8b4bd2cd1 100644 --- a/pyrevitlib/pyrevit/__init__.py +++ b/pyrevitlib/pyrevit/__init__.py @@ -1,7 +1,7 @@ """pyRevit root level config for all pyrevit sub-modules. Examples: - ''' + '''python from pyrevit import DB, UI from pyrevit import PyRevitException, PyRevitIOError @@ -182,7 +182,7 @@ class _HostApplication(object): postable commands, and other functionality. Examples: - ''' + '''python hostapp = _HostApplication() hostapp.is_newer_than(2017) ''' diff --git a/pyrevitlib/pyrevit/api.py b/pyrevitlib/pyrevit/api.py index a60adca6b..ce86185b9 100644 --- a/pyrevitlib/pyrevit/api.py +++ b/pyrevitlib/pyrevit/api.py @@ -1,7 +1,7 @@ """Provide access to Revit API. Examples: - ''' + '''python from pyrevit.api import AdWindows ''' """ diff --git a/pyrevitlib/pyrevit/compat.py b/pyrevitlib/pyrevit/compat.py index c42e13e0e..053f4908e 100644 --- a/pyrevitlib/pyrevit/compat.py +++ b/pyrevitlib/pyrevit/compat.py @@ -1,7 +1,7 @@ """python engine compatibility module. Examples: - ''' + '''python from pyrevit.compat import IRONPY277 from pyrevit.compat import safe_strtype ''' diff --git a/pyrevitlib/pyrevit/framework.py b/pyrevitlib/pyrevit/framework.py index c7a928b62..e16122f12 100644 --- a/pyrevitlib/pyrevit/framework.py +++ b/pyrevitlib/pyrevit/framework.py @@ -1,7 +1,7 @@ """Provide access to DotNet Framework. Examples: - ''' + '''python from pyrevit.framework import Assembly, Windows ''' """ diff --git a/pyrevitlib/pyrevit/loader/sessioninfo.py b/pyrevitlib/pyrevit/loader/sessioninfo.py index 22d7e177e..caded5db1 100644 --- a/pyrevitlib/pyrevit/loader/sessioninfo.py +++ b/pyrevitlib/pyrevit/loader/sessioninfo.py @@ -79,7 +79,7 @@ def get_runtime_info(): (RuntimeInfo): runtime info tuple Examples: - ''' + '''python sessioninfo.get_runtime_info() ''' """ diff --git a/pyrevitlib/pyrevit/loader/sessionmgr.py b/pyrevitlib/pyrevit/loader/sessionmgr.py index 7e24a15c3..81ee2a68d 100644 --- a/pyrevitlib/pyrevit/loader/sessionmgr.py +++ b/pyrevitlib/pyrevit/loader/sessionmgr.py @@ -255,7 +255,7 @@ def load_session(): through interactions with .extensions, .loader.asmmaker, and .loader.uimaker. Examples: - ''' + '''python from pyrevit.loader.sessionmgr import load_session load_session() # start loading a new pyRevit session ''' @@ -472,7 +472,7 @@ def find_pyrevitcmd(pyrevitcmd_unique_id): instantiated before use. Examples: - ''' + '''python cmd = find_pyrevitcmd('pyRevitCorepyRevitpyRevittoolsReload') command_instance = cmd() command_instance.Execute() # Provide commandData, message, elements diff --git a/pyrevitlib/pyrevit/output/__init__.py b/pyrevitlib/pyrevit/output/__init__.py index a8e1fb98d..c6582deb4 100644 --- a/pyrevitlib/pyrevit/output/__init__.py +++ b/pyrevitlib/pyrevit/output/__init__.py @@ -6,7 +6,7 @@ uses the `pyrevit.output` module to get access to the output wrapper. Examples: - ''' + '''python from pyrevit import script output = script.get_output() ''' @@ -180,7 +180,7 @@ def inject_to_head(self, element_tag, element_contents, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - ''' + '''python output = pyrevit.output.get_output() output.inject_to_head('script', '', # no script since it's a link @@ -210,7 +210,7 @@ def inject_to_body(self, element_tag, element_contents, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - ''' + '''python output = pyrevit.output.get_output() output.inject_to_body('script', '', # no script since it's a link @@ -240,7 +240,7 @@ def inject_script(self, script_code, attribs=None, body=False): body (bool, optional): injects script into body instead of head Examples: - ''' + '''python output = pyrevit.output.get_output() output.inject_script('', # no script since it's a link {'src': js_script_file_path}) @@ -259,7 +259,7 @@ def add_style(self, style_code, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - ''' + '''python output = pyrevit.output.get_output() output.add_style('body { color: blue; }') ''' @@ -417,7 +417,7 @@ def update_progress(self, cur_value, max_value): max_value (float): total value e.g. 100 Examples: - ''' + '''python output = pyrevit.output.get_output() for i in range(100): output.update_progress(i, 100) @@ -502,7 +502,7 @@ def print_html(html_str): """Add the html code to the output window. Examples: - ''' + '''python output = pyrevit.output.get_output() output.print_html('Title') ''' @@ -515,7 +515,7 @@ def print_code(code_str): """Print code to the output window with special formatting. Examples: - ''' + '''python output = pyrevit.output.get_output() output.print_code('value = 12') ''' @@ -535,7 +535,7 @@ def print_md(md_str): """Process markdown code and print to output window. Examples: - ''' + '''python output = pyrevit.output.get_output() output.print_md('### Title') ''' @@ -558,7 +558,7 @@ def print_table(self, table_data, columns=None, formats=None, last_line_style (str): css style of last row Examples: - ''' + '''python data = [ ['row1', 'data', 'data', 80 ], ['row2', 'data', 'data', 45 ], @@ -624,7 +624,7 @@ def print_image(self, image_path): r"""Prints given image to the output. Examples: - ''' + '''python output = pyrevit.output.get_output() output.print_image(r'C:\image.gif') ''' @@ -662,11 +662,11 @@ def linkify(element_ids, title=None): (str): clickable link Examples: - ''' + '''python output = pyrevit.output.get_output() for idx, elid in enumerate(element_ids): print('{}: {}'.format(idx+1, output.linkify(elid))) - '''00 + ''' """ return coreutils.prepare_html_str( linkmaker.make_link(element_ids, contents=title) diff --git a/pyrevitlib/pyrevit/output/linkmaker.py b/pyrevitlib/pyrevit/output/linkmaker.py index cda0b6737..93bd3fad7 100644 --- a/pyrevitlib/pyrevit/output/linkmaker.py +++ b/pyrevitlib/pyrevit/output/linkmaker.py @@ -42,7 +42,7 @@ def make_link(element_ids, contents=None): method. Examples: - ''' + '''python output = pyrevit.output.get_output() for idx, elid in enumerate(element_ids): print('{}: {}'.format(idx+1, output.linkify(elid))) diff --git a/pyrevitlib/pyrevit/routes/__init__.py b/pyrevitlib/pyrevit/routes/__init__.py index 0654b2586..19f1696b8 100644 --- a/pyrevitlib/pyrevit/routes/__init__.py +++ b/pyrevitlib/pyrevit/routes/__init__.py @@ -12,7 +12,7 @@ class API(object): name (str): URL-safe unique root name of the API Examples: - ''' + '''python from pyrevit import routes api = routes.API("pyrevit-core") @api.route('/sessions/', methods=['POST']) diff --git a/pyrevitlib/pyrevit/routes/server/router.py b/pyrevitlib/pyrevit/routes/server/router.py index d9b7bac6a..aabe0fef6 100644 --- a/pyrevitlib/pyrevit/routes/server/router.py +++ b/pyrevitlib/pyrevit/routes/server/router.py @@ -94,7 +94,7 @@ def extract_route_params(route_pattern, request_path): """Extracts route params from request path based on pattern. Examples: - ''' + '''python extract_route_params('api/v1/posts/', 'api/v1/posts/12') ''' [] diff --git a/pyrevitlib/pyrevit/runtime/__init__.py b/pyrevitlib/pyrevit/runtime/__init__.py index da1cee751..dca313e6f 100644 --- a/pyrevitlib/pyrevit/runtime/__init__.py +++ b/pyrevitlib/pyrevit/runtime/__init__.py @@ -408,7 +408,7 @@ def create_type(modulebuilder, type_class, class_name, custom_attr_list, *args): (type): returns created dotnet type Examples: - ''' + '''python asm_builder = AppDomain.CurrentDomain.DefineDynamicAssembly( win_asm_name, AssemblyBuilderAccess.RunAndSave, filepath ) diff --git a/pyrevitlib/pyrevit/script.py b/pyrevitlib/pyrevit/script.py index 3ed299626..955d7853e 100644 --- a/pyrevitlib/pyrevit/script.py +++ b/pyrevitlib/pyrevit/script.py @@ -1,7 +1,7 @@ """Provide basic utilities for pyRevit scripts. Examples: - ''' + '''python from pyrevit import script script.clipboard_copy('some text') data = script.journal_read('data-key') @@ -205,11 +205,11 @@ def get_universal_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{file_id}.{file_ext}`` Examples: - ''' + '''python script.get_universal_data_file('mydata', 'data') ''' '/pyRevit_mydata.data' - ''' + '''python script.get_universal_data_file('mydata', 'data', add_cmd_name=True) ''' '/pyRevit_Command Name_mydata.data' @@ -240,11 +240,11 @@ def get_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{Revit Version}_{file_id}.{file_ext}`` Examples: - ''' + '''python script.get_data_file('mydata', 'data') ''' '/pyRevit_2018_mydata.data' - ''' + '''python script.get_data_file('mydata', 'data', add_cmd_name=True) ''' '/pyRevit_2018_Command Name_mydata.data' @@ -276,11 +276,11 @@ def get_instance_data_file(file_id, add_cmd_name=False): ``pyRevit_{Revit Version}_{Process Id}_{file_id}.{file_ext}`` Examples: - ''' + '''python script.get_instance_data_file('mydata') ''' '/pyRevit_2018_6684_mydata.tmp' - ''' + '''python script.get_instance_data_file('mydata', add_cmd_name=True) ''' '/pyRevit_2018_6684_Command Name_mydata.tmp' @@ -309,11 +309,11 @@ def get_document_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{Revit Version}_{file_id}_{Project Name}.{file_ext}`` Examples: - ''' + '''python script.get_document_data_file('mydata', 'data') ''' '/pyRevit_2018_mydata_Project1.data' - ''' + '''python script.get_document_data_file('mydata', 'data', add_cmd_name=True) ''' '/pyRevit_2018_Command Name_mydata_Project1.data' @@ -569,7 +569,7 @@ def get_envvar(envvar): (Any): object stored in environment variable Examples: - ''' + '''python script.get_envvar('ToolActiveState') ''' True @@ -590,7 +590,7 @@ def set_envvar(envvar, value): value (any): value of environment variable Examples: - ''' + '''python script.set_envvar('ToolActiveState', False) script.get_envvar('ToolActiveState') ''' @@ -660,7 +660,7 @@ def store_data(slot_name, data, this_project=True): this_project (bool): data belongs to this project only Examples: - ''' + '''python from pyrevit import revit from pyrevit import script @@ -721,7 +721,7 @@ def load_data(slot_name, this_project=True): (object): stored data Examples: - ''' + '''python from pyrevit import revit from pyrevit import script diff --git a/pyrevitlib/pyrevit/telemetry/__init__.py b/pyrevitlib/pyrevit/telemetry/__init__.py index 5c1ccd519..87d601e25 100644 --- a/pyrevitlib/pyrevit/telemetry/__init__.py +++ b/pyrevitlib/pyrevit/telemetry/__init__.py @@ -1,16 +1,16 @@ """This module manages the telemetry system. This function is used to setup the telemetry system on pyRevit startup: - ''' + '''python setup_telemetry() ''' These functions are used to query information about the logging system: - ''' + '''python get_telemetry_state() ''' - ''' + '''python get_apptelemetry_state() ''' diff --git a/pyrevitlib/pyrevit/telemetry/record.py b/pyrevitlib/pyrevit/telemetry/record.py index 98bdd850b..04375b6a3 100644 --- a/pyrevitlib/pyrevit/telemetry/record.py +++ b/pyrevitlib/pyrevit/telemetry/record.py @@ -13,7 +13,7 @@ class CommandCustomResults(object): to use wrapper around it. Examples: - ''' + '''python CommandCustomResults().returnparam = 'some return value' ''' diff --git a/pyrevitlib/pyrevit/unittests/__init__.py b/pyrevitlib/pyrevit/unittests/__init__.py index 5154d821f..1c88f37bb 100644 --- a/pyrevitlib/pyrevit/unittests/__init__.py +++ b/pyrevitlib/pyrevit/unittests/__init__.py @@ -7,7 +7,7 @@ suite to test the full functionality of that module, although only a subset of functions are used during startup and normal operations of pyRevit. -''' +'''python from unittest import TestCase class TestWithIndependentOutput(TestCase): def setUp(self): diff --git a/pyrevitlib/pyrevit/userconfig.py b/pyrevitlib/pyrevit/userconfig.py index b8958969f..5733b06d6 100644 --- a/pyrevitlib/pyrevit/userconfig.py +++ b/pyrevitlib/pyrevit/userconfig.py @@ -8,7 +8,7 @@ All other modules use this module to query user config. Examples: - ''' + '''python from pyrevit.userconfig import user_config user_config.add_section('newsection') user_config.newsection.property = value @@ -25,7 +25,7 @@ :pyobject: get_config Examples: - ''' + '''python from pyrevit import script cfg = script.get_config() cfg.property = value @@ -69,7 +69,7 @@ class PyRevitConfig(configparser.PyRevitConfigParser): config_type (str): type of config file Examples: - ''' + '''python cfg = PyRevitConfig(cfg_file_path) cfg.add_section('sectionname') cfg.sectionname.property = value diff --git a/pyrevitlib/pyrevit/versionmgr/__init__.py b/pyrevitlib/pyrevit/versionmgr/__init__.py index 09372f73f..fd882b874 100644 --- a/pyrevitlib/pyrevit/versionmgr/__init__.py +++ b/pyrevitlib/pyrevit/versionmgr/__init__.py @@ -1,7 +1,7 @@ """Utility functions for managing pyRevit versions. Examples: - ''' + '''python from pyrevit import versionmgr v = versionmgr.get_pyrevit_version() v.get_formatted() diff --git a/pyrevitlib/pyrevit/versionmgr/about.py b/pyrevitlib/pyrevit/versionmgr/about.py index 2ab3a50d8..6870b36e2 100644 --- a/pyrevitlib/pyrevit/versionmgr/about.py +++ b/pyrevitlib/pyrevit/versionmgr/about.py @@ -2,7 +2,7 @@ """Utility module for pyRevit project information. Examples: - ''' + '''python from pyrevit.versionmgr import about a = about.get_pyrevit_about() a.subtitle