From 61ac22bb486682915f42f71639ca23d99daef4b3 Mon Sep 17 00:00:00 2001 From: jmcouffin Date: Sun, 22 Oct 2023 22:34:37 +0200 Subject: [PATCH] ''' for ``` --- pyrevitlib/pyrevit/__init__.py | 8 +- pyrevitlib/pyrevit/api.py | 4 +- pyrevitlib/pyrevit/compat.py | 4 +- pyrevitlib/pyrevit/coreutils/__init__.py | 148 +++++++++--------- pyrevitlib/pyrevit/coreutils/appdata.py | 4 +- pyrevitlib/pyrevit/coreutils/applocales.py | 4 +- pyrevitlib/pyrevit/coreutils/charts.py | 12 +- pyrevitlib/pyrevit/coreutils/colors.py | 8 +- pyrevitlib/pyrevit/coreutils/envvars.py | 12 +- pyrevitlib/pyrevit/coreutils/logger.py | 4 +- .../markdown/extensions/codehilite.py | 4 +- .../markdown/extensions/fenced_code.py | 4 +- .../coreutils/markdown/inlinepatterns.py | 2 +- pyrevitlib/pyrevit/coreutils/mathnet.py | 4 +- pyrevitlib/pyrevit/coreutils/pyutils.py | 28 ++-- pyrevitlib/pyrevit/coreutils/ribbon.py | 4 +- pyrevitlib/pyrevit/extensions/parser.py | 4 +- pyrevitlib/pyrevit/framework.py | 4 +- pyrevitlib/pyrevit/loader/sessioninfo.py | 4 +- pyrevitlib/pyrevit/loader/sessionmgr.py | 8 +- pyrevitlib/pyrevit/output/__init__.py | 48 +++--- pyrevitlib/pyrevit/output/linkmaker.py | 4 +- pyrevitlib/pyrevit/revit/__init__.py | 4 +- pyrevitlib/pyrevit/revit/db/transaction.py | 8 +- pyrevitlib/pyrevit/revit/serverutils.py | 8 +- pyrevitlib/pyrevit/routes/__init__.py | 4 +- pyrevitlib/pyrevit/routes/server/router.py | 4 +- pyrevitlib/pyrevit/runtime/__init__.py | 4 +- pyrevitlib/pyrevit/script.py | 52 +++--- pyrevitlib/pyrevit/telemetry/__init__.py | 12 +- pyrevitlib/pyrevit/telemetry/record.py | 4 +- pyrevitlib/pyrevit/unittests/__init__.py | 4 +- pyrevitlib/pyrevit/userconfig.py | 12 +- pyrevitlib/pyrevit/versionmgr/__init__.py | 4 +- pyrevitlib/pyrevit/versionmgr/about.py | 4 +- 35 files changed, 225 insertions(+), 225 deletions(-) diff --git a/pyrevitlib/pyrevit/__init__.py b/pyrevitlib/pyrevit/__init__.py index 8b4bd2cd1..a5f01d3b3 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 + ```python from pyrevit import DB, UI from pyrevit import PyRevitException, PyRevitIOError @@ -10,7 +10,7 @@ # 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 @@ -182,10 +182,10 @@ class _HostApplication(object): postable commands, and other functionality. Examples: - '''python + ```python hostapp = _HostApplication() hostapp.is_newer_than(2017) - ''' + ``` """ def __init__(self): diff --git a/pyrevitlib/pyrevit/api.py b/pyrevitlib/pyrevit/api.py index ce86185b9..da68ae2cc 100644 --- a/pyrevitlib/pyrevit/api.py +++ b/pyrevitlib/pyrevit/api.py @@ -1,9 +1,9 @@ """Provide access to Revit API. Examples: - '''python + ```python from pyrevit.api import AdWindows - ''' + ``` """ import os.path as op diff --git a/pyrevitlib/pyrevit/compat.py b/pyrevitlib/pyrevit/compat.py index 053f4908e..8b8e30643 100644 --- a/pyrevitlib/pyrevit/compat.py +++ b/pyrevitlib/pyrevit/compat.py @@ -1,10 +1,10 @@ """python engine compatibility module. Examples: - '''python + ```python from pyrevit.compat import IRONPY277 from pyrevit.compat import safe_strtype - ''' + ``` """ import sys diff --git a/pyrevitlib/pyrevit/coreutils/__init__.py b/pyrevitlib/pyrevit/coreutils/__init__.py index f34f77da1..3f840a297 100644 --- a/pyrevitlib/pyrevit/coreutils/__init__.py +++ b/pyrevitlib/pyrevit/coreutils/__init__.py @@ -1,10 +1,10 @@ """Misc Helper functions for pyRevit. Examples: - '''python + ```python from pyrevit import coreutils coreutils.cleanup_string('some string') - ''' + ``` """ #pylint: disable=invalid-name import os @@ -81,14 +81,14 @@ class ScriptFileParser(object): but can work for any python script. Examples: - '''python + ```python finder = ScriptFileParser('/path/to/coreutils/__init__.py') finder.docstring() - ''' + ``` "Misc Helper functions for pyRevit." - '''python + ```python finder.extract_param('SomeValue', []) - ''' + ``` [] """ @@ -166,10 +166,10 @@ class FileWatcher(object): its timestamp. Examples: - ''' + ``` watcher = FileWatcher('/path/to/file.ext') watcher.has_changed - ''' + ``` True """ @@ -200,12 +200,12 @@ class SafeDict(dict): key values. Examples: - '''python + ```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}.' """ @@ -329,10 +329,10 @@ def cleanup_string(input_str, skip=None): skip (Container[str]): special characters to keep Examples: - '''python + ```python src_str = 'TEST@Some*' cleanup_string(src_str) - ''' + ``` "TESTATSomeSTARvalue" """ # remove spaces and special characters from strings @@ -361,9 +361,9 @@ def run_process(proc, cwd='C:'): cwd (str): current working directory Exmaple: - '''python + ```python run_process('notepad.exe', 'c:/') - ''' + ``` """ import subprocess return subprocess.Popen(proc, @@ -417,9 +417,9 @@ def make_canonical_name(*args): (str): dot separated unique name Examples: - '''python + ```python make_canonical_name('somename', 'someid', 'txt') - ''' + ``` "somename.someid.txt" """ return '.'.join(args) @@ -435,9 +435,9 @@ def get_canonical_parts(canonical_string): (list[str]): list of composing parts Examples: - '''python + ```python get_canonical_parts("Config.SubConfig") - ''' + ``` ['Config', 'SubConfig'] """ return canonical_string.split('.') @@ -478,9 +478,9 @@ def calculate_dir_hash(dir_path, dir_filter, file_filter): (str): hash value as string Examples: - '''python + ```python calculate_dir_hash(source_path, '\.extension', '\.json') - ''' + ``` "1a885a0cae99f53d6088b9f7cee3bf4d" """ mtime_sum = 0 @@ -508,9 +508,9 @@ def prepare_html_str(input_string): input_string (str): input html string Examples: - '''python + ```python prepare_html_str('

Some text

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

Some text

" """ return input_html.replace('&clt;', '<').replace('&cgt;', '>') @@ -690,14 +690,14 @@ def cleanup_filename(file_name, windows_safe=False): (str): cleaned up file name Examples: - '''python + ```python cleanup_filename('Myfile-(3).txt') - ''' + ``` "Myfile(3).txt" - '''python + ```python cleanup_filename('Perforations 1/8" (New)') - ''' + ``` "Perforations 18 (New).txt" """ if windows_safe: @@ -719,9 +719,9 @@ def _inc_or_dec_string(str_id, shift, refit=False, logger=None): (str): modified identifier Examples: - '''python + ```python _inc_or_dec_string('A319z') - ''' + ``` 'A320a' """ # if no shift, return given string @@ -823,9 +823,9 @@ def increment_str(input_str, step=1, expand=False): (str): modified identifier Examples: - '''python + ```python increment_str('A319z') - ''' + ``` 'A320a' """ return _inc_or_dec_string(input_str, abs(step), refit=expand) @@ -843,9 +843,9 @@ def decrement_str(input_str, step=1, shrink=False): (str): modified identifier Examples: - '''python + ```python decrement_str('A310a') - ''' + ``` 'A309z' """ return _inc_or_dec_string(input_str, -abs(step), refit=shrink) @@ -863,13 +863,13 @@ def extend_counter(input_str, upper=True, use_zero=False): (str): extended identifier Examples: - '''python + ```python extend_counter('A310') - ''' + ``` 'A310A' - '''python + ```python extend_counter('A310A', use_zero=True) - ''' + ``` 'A310A0' """ if input_str[-1].isdigit(): @@ -900,9 +900,9 @@ def reverse_dict(input_dict): (defaultdict): reversed dictionary Examples: - '''python + ```python reverse_dict({1: 2, 3: 4}) - ''' + ``` defaultdict(, {2: [1], 4: [3]}) """ output_dict = defaultdict(list) @@ -918,9 +918,9 @@ def timestamp(): (str): timestamp in string format Examples: - '''python + ```python timestamp() - ''' + ``` '01003075032506808' """ return datetime.datetime.now().strftime("%m%j%H%M%S%f") @@ -935,9 +935,9 @@ def current_time(): (str): formatted current time. Examples: - '''python + ```python current_time() - ''' + ``` '07:50:53' """ return datetime.datetime.now().strftime("%H:%M:%S") @@ -952,9 +952,9 @@ def current_date(): (str): formatted current date. Examples: - '''python + ```python current_date() - ''' + ``` '2018-01-03' """ return datetime.datetime.now().strftime("%Y-%m-%d") @@ -970,9 +970,9 @@ def is_blank(input_string): (bool): True if string is blank Examples: - '''python + ```python is_blank(' ') - ''' + ``` True """ if input_string and input_string.strip(): @@ -990,9 +990,9 @@ def is_url_valid(url_string): (bool): True if URL is in valid format Examples: - '''python + ```python is_url_valid('https://www.google.com') - ''' + ``` True """ regex = re.compile( @@ -1022,11 +1022,11 @@ def reformat_string(orig_str, orig_format, new_format): (str): Reformatted string Examples: - '''python + ```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 @@ -1071,10 +1071,10 @@ def dletter_to_unc(dletter_path): (str): UNC path Examples: - '''python + ```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() @@ -1094,10 +1094,10 @@ def unc_to_dletter(unc_path): (str): drive letter path Examples: - '''python + ```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() @@ -1120,9 +1120,9 @@ def random_hex_color(): """Return a random color in hex format. Examples: - '''python + ```python random_hex_color() - ''' + ``` '#FF0000' """ return '#%02X%02X%02X' % (random_color(), @@ -1134,9 +1134,9 @@ def random_rgb_color(): """Return a random color in rgb format. Examples: - '''python + ```python random_rgb_color() - ''' + ``` 'rgb(255, 0, 0)' """ return 'rgb(%d, %d, %d)' % (random_color(), @@ -1148,9 +1148,9 @@ def random_rgba_color(): """Return a random color in rgba format. Examples: - '''python + ```python random_rgba_color() - ''' + ``` 'rgba(255, 0, 0, 0.5)' """ return 'rgba(%d, %d, %d, %.2f)' % (random_color(), @@ -1177,17 +1177,17 @@ def extract_range(formatted_str, max_range=500): (list[str]): names in the specified range Examples: - '''python + ```python exract_range('A103:A106') - ''' + ``` ['A103', 'A104', 'A105', 'A106'] - '''python + ```python exract_range('S203-S206') - ''' + ``` ['S203', 'S204', 'S205', 'S206'] - '''python + ```python exract_range('M00A,M00B') - ''' + ``` ['M00A', 'M00B'] """ for rchar, rchartype in {'::': 'range', '--': 'range', @@ -1408,9 +1408,9 @@ def get_reg_key(key, subkey): (PyHKEY): registry key if found, None if not found Examples: - '''python + ```python get_reg_key(wr.HKEY_CURRENT_USER, 'Control Panel/International') - ''' + ``` """ try: @@ -1426,9 +1426,9 @@ def kill_tasks(task_name): task_name (str): task name Examples: - '''python + ```python kill_tasks('Revit.exe') - ''' + ``` """ os.system("taskkill /f /im %s" % task_name) @@ -1456,9 +1456,9 @@ def split_words(input_string): (list[str]): split string Examples: - '''python + ```python split_words("UIApplication_ApplicationClosing") - ''' + ``` ['UIApplication', 'Application', 'Closing'] """ parts = [] diff --git a/pyrevitlib/pyrevit/coreutils/appdata.py b/pyrevitlib/pyrevit/coreutils/appdata.py index 15c41ad05..3491e85e4 100644 --- a/pyrevitlib/pyrevit/coreutils/appdata.py +++ b/pyrevitlib/pyrevit/coreutils/appdata.py @@ -5,10 +5,10 @@ the necessary and consistent mechanism for creating and maintaining such files. Examples: - '''python + ```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 787c4fef8..3b2e20395 100644 --- a/pyrevitlib/pyrevit/coreutils/applocales.py +++ b/pyrevitlib/pyrevit/coreutils/applocales.py @@ -220,12 +220,12 @@ def get_locale_string(string_dict): (str): string in correct locale Examples: - '''python + ```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) diff --git a/pyrevitlib/pyrevit/coreutils/charts.py b/pyrevitlib/pyrevit/coreutils/charts.py index fccd1b274..424ca8e14 100644 --- a/pyrevitlib/pyrevit/coreutils/charts.py +++ b/pyrevitlib/pyrevit/coreutils/charts.py @@ -56,9 +56,9 @@ def set_color(self, *args): Arguments are expected to be R, G, B, A values. Examples: - '''python + ```python dataset_obj.set_color(0xFF, 0x8C, 0x8D, 0.8) - ''' + ``` """ if len(args) == 4: self.backgroundColor = 'rgba({},{},{},{})'.format(args[0], @@ -85,9 +85,9 @@ def new_dataset(self, dataset_label): (PyRevitOutputChartDataset): dataset wrapper object Examples: - '''python + ```python chart.data.new_dataset('set_a') - ''' + ``` """ new_dataset = PyRevitOutputChartDataset(dataset_label) self.datasets.append(new_dataset) @@ -215,9 +215,9 @@ def set_style(self, html_style): html_style (str): inline html css styling string Examples: - '''python + ```python chart.set_style('height:150px') - ''' + ``` """ self._style = html_style diff --git a/pyrevitlib/pyrevit/coreutils/colors.py b/pyrevitlib/pyrevit/coreutils/colors.py index 4fc59ffbb..5c945e404 100644 --- a/pyrevitlib/pyrevit/coreutils/colors.py +++ b/pyrevitlib/pyrevit/coreutils/colors.py @@ -5,14 +5,14 @@ elements formatted: COLORS[colorname] = CONSTANT. Examples: - '''python + ```python from pyrevit.coreutils import colors colors.COLORS['black'] - ''' + ``` - '''python + ```python colors.BLACK - ''' + ``` """ diff --git a/pyrevitlib/pyrevit/coreutils/envvars.py b/pyrevitlib/pyrevit/coreutils/envvars.py index c35a66609..1c2b572d2 100644 --- a/pyrevitlib/pyrevit/coreutils/envvars.py +++ b/pyrevitlib/pyrevit/coreutils/envvars.py @@ -19,22 +19,22 @@ scripts is strongly prohibited. Examples: - '''python + ```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: - '''python + ```python envvars.get_pyrevit_env_vars('MY_SCRIPT_STATUS') - ''' + ``` True - '''python + ```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 71f96cfe2..c0c15f9b7 100644 --- a/pyrevitlib/pyrevit/coreutils/logger.py +++ b/pyrevitlib/pyrevit/coreutils/logger.py @@ -337,9 +337,9 @@ def get_logger(logger_name): (LoggerWrapper): logger object wrapper python's native logger Examples: - '''python + ```python get_logger('my command') - ''' + ``` """ if loggers.get(logger_name): diff --git a/pyrevitlib/pyrevit/coreutils/markdown/extensions/codehilite.py b/pyrevitlib/pyrevit/coreutils/markdown/extensions/codehilite.py index b30dbcd57..febe87f98 100644 --- a/pyrevitlib/pyrevit/coreutils/markdown/extensions/codehilite.py +++ b/pyrevitlib/pyrevit/coreutils/markdown/extensions/codehilite.py @@ -159,14 +159,14 @@ def _parseHeader(self): # pull first line to examine fl = lines.pop(0) - c = re.compile(r''' + c = re.compile(r``` (?:(?:^::+)|(?P^[#]!)) # Shebang or 2 or more colons (?P(?:/\w+)*[/ ])? # Zero or 1 path (?P[\w#.+-]*) # The language \s* # Arbitrary whitespace # Optional highlight lines, single- or double-quote-delimited (hl_lines=(?P"|')(?P.*?)(?P=quot))? - ''', re.VERBOSE) + ```, re.VERBOSE) # search first line for shebang m = c.search(fl) if m: diff --git a/pyrevitlib/pyrevit/coreutils/markdown/extensions/fenced_code.py b/pyrevitlib/pyrevit/coreutils/markdown/extensions/fenced_code.py index 3b12d93c2..532e9b8d7 100644 --- a/pyrevitlib/pyrevit/coreutils/markdown/extensions/fenced_code.py +++ b/pyrevitlib/pyrevit/coreutils/markdown/extensions/fenced_code.py @@ -35,14 +35,14 @@ def extendMarkdown(self, md, md_globals): class FencedBlockPreprocessor(Preprocessor): """Fenced code block preprocessor.""" - FENCED_BLOCK_RE = re.compile(r''' + FENCED_BLOCK_RE = re.compile(r``` (?P^(?:~{3,}|`{3,}))[ ]* # Opening ``` or ~~~ (\{?\.?(?P[\w#.+-]*))?[ ]* # Optional {, and lang # Optional highlight lines, single- or double-quote-delimited (hl_lines=(?P"|')(?P.*?)(?P=quot))?[ ]* }?[ ]*\n # Optional closing } (?P.*?)(?<=\n) -(?P=fence)[ ]*$''', re.MULTILINE | re.DOTALL | re.VERBOSE) +(?P=fence)[ ]*$```, re.MULTILINE | re.DOTALL | re.VERBOSE) CODE_WRAP = '
%s
' LANG_TAG = ' class="%s"' diff --git a/pyrevitlib/pyrevit/coreutils/markdown/inlinepatterns.py b/pyrevitlib/pyrevit/coreutils/markdown/inlinepatterns.py index fb9720084..e5bdc83ac 100644 --- a/pyrevitlib/pyrevit/coreutils/markdown/inlinepatterns.py +++ b/pyrevitlib/pyrevit/coreutils/markdown/inlinepatterns.py @@ -129,7 +129,7 @@ def build_inlinepatterns(md_instance, **kwargs): # [text](url) or [text]() or [text](url "title") LINK_RE = NOIMG + BRK + \ - r'''\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)''' + r```\(\s*(<.*?>|((?:(?:\(.*?\))|[^\(\)]))*?)\s*((['"])(.*?)\12\s*)?\)``` # ![alttxt](http://x.com/) or ![alttxt]() IMAGE_LINK_RE = r'\!' + BRK + r'\s*\(\s*(<.*?>|([^"\)\s]+\s*"[^"]*"|[^\)\s]*))\s*\)' diff --git a/pyrevitlib/pyrevit/coreutils/mathnet.py b/pyrevitlib/pyrevit/coreutils/mathnet.py index 3eaad4de6..f10a528ef 100644 --- a/pyrevitlib/pyrevit/coreutils/mathnet.py +++ b/pyrevitlib/pyrevit/coreutils/mathnet.py @@ -3,9 +3,9 @@ See https://www.mathdotnet.com for documentation. Examples: - '''python + ```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 aa06c31c2..0895251d0 100644 --- a/pyrevitlib/pyrevit/coreutils/pyutils.py +++ b/pyrevitlib/pyrevit/coreutils/pyutils.py @@ -22,7 +22,7 @@ class DefaultOrderedDict(OrderedDict): to it so in that regards it functions similar to OrderedDict. Examples: - '''python + ```python from pyrevit.coreutils import pyutils od = pyutils.DefaultOrderedDict(list) od['A'] = [1, 2, 3] @@ -30,7 +30,7 @@ class DefaultOrderedDict(OrderedDict): 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]) @@ -91,17 +91,17 @@ def pairwise(iterable, step=2): (Iterable[Any]): list of pairs Examples: - '''python + ```python pairwise([1, 2, 3, 4, 5]) - ''' + ``` [(1, 2), (3, 4)] # 5 can not be paired - '''python + ```python pairwise([1, 2, 3, 4, 5, 6]) - ''' + ``` [(1, 2), (3, 4), (5, 6)] - '''python + ```python pairwise([1, 2, 3, 4, 5, 6], step=1) - ''' + ``` [(1, 2), (2, 3), (3, 4), (4, 5), (5, 6)] """ if step == 1: @@ -125,9 +125,9 @@ def safe_cast(val, to_type, default=None): default (any): value to rerun on conversion exception Examples: - '''python + ```python safe_cast('name', int, default=0) - ''' + ``` 0 """ try: @@ -146,9 +146,9 @@ def isnumber(token): (bool): True of token is int or float Examples: - '''python + ```python isnumber('12.3') - ''' + ``` True """ if token: @@ -185,11 +185,11 @@ def merge(d1, d2): (dict[Any, Any]): updated d1 Examples: - '''python + ```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'}, diff --git a/pyrevitlib/pyrevit/coreutils/ribbon.py b/pyrevitlib/pyrevit/coreutils/ribbon.py index 84e7acc69..a5588d286 100644 --- a/pyrevitlib/pyrevit/coreutils/ribbon.py +++ b/pyrevitlib/pyrevit/coreutils/ribbon.py @@ -1691,11 +1691,11 @@ def get_current_ui(all_native=False): Returned class provides min required functionality for user interaction Examples: - '''python + ```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 diff --git a/pyrevitlib/pyrevit/extensions/parser.py b/pyrevitlib/pyrevit/extensions/parser.py index 116d5831b..71b256033 100644 --- a/pyrevitlib/pyrevit/extensions/parser.py +++ b/pyrevitlib/pyrevit/extensions/parser.py @@ -39,10 +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 + ```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/framework.py b/pyrevitlib/pyrevit/framework.py index e16122f12..f9a081258 100644 --- a/pyrevitlib/pyrevit/framework.py +++ b/pyrevitlib/pyrevit/framework.py @@ -1,9 +1,9 @@ """Provide access to DotNet Framework. Examples: - '''python + ```python from pyrevit.framework import Assembly, Windows - ''' + ``` """ #pylint: disable=W0703,C0302,C0103,W0614,E0401,W0611,C0413,ungrouped-imports diff --git a/pyrevitlib/pyrevit/loader/sessioninfo.py b/pyrevitlib/pyrevit/loader/sessioninfo.py index caded5db1..e68a30bef 100644 --- a/pyrevitlib/pyrevit/loader/sessioninfo.py +++ b/pyrevitlib/pyrevit/loader/sessioninfo.py @@ -79,9 +79,9 @@ def get_runtime_info(): (RuntimeInfo): runtime info tuple Examples: - '''python + ```python 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 81ee2a68d..ecf468a49 100644 --- a/pyrevitlib/pyrevit/loader/sessionmgr.py +++ b/pyrevitlib/pyrevit/loader/sessionmgr.py @@ -255,10 +255,10 @@ def load_session(): through interactions with .extensions, .loader.asmmaker, and .loader.uimaker. Examples: - '''python + ```python from pyrevit.loader.sessionmgr import load_session load_session() # start loading a new pyRevit session - ''' + ``` Returns: (str): sesion uuid @@ -472,11 +472,11 @@ def find_pyrevitcmd(pyrevitcmd_unique_id): instantiated before use. Examples: - '''python + ```python cmd = find_pyrevitcmd('pyRevitCorepyRevitpyRevittoolsReload') command_instance = cmd() command_instance.Execute() # Provide commandData, message, elements - ''' + ``` Args: pyrevitcmd_unique_id (str): Unique name for the command diff --git a/pyrevitlib/pyrevit/output/__init__.py b/pyrevitlib/pyrevit/output/__init__.py index c6582deb4..8e1c5e5d1 100644 --- a/pyrevitlib/pyrevit/output/__init__.py +++ b/pyrevitlib/pyrevit/output/__init__.py @@ -6,10 +6,10 @@ uses the `pyrevit.output` module to get access to the output wrapper. Examples: - '''python + ```python 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 @@ -180,12 +180,12 @@ def inject_to_head(self, element_tag, element_contents, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - '''python + ```python 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: @@ -210,12 +210,12 @@ def inject_to_body(self, element_tag, element_contents, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - '''python + ```python 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: @@ -240,11 +240,11 @@ def inject_script(self, script_code, attribs=None, body=False): body (bool, optional): injects script into body instead of head Examples: - '''python + ```python 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) @@ -259,10 +259,10 @@ def add_style(self, style_code, attribs=None): attribs (:obj:`dict`): dictionary of attribute names and value Examples: - '''python + ```python output = pyrevit.output.get_output() output.add_style('body { color: blue; }') - ''' + ``` """ self.inject_to_head('style', style_code, attribs=attribs) @@ -417,11 +417,11 @@ def update_progress(self, cur_value, max_value): max_value (float): total value e.g. 100 Examples: - '''python + ```python 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) @@ -502,10 +502,10 @@ def print_html(html_str): """Add the html code to the output window. Examples: - '''python + ```python output = pyrevit.output.get_output() output.print_html('Title') - ''' + ``` """ print(coreutils.prepare_html_str(html_str), end="") @@ -515,10 +515,10 @@ def print_code(code_str): """Print code to the output window with special formatting. Examples: - '''python + ```python output = pyrevit.output.get_output() output.print_code('value = 12') - ''' + ``` """ code_div = '
{}
' print( @@ -535,10 +535,10 @@ def print_md(md_str): """Process markdown code and print to output window. Examples: - '''python + ```python 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]) @@ -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 + ```python data = [ ['row1', 'data', 'data', 80 ], ['row2', 'data', 'data', 45 ], @@ -570,7 +570,7 @@ def print_table(self, table_data, columns=None, formats=None, formats=['', '', '', '{}%'], last_line_style='color:red;' ) - ''' + ``` """ if not columns: columns = [] @@ -624,10 +624,10 @@ def print_image(self, image_path): r"""Prints given image to the output. Examples: - '''python + ```python output = pyrevit.output.get_output() output.print_image(r'C:\image.gif') - ''' + ``` """ self.print_html( "".format( @@ -662,11 +662,11 @@ def linkify(element_ids, title=None): (str): clickable link Examples: - '''python + ```python output = pyrevit.output.get_output() for idx, elid in enumerate(element_ids): print('{}: {}'.format(idx+1, output.linkify(elid))) - ''' + ``` """ 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 93bd3fad7..ad83dc546 100644 --- a/pyrevitlib/pyrevit/output/linkmaker.py +++ b/pyrevitlib/pyrevit/output/linkmaker.py @@ -42,11 +42,11 @@ def make_link(element_ids, contents=None): method. Examples: - '''python + ```python output = pyrevit.output.get_output() for idx, elid in enumerate(element_ids): print('{}: {}'.format(idx+1, output.linkify(elid))) - ''' + ``` """ try: try: diff --git a/pyrevitlib/pyrevit/revit/__init__.py b/pyrevitlib/pyrevit/revit/__init__.py index a466c1fd6..559378659 100644 --- a/pyrevitlib/pyrevit/revit/__init__.py +++ b/pyrevitlib/pyrevit/revit/__init__.py @@ -138,13 +138,13 @@ class ErrorSwallower(): """Suppresses warnings during script execution. Examples: - '''python + ```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/db/transaction.py b/pyrevitlib/pyrevit/revit/db/transaction.py index 38642cf84..6bd4d369d 100644 --- a/pyrevitlib/pyrevit/revit/db/transaction.py +++ b/pyrevitlib/pyrevit/revit/db/transaction.py @@ -23,7 +23,7 @@ class Transaction(): before and after the context. Automatically rolls back if exception is raised. - '''python + ```python with Transaction('Move Wall'): wall.DoSomething() @@ -31,7 +31,7 @@ class Transaction(): wall.DoSomething() assert action.status == ActionStatus.Started # True assert action.status == ActionStatus.Committed # True - ''' + ``` """ def __init__(self, name=None, doc=None, @@ -167,14 +167,14 @@ def carryout(name, doc=None): name (str): Name of the Transaction doc (Document): Revit document - '''python + ```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 diff --git a/pyrevitlib/pyrevit/revit/serverutils.py b/pyrevitlib/pyrevit/revit/serverutils.py index d730fda21..f0bdbb1d4 100644 --- a/pyrevitlib/pyrevit/revit/serverutils.py +++ b/pyrevitlib/pyrevit/revit/serverutils.py @@ -29,10 +29,10 @@ def get_server_path(doc, path_dict): path_dict (dict): dict of RSN paths and their directory paths Examples: - '''python + ```python rsn_paths = {'RSN://SERVERNAME': '//servername/filestore'} get_server_path(doc, rsn_paths) - ''' + ``` "//servername/filestore/path/to/model.rvt" """ model_path = doc.GetWorksharingCentralModelPath() @@ -53,9 +53,9 @@ def get_model_sync_history(server_path): (list[SyncHistory]): list of SyncHistory instances Examples: - '''python + ```python get_model_sync_history("//servername/path/to/model.rvt") - ''' + ``` [SyncHistory(index=498, userid="user", timestamp="2017-12-13 19:56:20")] """ diff --git a/pyrevitlib/pyrevit/routes/__init__.py b/pyrevitlib/pyrevit/routes/__init__.py index 19f1696b8..e2071c29a 100644 --- a/pyrevitlib/pyrevit/routes/__init__.py +++ b/pyrevitlib/pyrevit/routes/__init__.py @@ -12,14 +12,14 @@ class API(object): name (str): URL-safe unique root name of the API Examples: - '''python + ```python 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 aabe0fef6..a0d31a9d3 100644 --- a/pyrevitlib/pyrevit/routes/server/router.py +++ b/pyrevitlib/pyrevit/routes/server/router.py @@ -94,9 +94,9 @@ def extract_route_params(route_pattern, request_path): """Extracts route params from request path based on pattern. Examples: - '''python + ```python extract_route_params('api/v1/posts/', 'api/v1/posts/12') - ''' + ``` [] """ finder_pattern = _make_finder_pattern(route_pattern) diff --git a/pyrevitlib/pyrevit/runtime/__init__.py b/pyrevitlib/pyrevit/runtime/__init__.py index dca313e6f..fd030394e 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 + ```python asm_builder = AppDomain.CurrentDomain.DefineDynamicAssembly( win_asm_name, AssemblyBuilderAccess.RunAndSave, filepath ) @@ -422,7 +422,7 @@ def create_type(modulebuilder, type_class, class_name, custom_attr_list, *args): runtime.create_ext_command_attrs(), [scriptpath, atlscriptpath, searchpath, helpurl, name, bundle, extension, uniquename, False, False]) - ''' + ``` """ # create type builder diff --git a/pyrevitlib/pyrevit/script.py b/pyrevitlib/pyrevit/script.py index 955d7853e..3c4003475 100644 --- a/pyrevitlib/pyrevit/script.py +++ b/pyrevitlib/pyrevit/script.py @@ -1,12 +1,12 @@ """Provide basic utilities for pyRevit scripts. Examples: - '''python + ```python from pyrevit import script script.clipboard_copy('some text') data = script.journal_read('data-key') script.exit() - ''' + ``` """ #pylint: disable=consider-using-f-string @@ -205,13 +205,13 @@ def get_universal_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{file_id}.{file_ext}`` Examples: - '''python + ```python script.get_universal_data_file('mydata', 'data') - ''' + ``` '/pyRevit_mydata.data' - '''python + ```python 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. @@ -240,13 +240,13 @@ def get_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{Revit Version}_{file_id}.{file_ext}`` Examples: - '''python + ```python script.get_data_file('mydata', 'data') - ''' + ``` '/pyRevit_2018_mydata.data' - '''python + ```python script.get_data_file('mydata', 'data', add_cmd_name=True) - ''' + ``` '/pyRevit_2018_Command Name_mydata.data' @@ -276,13 +276,13 @@ def get_instance_data_file(file_id, add_cmd_name=False): ``pyRevit_{Revit Version}_{Process Id}_{file_id}.{file_ext}`` Examples: - '''python + ```python script.get_instance_data_file('mydata') - ''' + ``` '/pyRevit_2018_6684_mydata.tmp' - '''python + ```python 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. @@ -309,13 +309,13 @@ def get_document_data_file(file_id, file_ext, add_cmd_name=False): ``pyRevit_{Revit Version}_{file_id}_{Project Name}.{file_ext}`` Examples: - '''python + ```python script.get_document_data_file('mydata', 'data') - ''' + ``` '/pyRevit_2018_mydata_Project1.data' - '''python + ```python 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. @@ -569,9 +569,9 @@ def get_envvar(envvar): (Any): object stored in environment variable Examples: - '''python + ```python script.get_envvar('ToolActiveState') - ''' + ``` True """ return envvars.get_pyrevit_env_var(envvar) @@ -590,10 +590,10 @@ def set_envvar(envvar, value): value (any): value of environment variable Examples: - '''python + ```python script.set_envvar('ToolActiveState', False) script.get_envvar('ToolActiveState') - ''' + ``` False """ return envvars.set_pyrevit_env_var(envvar, value) @@ -660,7 +660,7 @@ def store_data(slot_name, data, this_project=True): this_project (bool): data belongs to this project only Examples: - '''python + ```python from pyrevit import revit from pyrevit import script @@ -687,7 +687,7 @@ def element_ids(self): ) script.store_data("Selected Elements", mydata) - ''' + ``` """ # for this specific project? @@ -721,7 +721,7 @@ def load_data(slot_name, this_project=True): (object): stored data Examples: - '''python + ```python from pyrevit import revit from pyrevit import script @@ -744,7 +744,7 @@ def element_ids(self): mydata = script.load_data("Selected Elements") mydata.element_ids - ''' + ``` [, , ] """ # for this specific project? diff --git a/pyrevitlib/pyrevit/telemetry/__init__.py b/pyrevitlib/pyrevit/telemetry/__init__.py index 87d601e25..a129b405d 100644 --- a/pyrevitlib/pyrevit/telemetry/__init__.py +++ b/pyrevitlib/pyrevit/telemetry/__init__.py @@ -1,18 +1,18 @@ """This module manages the telemetry system. This function is used to setup the telemetry system on pyRevit startup: - '''python + ```python setup_telemetry() - ''' + ``` These functions are used to query information about the logging system: - '''python + ```python get_telemetry_state() - ''' + ``` - '''python + ```python 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 04375b6a3..7bc418042 100644 --- a/pyrevitlib/pyrevit/telemetry/record.py +++ b/pyrevitlib/pyrevit/telemetry/record.py @@ -13,9 +13,9 @@ class CommandCustomResults(object): to use wrapper around it. Examples: - '''python + ```python CommandCustomResults().returnparam = 'some return value' - ''' + ``` """ diff --git a/pyrevitlib/pyrevit/unittests/__init__.py b/pyrevitlib/pyrevit/unittests/__init__.py index 1c88f37bb..7a071e9fc 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 +```python from unittest import TestCase class TestWithIndependentOutput(TestCase): def setUp(self): @@ -18,7 +18,7 @@ def tearDown(self): def doCleanups(self): pass -''' +``` """ import warnings diff --git a/pyrevitlib/pyrevit/userconfig.py b/pyrevitlib/pyrevit/userconfig.py index 5733b06d6..e723f8e19 100644 --- a/pyrevitlib/pyrevit/userconfig.py +++ b/pyrevitlib/pyrevit/userconfig.py @@ -8,13 +8,13 @@ All other modules use this module to query user config. Examples: - '''python + ```python 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 @@ -25,13 +25,13 @@ :pyobject: get_config Examples: - '''python + ```python 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 @@ -69,13 +69,13 @@ class PyRevitConfig(configparser.PyRevitConfigParser): config_type (str): type of config file Examples: - '''python + ```python 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'): diff --git a/pyrevitlib/pyrevit/versionmgr/__init__.py b/pyrevitlib/pyrevit/versionmgr/__init__.py index fd882b874..2977ed6d1 100644 --- a/pyrevitlib/pyrevit/versionmgr/__init__.py +++ b/pyrevitlib/pyrevit/versionmgr/__init__.py @@ -1,11 +1,11 @@ """Utility functions for managing pyRevit versions. Examples: - '''python + ```python 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 6870b36e2..8fba891f9 100644 --- a/pyrevitlib/pyrevit/versionmgr/about.py +++ b/pyrevitlib/pyrevit/versionmgr/about.py @@ -2,11 +2,11 @@ """Utility module for pyRevit project information. Examples: - '''python + ```python 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