From bc590573342e9ea70f02e1c151413d06a7de3a36 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 2 Jul 2026 10:42:51 -0500 Subject: [PATCH 01/21] add overwrite to repeated capabilities --- build/templates/rep_caps.rst.mako | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 179d56e1fc..350cda6b4f 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -34,12 +34,18 @@ ${helper.get_rst_header_snippet('Repeated Capabilities', '=')} <% name = rep_cap['python_name'] prefix = rep_cap['prefix'] +rep_cap_doc = rep_cap.get('documentation', {}) +has_custom_doc = len(rep_cap_doc) > 0 +auto_prefix = rep_cap_doc.get('auto_prefix_addition_supported', len(prefix) > 0) %>\ ${helper.get_rst_header_snippet(name, '-')} .. py:attribute:: ${module_name}.Session.${name}[] -% if len(prefix) > 0: +% if has_custom_doc and 'description' in rep_cap_doc: + ${rep_cap_doc['description']} + +% elif auto_prefix: If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. @@ -51,16 +57,30 @@ ${helper.get_rst_header_snippet(name, '-')} If an invalid repeated capability is passed to the driver, the driver will return an error. +% if len(prefix) > 0: You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. % endif +% endif +% if not has_custom_doc or 'examples' not in rep_cap_doc: .. code:: python session.${name}['${prefix}0-${prefix}2'].channel_enabled = True passes a string of :python:`'${prefix}0, ${prefix}1, ${prefix}2'` to the set attribute function. +% endif +% if has_custom_doc and 'valid_identifiers' in rep_cap_doc and len(rep_cap_doc['valid_identifiers']) > 0: + Valid identifiers: :python:`'${", ".join(rep_cap_doc["valid_identifiers"])}'`. -% endfor +% endif +% if has_custom_doc and 'examples' in rep_cap_doc and len(rep_cap_doc['examples']) > 0: +% for example in rep_cap_doc['examples']: + .. code:: python + + ${example} +% endfor +% endif +% endfor From db0726d613e4b617c8a6109bb16299819be6913b Mon Sep 17 00:00:00 2001 From: Evan LeBel Date: Thu, 2 Jul 2026 13:16:23 -0500 Subject: [PATCH 02/21] Test for rep caps template --- build/unit_tests/test_rep_caps_template.py | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 build/unit_tests/test_rep_caps_template.py diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py new file mode 100644 index 0000000000..c19a0662be --- /dev/null +++ b/build/unit_tests/test_rep_caps_template.py @@ -0,0 +1,65 @@ +from pathlib import Path +from types import SimpleNamespace + +from mako.template import Template + + +def _render_rep_caps(config): + repo_root = Path(__file__).resolve().parents[2] + template_path = repo_root / 'build' / 'templates' / 'rep_caps.rst.mako' + template = Template(filename=str(template_path)) + metadata = SimpleNamespace(config=config) + return template.render(template_parameters={'metadata': metadata}) + + +def test_rep_caps_template_uses_custom_documentation_overrides(): + config = { + 'module_name': 'nifake', + 'c_function_prefix': 'niFake_', + 'repeated_capabilities': [ + { + 'prefix': 'res', + 'python_name': 'resources', + 'documentation': { + 'description': 'Resource repeated capabilities use fully-qualified identifiers.', + 'auto_prefix_addition_supported': False, + 'valid_identifiers': ['dev0/res0', 'dev0/res1'], + 'examples': [ + "session.resources['dev0/res0'].channel_enabled = True", + "session.resources['dev0/res1'].channel_enabled = True", + ], + }, + } + ], + } + + rendered = _render_rep_caps(config) + + assert 'Resource repeated capabilities use fully-qualified identifiers.' in rendered + assert "Valid identifiers: :python:`'dev0/res0, dev0/res1'`." in rendered + assert "session.resources['dev0/res0'].channel_enabled = True" in rendered + assert "session.resources['dev0/res1'].channel_enabled = True" in rendered + + # Generic auto-prefix guidance should be suppressed when override disables it. + assert 'If no prefix is added to the items in the parameter' not in rendered + assert "session.resources['0-2'].channel_enabled = True" not in rendered + assert "'res0, res1, res2'" not in rendered + + +def test_rep_caps_template_preserves_default_prefixed_behavior(): + config = { + 'module_name': 'nifake', + 'c_function_prefix': 'niFake_', + 'repeated_capabilities': [ + { + 'prefix': 'channel', + 'python_name': 'channels', + } + ], + } + + rendered = _render_rep_caps(config) + + assert 'If no prefix is added to the items in the parameter' in rendered + assert "session.channels['0-2'].channel_enabled = True" in rendered + assert "'channel0, channel1, channel2'" in rendered From dcb38940a32b71993917d8312a4ac82a4e4ce416 Mon Sep 17 00:00:00 2001 From: Evan LeBel Date: Thu, 2 Jul 2026 14:38:02 -0500 Subject: [PATCH 03/21] codegen --- build.sh | 0 docs/nidcpower/rep_caps.rst | 3 --- docs/nidigital/rep_caps.rst | 9 --------- docs/nifgen/rep_caps.rst | 5 ----- docs/nirfsg/rep_caps.rst | 8 -------- docs/niscope/rep_caps.rst | 3 --- docs/niswitch/rep_caps.rst | 2 -- src/nifgen/metadata/attributes.py | 0 src/nifgen/metadata/config.py | 0 src/nifgen/metadata/enums.py | 0 src/nifgen/metadata/functions.py | 0 src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms | Bin src/nirfsg/system_tests/samples2pfile.s2p | 0 13 files changed, 30 deletions(-) mode change 100755 => 100644 build.sh mode change 100755 => 100644 src/nifgen/metadata/attributes.py mode change 100755 => 100644 src/nifgen/metadata/config.py mode change 100755 => 100644 src/nifgen/metadata/enums.py mode change 100755 => 100644 src/nifgen/metadata/functions.py mode change 100755 => 100644 src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms mode change 100755 => 100644 src/nirfsg/system_tests/samples2pfile.s2p diff --git a/build.sh b/build.sh old mode 100755 new mode 100644 diff --git a/docs/nidcpower/rep_caps.rst b/docs/nidcpower/rep_caps.rst index 6078e4deab..a828f90261 100644 --- a/docs/nidcpower/rep_caps.rst +++ b/docs/nidcpower/rep_caps.rst @@ -34,7 +34,6 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. - instruments ----------- @@ -46,5 +45,3 @@ instruments passes a string of :python:`'0, 1, 2'` to the set attribute function. - - diff --git a/docs/nidigital/rep_caps.rst b/docs/nidigital/rep_caps.rst index 32550fc4f8..5fc51e899c 100644 --- a/docs/nidigital/rep_caps.rst +++ b/docs/nidigital/rep_caps.rst @@ -34,7 +34,6 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. - pins ---- @@ -46,7 +45,6 @@ pins passes a string of :python:`'0, 1, 2'` to the set attribute function. - instruments ----------- @@ -58,7 +56,6 @@ instruments passes a string of :python:`'0, 1, 2'` to the set attribute function. - pattern_opcode_events --------------------- @@ -84,7 +81,6 @@ pattern_opcode_events passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. - conditional_jump_triggers ------------------------- @@ -110,7 +106,6 @@ conditional_jump_triggers passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. - sites ----- @@ -136,7 +131,6 @@ sites passes a string of :python:`'site0, site1, site2'` to the set attribute function. - rio_events ---------- @@ -162,7 +156,6 @@ rio_events passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. - rio_triggers ------------ @@ -188,5 +181,3 @@ rio_triggers passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. - - diff --git a/docs/nifgen/rep_caps.rst b/docs/nifgen/rep_caps.rst index 5890a432ea..030d3d52f4 100644 --- a/docs/nifgen/rep_caps.rst +++ b/docs/nifgen/rep_caps.rst @@ -34,7 +34,6 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. - script_triggers --------------- @@ -60,7 +59,6 @@ script_triggers passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. - markers ------- @@ -86,7 +84,6 @@ markers passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. - data_markers ------------ @@ -112,5 +109,3 @@ data_markers passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. - - diff --git a/docs/nirfsg/rep_caps.rst b/docs/nirfsg/rep_caps.rst index 4b13100dfa..41fa8018dd 100644 --- a/docs/nirfsg/rep_caps.rst +++ b/docs/nirfsg/rep_caps.rst @@ -48,7 +48,6 @@ markers passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. - script_triggers --------------- @@ -74,7 +73,6 @@ script_triggers passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. - waveforms --------- @@ -100,7 +98,6 @@ waveforms passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. - ports ----- @@ -112,7 +109,6 @@ ports passes a string of :python:`'0, 1, 2'` to the set attribute function. - los --- @@ -138,7 +134,6 @@ los passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. - device_temperatures ------------------- @@ -150,7 +145,6 @@ device_temperatures passes a string of :python:`'0, 1, 2'` to the set attribute function. - channels -------- @@ -162,5 +156,3 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. - - diff --git a/docs/niscope/rep_caps.rst b/docs/niscope/rep_caps.rst index 19169bc085..45c220cccc 100644 --- a/docs/niscope/rep_caps.rst +++ b/docs/niscope/rep_caps.rst @@ -34,7 +34,6 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. - instruments ----------- @@ -46,5 +45,3 @@ instruments passes a string of :python:`'0, 1, 2'` to the set attribute function. - - diff --git a/docs/niswitch/rep_caps.rst b/docs/niswitch/rep_caps.rst index 7f141fa26b..c0dde51f4f 100644 --- a/docs/niswitch/rep_caps.rst +++ b/docs/niswitch/rep_caps.rst @@ -34,5 +34,3 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. - - diff --git a/src/nifgen/metadata/attributes.py b/src/nifgen/metadata/attributes.py old mode 100755 new mode 100644 diff --git a/src/nifgen/metadata/config.py b/src/nifgen/metadata/config.py old mode 100755 new mode 100644 diff --git a/src/nifgen/metadata/enums.py b/src/nifgen/metadata/enums.py old mode 100755 new mode 100644 diff --git a/src/nifgen/metadata/functions.py b/src/nifgen/metadata/functions.py old mode 100755 new mode 100644 diff --git a/src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms b/src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms old mode 100755 new mode 100644 diff --git a/src/nirfsg/system_tests/samples2pfile.s2p b/src/nirfsg/system_tests/samples2pfile.s2p old mode 100755 new mode 100644 From 92b5d19f639348467f354d18fea96e36e3e0287e Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 30 Jul 2026 14:11:26 -0500 Subject: [PATCH 04/21] Revert changes to file modes --- build.sh | 0 src/nifgen/metadata/attributes.py | 0 src/nifgen/metadata/config.py | 0 src/nifgen/metadata/enums.py | 0 src/nifgen/metadata/functions.py | 0 src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms | Bin src/nirfsg/system_tests/samples2pfile.s2p | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build.sh mode change 100644 => 100755 src/nifgen/metadata/attributes.py mode change 100644 => 100755 src/nifgen/metadata/config.py mode change 100644 => 100755 src/nifgen/metadata/enums.py mode change 100644 => 100755 src/nifgen/metadata/functions.py mode change 100644 => 100755 src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms mode change 100644 => 100755 src/nirfsg/system_tests/samples2pfile.s2p diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/src/nifgen/metadata/attributes.py b/src/nifgen/metadata/attributes.py old mode 100644 new mode 100755 diff --git a/src/nifgen/metadata/config.py b/src/nifgen/metadata/config.py old mode 100644 new mode 100755 diff --git a/src/nifgen/metadata/enums.py b/src/nifgen/metadata/enums.py old mode 100644 new mode 100755 diff --git a/src/nifgen/metadata/functions.py b/src/nifgen/metadata/functions.py old mode 100644 new mode 100755 diff --git a/src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms b/src/nirfsg/system_tests/ValidWaveformTDMSFile.tdms old mode 100644 new mode 100755 diff --git a/src/nirfsg/system_tests/samples2pfile.s2p b/src/nirfsg/system_tests/samples2pfile.s2p old mode 100644 new mode 100755 From a5b270d349ddb1c56473c4c511473e1b84f3d226 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 30 Jul 2026 14:37:31 -0500 Subject: [PATCH 05/21] remove auto_prefix_addition_supported --- build/templates/rep_caps.rst.mako | 3 +-- build/unit_tests/test_rep_caps_template.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 350cda6b4f..0b9b93c5a1 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -36,7 +36,6 @@ name = rep_cap['python_name'] prefix = rep_cap['prefix'] rep_cap_doc = rep_cap.get('documentation', {}) has_custom_doc = len(rep_cap_doc) > 0 -auto_prefix = rep_cap_doc.get('auto_prefix_addition_supported', len(prefix) > 0) %>\ ${helper.get_rst_header_snippet(name, '-')} @@ -45,7 +44,7 @@ ${helper.get_rst_header_snippet(name, '-')} % if has_custom_doc and 'description' in rep_cap_doc: ${rep_cap_doc['description']} -% elif auto_prefix: +% elif len(prefix) > 0: If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index c19a0662be..05cdf5246a 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -22,7 +22,6 @@ def test_rep_caps_template_uses_custom_documentation_overrides(): 'python_name': 'resources', 'documentation': { 'description': 'Resource repeated capabilities use fully-qualified identifiers.', - 'auto_prefix_addition_supported': False, 'valid_identifiers': ['dev0/res0', 'dev0/res1'], 'examples': [ "session.resources['dev0/res0'].channel_enabled = True", From 9cd734474b4e4bdcb5265d07e46fdeee80dc44e1 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 6 Aug 2026 13:59:44 -0500 Subject: [PATCH 06/21] expanding metadata instead of creating --- build/helper/metadata_add_all.py | 32 ++++++++ build/templates/rep_caps.rst.mako | 39 ++------- build/unit_tests/test_rep_caps_template.py | 25 +++++- docs/nidcpower/rep_caps.rst | 8 +- docs/nidigital/rep_caps.rst | 92 +++++++++++----------- docs/nifgen/rep_caps.rst | 52 ++++++------ docs/nirfsg/rep_caps.rst | 76 +++++++++--------- docs/niscope/rep_caps.rst | 8 +- docs/niswitch/rep_caps.rst | 4 +- src/nifake/metadata/config.py | 8 ++ 10 files changed, 189 insertions(+), 155 deletions(-) diff --git a/build/helper/metadata_add_all.py b/build/helper/metadata_add_all.py index 69132a934f..235ee44f10 100644 --- a/build/helper/metadata_add_all.py +++ b/build/helper/metadata_add_all.py @@ -729,6 +729,38 @@ def add_all_config_metadata(config): ''' config = merge_helper(config, 'config', config, use_re=False) + for repeated_capability in config['repeated_capabilities']: + documentation = repeated_capability.setdefault('documentation', {}) + prefix = repeated_capability['prefix'] + name = repeated_capability['python_name'] + + if prefix: + documentation.setdefault( + 'description', + ( + 'If no prefix is added to the items in the parameter, the correct prefix will be added when\n' + 'the driver function call is made.\n\n' + ".. code:: python\n\n session.{}['0-2'].channel_enabled = True\n\n" + "passes a string of :python:`'{}0, {}1, {}2'` to the set attribute function.\n\n" + 'If an invalid repeated capability is passed to the driver, the driver will return an error.\n\n' + 'You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix\n' + 'for the specific repeated capability.' + ).format(name, prefix, prefix, prefix) + ) + else: + documentation.setdefault('description', '') + + documentation.setdefault( + 'examples', + [ + ( + "session.{}['{}0-{}2'].channel_enabled = True\n\n" + "passes a string of :python:`'{}0, {}1, {}2'` to the set attribute function." + ).format(name, prefix, prefix, prefix, prefix, prefix) + ] + ) + documentation.setdefault('valid_identifiers', []) + if 'use_locking' not in config: config['use_locking'] = True diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 0b9b93c5a1..1571d9c3b4 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -33,53 +33,24 @@ ${helper.get_rst_header_snippet('Repeated Capabilities', '=')} % for rep_cap in config['repeated_capabilities']: <% name = rep_cap['python_name'] -prefix = rep_cap['prefix'] -rep_cap_doc = rep_cap.get('documentation', {}) -has_custom_doc = len(rep_cap_doc) > 0 +rep_cap_doc = rep_cap['documentation'] %>\ ${helper.get_rst_header_snippet(name, '-')} .. py:attribute:: ${module_name}.Session.${name}[] -% if has_custom_doc and 'description' in rep_cap_doc: - ${rep_cap_doc['description']} - -% elif len(prefix) > 0: - If no prefix is added to the items in the parameter, the correct prefix will be added when - the driver function call is made. - - .. code:: python - - session.${name}['0-2'].channel_enabled = True - - passes a string of :python:`'${prefix}0, ${prefix}1, ${prefix}2'` to the set attribute function. - - If an invalid repeated capability is passed to the driver, the driver will return an error. - -% if len(prefix) > 0: - You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix - for the specific repeated capability. +% if rep_cap_doc['description']: + ${rep_cap_doc['description'].replace('\n', '\n ')} % endif -% endif -% if not has_custom_doc or 'examples' not in rep_cap_doc: - .. code:: python - - session.${name}['${prefix}0-${prefix}2'].channel_enabled = True - - passes a string of :python:`'${prefix}0, ${prefix}1, ${prefix}2'` to the set attribute function. - -% endif -% if has_custom_doc and 'valid_identifiers' in rep_cap_doc and len(rep_cap_doc['valid_identifiers']) > 0: +% if rep_cap_doc['valid_identifiers']: Valid identifiers: :python:`'${", ".join(rep_cap_doc["valid_identifiers"])}'`. % endif -% if has_custom_doc and 'examples' in rep_cap_doc and len(rep_cap_doc['examples']) > 0: % for example in rep_cap_doc['examples']: .. code:: python - ${example} + ${example.replace('\n', '\n ')} % endfor -% endif % endfor diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index 05cdf5246a..347297c485 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -2,13 +2,14 @@ from types import SimpleNamespace from mako.template import Template +from build.helper.metadata_add_all import add_all_config_metadata def _render_rep_caps(config): repo_root = Path(__file__).resolve().parents[2] template_path = repo_root / 'build' / 'templates' / 'rep_caps.rst.mako' template = Template(filename=str(template_path)) - metadata = SimpleNamespace(config=config) + metadata = SimpleNamespace(config=add_all_config_metadata(config)) return template.render(template_parameters={'metadata': metadata}) @@ -62,3 +63,25 @@ def test_rep_caps_template_preserves_default_prefixed_behavior(): assert 'If no prefix is added to the items in the parameter' in rendered assert "session.channels['0-2'].channel_enabled = True" in rendered assert "'channel0, channel1, channel2'" in rendered + + +def test_rep_caps_template_expands_default_documentation_fields(): + config = { + 'module_name': 'nifake', + 'c_function_prefix': 'niFake_', + 'repeated_capabilities': [ + { + 'prefix': 'channel', + 'python_name': 'channels', + 'documentation': { + 'description': 'Custom channel documentation.', + }, + } + ], + } + + rendered = _render_rep_caps(config) + + assert 'Custom channel documentation.' in rendered + assert "session.channels['channel0-channel2'].channel_enabled = True" in rendered + assert "'channel0, channel1, channel2'" in rendered diff --git a/docs/nidcpower/rep_caps.rst b/docs/nidcpower/rep_caps.rst index a828f90261..76fa29a033 100644 --- a/docs/nidcpower/rep_caps.rst +++ b/docs/nidcpower/rep_caps.rst @@ -31,8 +31,8 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. instruments ----------- @@ -42,6 +42,6 @@ instruments .. code:: python session.instruments['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. diff --git a/docs/nidigital/rep_caps.rst b/docs/nidigital/rep_caps.rst index 5fc51e899c..01eb7e6efb 100644 --- a/docs/nidigital/rep_caps.rst +++ b/docs/nidigital/rep_caps.rst @@ -31,8 +31,8 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. pins ---- @@ -42,8 +42,8 @@ pins .. code:: python session.pins['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. instruments ----------- @@ -53,131 +53,131 @@ instruments .. code:: python session.instruments['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. pattern_opcode_events --------------------- .. py:attribute:: nidigital.Session.pattern_opcode_events[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.pattern_opcode_events['0-2'].channel_enabled = True - + passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.pattern_opcode_events['patternOpcodeEvent0-patternOpcodeEvent2'].channel_enabled = True - - passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. + + passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. conditional_jump_triggers ------------------------- .. py:attribute:: nidigital.Session.conditional_jump_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.conditional_jump_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.conditional_jump_triggers['conditionalJumpTrigger0-conditionalJumpTrigger2'].channel_enabled = True - - passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. + + passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. sites ----- .. py:attribute:: nidigital.Session.sites[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.sites['0-2'].channel_enabled = True - + passes a string of :python:`'site0, site1, site2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.sites['site0-site2'].channel_enabled = True - - passes a string of :python:`'site0, site1, site2'` to the set attribute function. + + passes a string of :python:`'site0, site1, site2'` to the set attribute function. rio_events ---------- .. py:attribute:: nidigital.Session.rio_events[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.rio_events['0-2'].channel_enabled = True - + passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.rio_events['RIOEvent0-RIOEvent2'].channel_enabled = True - - passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. + + passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. rio_triggers ------------ .. py:attribute:: nidigital.Session.rio_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.rio_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.rio_triggers['RIOTrigger0-RIOTrigger2'].channel_enabled = True - - passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. + + passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. diff --git a/docs/nifgen/rep_caps.rst b/docs/nifgen/rep_caps.rst index 030d3d52f4..7ff8a720a2 100644 --- a/docs/nifgen/rep_caps.rst +++ b/docs/nifgen/rep_caps.rst @@ -31,81 +31,81 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. script_triggers --------------- .. py:attribute:: nifgen.Session.script_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.script_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.script_triggers['ScriptTrigger0-ScriptTrigger2'].channel_enabled = True - - passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. + + passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. markers ------- .. py:attribute:: nifgen.Session.markers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.markers['0-2'].channel_enabled = True - + passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.markers['Marker0-Marker2'].channel_enabled = True - - passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. + + passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. data_markers ------------ .. py:attribute:: nifgen.Session.data_markers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.data_markers['0-2'].channel_enabled = True - + passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.data_markers['DataMarker0-DataMarker2'].channel_enabled = True - - passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. + + passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. diff --git a/docs/nirfsg/rep_caps.rst b/docs/nirfsg/rep_caps.rst index 41fa8018dd..f14b8924ee 100644 --- a/docs/nirfsg/rep_caps.rst +++ b/docs/nirfsg/rep_caps.rst @@ -28,75 +28,75 @@ markers .. py:attribute:: nirfsg.Session.markers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.markers['0-2'].channel_enabled = True - + passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.markers['marker0-marker2'].channel_enabled = True - - passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. + + passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. script_triggers --------------- .. py:attribute:: nirfsg.Session.script_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.script_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.script_triggers['scripttrigger0-scripttrigger2'].channel_enabled = True - - passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. + + passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. waveforms --------- .. py:attribute:: nirfsg.Session.waveforms[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.waveforms['0-2'].channel_enabled = True - + passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.waveforms['waveform::0-waveform::2'].channel_enabled = True - - passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. + + passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. ports ----- @@ -106,33 +106,33 @@ ports .. code:: python session.ports['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. los --- .. py:attribute:: nirfsg.Session.los[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.los['0-2'].channel_enabled = True - + passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. .. code:: python session.los['LO0-LO2'].channel_enabled = True - - passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. + + passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. device_temperatures ------------------- @@ -142,8 +142,8 @@ device_temperatures .. code:: python session.device_temperatures['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. channels -------- @@ -153,6 +153,6 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. diff --git a/docs/niscope/rep_caps.rst b/docs/niscope/rep_caps.rst index 45c220cccc..49086e35df 100644 --- a/docs/niscope/rep_caps.rst +++ b/docs/niscope/rep_caps.rst @@ -31,8 +31,8 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. instruments ----------- @@ -42,6 +42,6 @@ instruments .. code:: python session.instruments['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. diff --git a/docs/niswitch/rep_caps.rst b/docs/niswitch/rep_caps.rst index c0dde51f4f..9b1bad4f86 100644 --- a/docs/niswitch/rep_caps.rst +++ b/docs/niswitch/rep_caps.rst @@ -31,6 +31,6 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. diff --git a/src/nifake/metadata/config.py b/src/nifake/metadata/config.py index ea09207158..183e6f3496 100644 --- a/src/nifake/metadata/config.py +++ b/src/nifake/metadata/config.py @@ -64,6 +64,14 @@ 'python_name': 'channels' }, { + 'documentation': { + 'description': 'Sites are identified by the ``site`` prefix followed by a zero-based index.', + 'valid_identifiers': ['site0', 'site1'], + 'examples': [ + "session.sites['site0'].function_with_repeated_capability_type()", + "session.sites['site0', 'site1'].function_with_repeated_capability_type()", + ], + }, 'prefix': 'site', 'python_name': 'sites' }, From 33883f01c2a9a39871040e0d074d91cdfc938509 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 13 Aug 2026 10:06:11 -0500 Subject: [PATCH 07/21] change repeated capabilities to pass --- build/templates/_converters.py.mako | 10 +++++++++- build/unit_tests/test_metadata_add_all.py | 13 ++++++++++++- build/unit_tests/test_rep_caps_template.py | 2 +- generated/nidcpower/nidcpower/_converters.py | 10 +++++++++- generated/nidigital/nidigital/_converters.py | 10 +++++++++- generated/nidmm/nidmm/_converters.py | 10 +++++++++- generated/nifake/nifake/_converters.py | 10 +++++++++- .../nifake/nifake/unit_tests/test_converters.py | 5 +++++ generated/nifgen/nifgen/_converters.py | 10 +++++++++- generated/nimodinst/nimodinst/_converters.py | 10 +++++++++- generated/nirfsg/nirfsg/_converters.py | 10 +++++++++- generated/niscope/niscope/_converters.py | 10 +++++++++- generated/nise/nise/_converters.py | 10 +++++++++- generated/niswitch/niswitch/_converters.py | 10 +++++++++- generated/nitclk/nitclk/_converters.py | 10 +++++++++- src/nifake/unit_tests/test_converters.py | 5 +++++ 16 files changed, 131 insertions(+), 14 deletions(-) diff --git a/build/templates/_converters.py.mako b/build/templates/_converters.py.mako index 2ee4ba6630..da1422e14d 100644 --- a/build/templates/_converters.py.mako +++ b/build/templates/_converters.py.mako @@ -121,6 +121,11 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -134,7 +139,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/build/unit_tests/test_metadata_add_all.py b/build/unit_tests/test_metadata_add_all.py index fdbf8e1285..76ab4feec9 100644 --- a/build/unit_tests/test_metadata_add_all.py +++ b/build/unit_tests/test_metadata_add_all.py @@ -1008,7 +1008,18 @@ def _compare_dicts(actual, expected): ], 'enum_whitelist_suffix': ['_POINT_FIVE'], 'repeated_capabilities': [ - {'python_name': 'channels', 'prefix': '', }, + { + 'python_name': 'channels', + 'prefix': '', + 'documentation': { + 'description': '', + 'examples': [ + "session.channels['0-2'].channel_enabled = True\n\n" + "passes a string of :python:`'0, 1, 2'` to the set attribute function.", + ], + 'valid_identifiers': [], + }, + }, ], 'use_locking': True, 'functions': functions_expected, diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index 347297c485..4e74ce2a65 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -1,8 +1,8 @@ from pathlib import Path from types import SimpleNamespace -from mako.template import Template from build.helper.metadata_add_all import add_all_config_metadata +from mako.template import Template def _render_rep_caps(config): diff --git a/generated/nidcpower/nidcpower/_converters.py b/generated/nidcpower/nidcpower/_converters.py index 3c80fcb7cc..f2805ac161 100644 --- a/generated/nidcpower/nidcpower/_converters.py +++ b/generated/nidcpower/nidcpower/_converters.py @@ -112,6 +112,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -125,7 +130,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nidigital/nidigital/_converters.py b/generated/nidigital/nidigital/_converters.py index e645ad43d4..3bd1d01a8c 100644 --- a/generated/nidigital/nidigital/_converters.py +++ b/generated/nidigital/nidigital/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nidmm/nidmm/_converters.py b/generated/nidmm/nidmm/_converters.py index 7dcf49ee8f..3e147ad42d 100644 --- a/generated/nidmm/nidmm/_converters.py +++ b/generated/nidmm/nidmm/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nifake/nifake/_converters.py b/generated/nifake/nifake/_converters.py index 9de6fa6942..697688f276 100644 --- a/generated/nifake/nifake/_converters.py +++ b/generated/nifake/nifake/_converters.py @@ -112,6 +112,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -125,7 +130,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nifake/nifake/unit_tests/test_converters.py b/generated/nifake/nifake/unit_tests/test_converters.py index daa0d21963..fb5eac965d 100644 --- a/generated/nifake/nifake/unit_tests/test_converters.py +++ b/generated/nifake/nifake/unit_tests/test_converters.py @@ -92,6 +92,11 @@ def test_repeated_capabilities_string_prefix(): assert test_result_list == ['ScriptTrigger0'] +def test_repeated_capabilities_fully_qualified_string_prefix(): + test_result_list = _converters.convert_repeated_capabilities('PXI1Slot2/tmu0,PXI1Slot2/tmu1', prefix='tmu') + assert test_result_list == ['PXI1Slot2/tmu0', 'PXI1Slot2/tmu1'] + + def test_repeated_capabilities_list_channel(): test_result_list = _converters.convert_repeated_capabilities(['0']) assert test_result_list == ['0'] diff --git a/generated/nifgen/nifgen/_converters.py b/generated/nifgen/nifgen/_converters.py index 1d18df460c..24b7592ff0 100644 --- a/generated/nifgen/nifgen/_converters.py +++ b/generated/nifgen/nifgen/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nimodinst/nimodinst/_converters.py b/generated/nimodinst/nimodinst/_converters.py index 666c3c925e..264cce0a54 100644 --- a/generated/nimodinst/nimodinst/_converters.py +++ b/generated/nimodinst/nimodinst/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nirfsg/nirfsg/_converters.py b/generated/nirfsg/nirfsg/_converters.py index e5c50c04d3..28b518e9f3 100644 --- a/generated/nirfsg/nirfsg/_converters.py +++ b/generated/nirfsg/nirfsg/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/niscope/niscope/_converters.py b/generated/niscope/niscope/_converters.py index 78518a9132..e8edf1c59e 100644 --- a/generated/niscope/niscope/_converters.py +++ b/generated/niscope/niscope/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nise/nise/_converters.py b/generated/nise/nise/_converters.py index 98fd3af425..765922844f 100644 --- a/generated/nise/nise/_converters.py +++ b/generated/nise/nise/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/niswitch/niswitch/_converters.py b/generated/niswitch/niswitch/_converters.py index e72487bda4..64f77b87e1 100644 --- a/generated/niswitch/niswitch/_converters.py +++ b/generated/niswitch/niswitch/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nitclk/nitclk/_converters.py b/generated/nitclk/nitclk/_converters.py index 8c1395257e..736d4585dd 100644 --- a/generated/nitclk/nitclk/_converters.py +++ b/generated/nitclk/nitclk/_converters.py @@ -111,6 +111,11 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) +def _add_repeated_capability_prefix(repeated_capability, prefix): + path, separator, identifier = repeated_capability.rpartition('/') + return path + separator + prefix + identifier + + def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -124,7 +129,10 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + _add_repeated_capability_prefix(repeated_capability, prefix) + for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/src/nifake/unit_tests/test_converters.py b/src/nifake/unit_tests/test_converters.py index daa0d21963..fb5eac965d 100644 --- a/src/nifake/unit_tests/test_converters.py +++ b/src/nifake/unit_tests/test_converters.py @@ -92,6 +92,11 @@ def test_repeated_capabilities_string_prefix(): assert test_result_list == ['ScriptTrigger0'] +def test_repeated_capabilities_fully_qualified_string_prefix(): + test_result_list = _converters.convert_repeated_capabilities('PXI1Slot2/tmu0,PXI1Slot2/tmu1', prefix='tmu') + assert test_result_list == ['PXI1Slot2/tmu0', 'PXI1Slot2/tmu1'] + + def test_repeated_capabilities_list_channel(): test_result_list = _converters.convert_repeated_capabilities(['0']) assert test_result_list == ['0'] From eae401f747f6b16b05a38e80badafcc2e114cd7a Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 20 Aug 2026 13:50:12 -0500 Subject: [PATCH 08/21] remove functional change --- build/templates/_converters.py.mako | 10 +--------- generated/nidcpower/nidcpower/_converters.py | 10 +--------- generated/nidigital/nidigital/_converters.py | 10 +--------- generated/nidmm/nidmm/_converters.py | 10 +--------- generated/nifake/nifake/_converters.py | 10 +--------- generated/nifake/nifake/unit_tests/test_converters.py | 5 ----- generated/nifgen/nifgen/_converters.py | 10 +--------- generated/nimodinst/nimodinst/_converters.py | 10 +--------- generated/nirfsg/nirfsg/_converters.py | 10 +--------- generated/niscope/niscope/_converters.py | 10 +--------- generated/nise/nise/_converters.py | 10 +--------- generated/niswitch/niswitch/_converters.py | 10 +--------- generated/nitclk/nitclk/_converters.py | 10 +--------- src/nifake/unit_tests/test_converters.py | 5 ----- 14 files changed, 12 insertions(+), 118 deletions(-) diff --git a/build/templates/_converters.py.mako b/build/templates/_converters.py.mako index da1422e14d..2ee4ba6630 100644 --- a/build/templates/_converters.py.mako +++ b/build/templates/_converters.py.mako @@ -121,11 +121,6 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -139,10 +134,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nidcpower/nidcpower/_converters.py b/generated/nidcpower/nidcpower/_converters.py index f2805ac161..3c80fcb7cc 100644 --- a/generated/nidcpower/nidcpower/_converters.py +++ b/generated/nidcpower/nidcpower/_converters.py @@ -112,11 +112,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -130,10 +125,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nidigital/nidigital/_converters.py b/generated/nidigital/nidigital/_converters.py index 3bd1d01a8c..e645ad43d4 100644 --- a/generated/nidigital/nidigital/_converters.py +++ b/generated/nidigital/nidigital/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nidmm/nidmm/_converters.py b/generated/nidmm/nidmm/_converters.py index 3e147ad42d..7dcf49ee8f 100644 --- a/generated/nidmm/nidmm/_converters.py +++ b/generated/nidmm/nidmm/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nifake/nifake/_converters.py b/generated/nifake/nifake/_converters.py index 697688f276..9de6fa6942 100644 --- a/generated/nifake/nifake/_converters.py +++ b/generated/nifake/nifake/_converters.py @@ -112,11 +112,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -130,10 +125,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nifake/nifake/unit_tests/test_converters.py b/generated/nifake/nifake/unit_tests/test_converters.py index fb5eac965d..daa0d21963 100644 --- a/generated/nifake/nifake/unit_tests/test_converters.py +++ b/generated/nifake/nifake/unit_tests/test_converters.py @@ -92,11 +92,6 @@ def test_repeated_capabilities_string_prefix(): assert test_result_list == ['ScriptTrigger0'] -def test_repeated_capabilities_fully_qualified_string_prefix(): - test_result_list = _converters.convert_repeated_capabilities('PXI1Slot2/tmu0,PXI1Slot2/tmu1', prefix='tmu') - assert test_result_list == ['PXI1Slot2/tmu0', 'PXI1Slot2/tmu1'] - - def test_repeated_capabilities_list_channel(): test_result_list = _converters.convert_repeated_capabilities(['0']) assert test_result_list == ['0'] diff --git a/generated/nifgen/nifgen/_converters.py b/generated/nifgen/nifgen/_converters.py index 24b7592ff0..1d18df460c 100644 --- a/generated/nifgen/nifgen/_converters.py +++ b/generated/nifgen/nifgen/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nimodinst/nimodinst/_converters.py b/generated/nimodinst/nimodinst/_converters.py index 264cce0a54..666c3c925e 100644 --- a/generated/nimodinst/nimodinst/_converters.py +++ b/generated/nimodinst/nimodinst/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nirfsg/nirfsg/_converters.py b/generated/nirfsg/nirfsg/_converters.py index 28b518e9f3..e5c50c04d3 100644 --- a/generated/nirfsg/nirfsg/_converters.py +++ b/generated/nirfsg/nirfsg/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/niscope/niscope/_converters.py b/generated/niscope/niscope/_converters.py index e8edf1c59e..78518a9132 100644 --- a/generated/niscope/niscope/_converters.py +++ b/generated/niscope/niscope/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nise/nise/_converters.py b/generated/nise/nise/_converters.py index 765922844f..98fd3af425 100644 --- a/generated/nise/nise/_converters.py +++ b/generated/nise/nise/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/niswitch/niswitch/_converters.py b/generated/niswitch/niswitch/_converters.py index 64f77b87e1..e72487bda4 100644 --- a/generated/niswitch/niswitch/_converters.py +++ b/generated/niswitch/niswitch/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/generated/nitclk/nitclk/_converters.py b/generated/nitclk/nitclk/_converters.py index 736d4585dd..8c1395257e 100644 --- a/generated/nitclk/nitclk/_converters.py +++ b/generated/nitclk/nitclk/_converters.py @@ -111,11 +111,6 @@ def ifnone(a, b): return _convert_repeated_capabilities(rng, prefix) -def _add_repeated_capability_prefix(repeated_capability, prefix): - path, separator, identifier = repeated_capability.rpartition('/') - return path + separator + prefix + identifier - - def convert_repeated_capabilities(repeated_capability, prefix=''): '''Convert a repeated capabilities object to a comma delimited list @@ -129,10 +124,7 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [ - _add_repeated_capability_prefix(repeated_capability, prefix) - for repeated_capability in _convert_repeated_capabilities(repeated_capability, prefix) - ] + return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] def convert_repeated_capabilities_without_prefix(repeated_capability): diff --git a/src/nifake/unit_tests/test_converters.py b/src/nifake/unit_tests/test_converters.py index fb5eac965d..daa0d21963 100644 --- a/src/nifake/unit_tests/test_converters.py +++ b/src/nifake/unit_tests/test_converters.py @@ -92,11 +92,6 @@ def test_repeated_capabilities_string_prefix(): assert test_result_list == ['ScriptTrigger0'] -def test_repeated_capabilities_fully_qualified_string_prefix(): - test_result_list = _converters.convert_repeated_capabilities('PXI1Slot2/tmu0,PXI1Slot2/tmu1', prefix='tmu') - assert test_result_list == ['PXI1Slot2/tmu0', 'PXI1Slot2/tmu1'] - - def test_repeated_capabilities_list_channel(): test_result_list = _converters.convert_repeated_capabilities(['0']) assert test_result_list == ['0'] From 53574b6a98ced1f174659708f00b4de86bdaac41 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 20 Aug 2026 14:42:24 -0500 Subject: [PATCH 09/21] testing chained rep caps --- generated/nifake/nifake/unit_tests/test_session.py | 4 ++++ src/nifake/unit_tests/test_session.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/generated/nifake/nifake/unit_tests/test_session.py b/generated/nifake/nifake/unit_tests/test_session.py index 36e45fb06f..94d233ec03 100644 --- a/generated/nifake/nifake/unit_tests/test_session.py +++ b/generated/nifake/nifake/unit_tests/test_session.py @@ -350,6 +350,10 @@ def test_chained_repeated_capabilities_list(self): with nifake.Session('dev1') as session: assert session.sites[0, 1].channels[2, 3]._repeated_capability_list == ['site0/2', 'site0/3', 'site1/2', 'site1/3'] + def test_multi_instrument_chained_repeated_capabilities_list(self): + with nifake.Session('dev1,dev2') as session: + assert session.instruments['dev1', 'dev2'].sites[0, 1]._repeated_capability_list == ['dev1/site0', 'dev1/site1', 'dev2/site0', 'dev2/site1'] + def test_chained_repeated_capability_method_on_specific_channel(self): test_maximum_time_ms = 10 # milliseconds test_maximum_time = hightime.timedelta(milliseconds=test_maximum_time_ms) diff --git a/src/nifake/unit_tests/test_session.py b/src/nifake/unit_tests/test_session.py index 36e45fb06f..94d233ec03 100644 --- a/src/nifake/unit_tests/test_session.py +++ b/src/nifake/unit_tests/test_session.py @@ -350,6 +350,10 @@ def test_chained_repeated_capabilities_list(self): with nifake.Session('dev1') as session: assert session.sites[0, 1].channels[2, 3]._repeated_capability_list == ['site0/2', 'site0/3', 'site1/2', 'site1/3'] + def test_multi_instrument_chained_repeated_capabilities_list(self): + with nifake.Session('dev1,dev2') as session: + assert session.instruments['dev1', 'dev2'].sites[0, 1]._repeated_capability_list == ['dev1/site0', 'dev1/site1', 'dev2/site0', 'dev2/site1'] + def test_chained_repeated_capability_method_on_specific_channel(self): test_maximum_time_ms = 10 # milliseconds test_maximum_time = hightime.timedelta(milliseconds=test_maximum_time_ms) From 4b2ab0dcbb184337ec6df3a2bbb281f83a409f80 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Sun, 23 Aug 2026 14:51:25 -0500 Subject: [PATCH 10/21] fixing whitespace/code sections --- build/templates/rep_caps.rst.mako | 6 +++- build/unit_tests/test_rep_caps_template.py | 13 +++++++-- docs/nidcpower/rep_caps.rst | 8 +++--- docs/nidigital/rep_caps.rst | 32 +++++++++++----------- docs/nifgen/rep_caps.rst | 16 +++++------ docs/nirfsg/rep_caps.rst | 28 +++++++++---------- docs/niscope/rep_caps.rst | 8 +++--- docs/niswitch/rep_caps.rst | 4 +-- 8 files changed, 63 insertions(+), 52 deletions(-) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 1571d9c3b4..7de7d622b5 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -50,7 +50,11 @@ ${helper.get_rst_header_snippet(name, '-')} % for example in rep_cap_doc['examples']: .. code:: python - ${example.replace('\n', '\n ')} + ${example.split('\n\n', 1)[0].replace('\n', '\n ')} +% if '\n\n' in example: + ${example.split('\n\n', 1)[1].replace('\n', '\n ')} + +% endif % endfor % endfor diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index 4e74ce2a65..d603d16e29 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -1,16 +1,19 @@ from pathlib import Path +from tempfile import TemporaryDirectory from types import SimpleNamespace +from build.generate_template import generate_template from build.helper.metadata_add_all import add_all_config_metadata -from mako.template import Template def _render_rep_caps(config): repo_root = Path(__file__).resolve().parents[2] template_path = repo_root / 'build' / 'templates' / 'rep_caps.rst.mako' - template = Template(filename=str(template_path)) metadata = SimpleNamespace(config=add_all_config_metadata(config)) - return template.render(template_parameters={'metadata': metadata}) + with TemporaryDirectory() as temp_dir: + output_path = Path(temp_dir) / 'rep_caps.rst' + generate_template(str(template_path), {'metadata': metadata}, str(output_path)) + return output_path.read_text() def test_rep_caps_template_uses_custom_documentation_overrides(): @@ -63,6 +66,10 @@ def test_rep_caps_template_preserves_default_prefixed_behavior(): assert 'If no prefix is added to the items in the parameter' in rendered assert "session.channels['0-2'].channel_enabled = True" in rendered assert "'channel0, channel1, channel2'" in rendered + assert ( + " session.channels['0-2'].channel_enabled = True\n \n" + " passes a string of :python:`'channel0, channel1, channel2'` to the set attribute function." + ) in rendered def test_rep_caps_template_expands_default_documentation_fields(): diff --git a/docs/nidcpower/rep_caps.rst b/docs/nidcpower/rep_caps.rst index 76fa29a033..a828f90261 100644 --- a/docs/nidcpower/rep_caps.rst +++ b/docs/nidcpower/rep_caps.rst @@ -31,8 +31,8 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. instruments ----------- @@ -42,6 +42,6 @@ instruments .. code:: python session.instruments['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. diff --git a/docs/nidigital/rep_caps.rst b/docs/nidigital/rep_caps.rst index 01eb7e6efb..d06d862583 100644 --- a/docs/nidigital/rep_caps.rst +++ b/docs/nidigital/rep_caps.rst @@ -31,8 +31,8 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. pins ---- @@ -42,8 +42,8 @@ pins .. code:: python session.pins['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. instruments ----------- @@ -53,8 +53,8 @@ instruments .. code:: python session.instruments['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. pattern_opcode_events --------------------- @@ -78,8 +78,8 @@ pattern_opcode_events .. code:: python session.pattern_opcode_events['patternOpcodeEvent0-patternOpcodeEvent2'].channel_enabled = True - - passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. + + passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. conditional_jump_triggers ------------------------- @@ -103,8 +103,8 @@ conditional_jump_triggers .. code:: python session.conditional_jump_triggers['conditionalJumpTrigger0-conditionalJumpTrigger2'].channel_enabled = True - - passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. + + passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. sites ----- @@ -128,8 +128,8 @@ sites .. code:: python session.sites['site0-site2'].channel_enabled = True - - passes a string of :python:`'site0, site1, site2'` to the set attribute function. + + passes a string of :python:`'site0, site1, site2'` to the set attribute function. rio_events ---------- @@ -153,8 +153,8 @@ rio_events .. code:: python session.rio_events['RIOEvent0-RIOEvent2'].channel_enabled = True - - passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. + + passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. rio_triggers ------------ @@ -178,6 +178,6 @@ rio_triggers .. code:: python session.rio_triggers['RIOTrigger0-RIOTrigger2'].channel_enabled = True - - passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. + + passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. diff --git a/docs/nifgen/rep_caps.rst b/docs/nifgen/rep_caps.rst index 7ff8a720a2..cf675a8531 100644 --- a/docs/nifgen/rep_caps.rst +++ b/docs/nifgen/rep_caps.rst @@ -31,8 +31,8 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. script_triggers --------------- @@ -56,8 +56,8 @@ script_triggers .. code:: python session.script_triggers['ScriptTrigger0-ScriptTrigger2'].channel_enabled = True - - passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. + + passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. markers ------- @@ -81,8 +81,8 @@ markers .. code:: python session.markers['Marker0-Marker2'].channel_enabled = True - - passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. + + passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. data_markers ------------ @@ -106,6 +106,6 @@ data_markers .. code:: python session.data_markers['DataMarker0-DataMarker2'].channel_enabled = True - - passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. + + passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. diff --git a/docs/nirfsg/rep_caps.rst b/docs/nirfsg/rep_caps.rst index f14b8924ee..02fe19b935 100644 --- a/docs/nirfsg/rep_caps.rst +++ b/docs/nirfsg/rep_caps.rst @@ -45,8 +45,8 @@ markers .. code:: python session.markers['marker0-marker2'].channel_enabled = True - - passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. + + passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. script_triggers --------------- @@ -70,8 +70,8 @@ script_triggers .. code:: python session.script_triggers['scripttrigger0-scripttrigger2'].channel_enabled = True - - passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. + + passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. waveforms --------- @@ -95,8 +95,8 @@ waveforms .. code:: python session.waveforms['waveform::0-waveform::2'].channel_enabled = True - - passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. + + passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. ports ----- @@ -106,8 +106,8 @@ ports .. code:: python session.ports['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. los --- @@ -131,8 +131,8 @@ los .. code:: python session.los['LO0-LO2'].channel_enabled = True - - passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. + + passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. device_temperatures ------------------- @@ -142,8 +142,8 @@ device_temperatures .. code:: python session.device_temperatures['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. channels -------- @@ -153,6 +153,6 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. diff --git a/docs/niscope/rep_caps.rst b/docs/niscope/rep_caps.rst index 49086e35df..45c220cccc 100644 --- a/docs/niscope/rep_caps.rst +++ b/docs/niscope/rep_caps.rst @@ -31,8 +31,8 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. instruments ----------- @@ -42,6 +42,6 @@ instruments .. code:: python session.instruments['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. diff --git a/docs/niswitch/rep_caps.rst b/docs/niswitch/rep_caps.rst index 9b1bad4f86..c0dde51f4f 100644 --- a/docs/niswitch/rep_caps.rst +++ b/docs/niswitch/rep_caps.rst @@ -31,6 +31,6 @@ channels .. code:: python session.channels['0-2'].channel_enabled = True - - passes a string of :python:`'0, 1, 2'` to the set attribute function. + + passes a string of :python:`'0, 1, 2'` to the set attribute function. From 8e16ee13a49dee82c4c551859e794f208732fad8 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Mon, 24 Aug 2026 10:59:05 -0500 Subject: [PATCH 11/21] change to use valid_indices instead of valid_identifiers --- build/helper/metadata_add_all.py | 2 +- build/templates/rep_caps.rst.mako | 4 ++-- build/unit_tests/test_metadata_add_all.py | 2 +- build/unit_tests/test_rep_caps_template.py | 4 ++-- src/nifake/metadata/config.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/helper/metadata_add_all.py b/build/helper/metadata_add_all.py index 235ee44f10..46989b4e5d 100644 --- a/build/helper/metadata_add_all.py +++ b/build/helper/metadata_add_all.py @@ -759,7 +759,7 @@ def add_all_config_metadata(config): ).format(name, prefix, prefix, prefix, prefix, prefix) ] ) - documentation.setdefault('valid_identifiers', []) + documentation.setdefault('valid_indices', []) if 'use_locking' not in config: config['use_locking'] = True diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 7de7d622b5..f201f2addf 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -43,8 +43,8 @@ ${helper.get_rst_header_snippet(name, '-')} ${rep_cap_doc['description'].replace('\n', '\n ')} % endif -% if rep_cap_doc['valid_identifiers']: - Valid identifiers: :python:`'${", ".join(rep_cap_doc["valid_identifiers"])}'`. +% if rep_cap_doc['valid_indices']: + Valid Indices: :python:`'${", ".join(rep_cap_doc["valid_indices"])}'`. % endif % for example in rep_cap_doc['examples']: diff --git a/build/unit_tests/test_metadata_add_all.py b/build/unit_tests/test_metadata_add_all.py index 76ab4feec9..36aceb5890 100644 --- a/build/unit_tests/test_metadata_add_all.py +++ b/build/unit_tests/test_metadata_add_all.py @@ -1017,7 +1017,7 @@ def _compare_dicts(actual, expected): "session.channels['0-2'].channel_enabled = True\n\n" "passes a string of :python:`'0, 1, 2'` to the set attribute function.", ], - 'valid_identifiers': [], + 'valid_indices': [], }, }, ], diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index d603d16e29..13462b2e8d 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -26,7 +26,7 @@ def test_rep_caps_template_uses_custom_documentation_overrides(): 'python_name': 'resources', 'documentation': { 'description': 'Resource repeated capabilities use fully-qualified identifiers.', - 'valid_identifiers': ['dev0/res0', 'dev0/res1'], + 'valid_indices': ['dev0/res0', 'dev0/res1'], 'examples': [ "session.resources['dev0/res0'].channel_enabled = True", "session.resources['dev0/res1'].channel_enabled = True", @@ -39,7 +39,7 @@ def test_rep_caps_template_uses_custom_documentation_overrides(): rendered = _render_rep_caps(config) assert 'Resource repeated capabilities use fully-qualified identifiers.' in rendered - assert "Valid identifiers: :python:`'dev0/res0, dev0/res1'`." in rendered + assert "Valid Indices: :python:`'dev0/res0, dev0/res1'`." in rendered assert "session.resources['dev0/res0'].channel_enabled = True" in rendered assert "session.resources['dev0/res1'].channel_enabled = True" in rendered diff --git a/src/nifake/metadata/config.py b/src/nifake/metadata/config.py index 183e6f3496..089da081bf 100644 --- a/src/nifake/metadata/config.py +++ b/src/nifake/metadata/config.py @@ -66,7 +66,7 @@ { 'documentation': { 'description': 'Sites are identified by the ``site`` prefix followed by a zero-based index.', - 'valid_identifiers': ['site0', 'site1'], + 'valid_indices': ['site0', 'site1'], 'examples': [ "session.sites['site0'].function_with_repeated_capability_type()", "session.sites['site0', 'site1'].function_with_repeated_capability_type()", From 6d34dbaae49595d9727d2f33d6fe784ab6352e79 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Tue, 25 Aug 2026 13:25:29 -0500 Subject: [PATCH 12/21] fixing bolding of first line of rep_caps --- build/templates/rep_caps.rst.mako | 2 +- docs/nidigital/rep_caps.rst | 10 +++++----- docs/nifgen/rep_caps.rst | 6 +++--- docs/nirfsg/rep_caps.rst | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index f201f2addf..9dcc163c70 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -40,7 +40,7 @@ ${helper.get_rst_header_snippet(name, '-')} .. py:attribute:: ${module_name}.Session.${name}[] % if rep_cap_doc['description']: - ${rep_cap_doc['description'].replace('\n', '\n ')} + ${rep_cap_doc['description'].replace('\n', '\n ')} % endif % if rep_cap_doc['valid_indices']: diff --git a/docs/nidigital/rep_caps.rst b/docs/nidigital/rep_caps.rst index d06d862583..2819d40ed8 100644 --- a/docs/nidigital/rep_caps.rst +++ b/docs/nidigital/rep_caps.rst @@ -61,7 +61,7 @@ pattern_opcode_events .. py:attribute:: nidigital.Session.pattern_opcode_events[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -86,7 +86,7 @@ conditional_jump_triggers .. py:attribute:: nidigital.Session.conditional_jump_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -111,7 +111,7 @@ sites .. py:attribute:: nidigital.Session.sites[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -136,7 +136,7 @@ rio_events .. py:attribute:: nidigital.Session.rio_events[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -161,7 +161,7 @@ rio_triggers .. py:attribute:: nidigital.Session.rio_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python diff --git a/docs/nifgen/rep_caps.rst b/docs/nifgen/rep_caps.rst index cf675a8531..c9691c7d44 100644 --- a/docs/nifgen/rep_caps.rst +++ b/docs/nifgen/rep_caps.rst @@ -39,7 +39,7 @@ script_triggers .. py:attribute:: nifgen.Session.script_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -64,7 +64,7 @@ markers .. py:attribute:: nifgen.Session.markers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -89,7 +89,7 @@ data_markers .. py:attribute:: nifgen.Session.data_markers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python diff --git a/docs/nirfsg/rep_caps.rst b/docs/nirfsg/rep_caps.rst index 02fe19b935..1c9a2ac1ac 100644 --- a/docs/nirfsg/rep_caps.rst +++ b/docs/nirfsg/rep_caps.rst @@ -28,7 +28,7 @@ markers .. py:attribute:: nirfsg.Session.markers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -53,7 +53,7 @@ script_triggers .. py:attribute:: nirfsg.Session.script_triggers[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -78,7 +78,7 @@ waveforms .. py:attribute:: nirfsg.Session.waveforms[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python @@ -114,7 +114,7 @@ los .. py:attribute:: nirfsg.Session.los[] - If no prefix is added to the items in the parameter, the correct prefix will be added when + If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. .. code:: python From 3108727dad019109f6730d823f1ec6bd35da5bbb Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Tue, 25 Aug 2026 13:50:18 -0500 Subject: [PATCH 13/21] change nifake from keys to indices --- src/nifake/metadata/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nifake/metadata/config.py b/src/nifake/metadata/config.py index 089da081bf..47c0275696 100644 --- a/src/nifake/metadata/config.py +++ b/src/nifake/metadata/config.py @@ -66,7 +66,7 @@ { 'documentation': { 'description': 'Sites are identified by the ``site`` prefix followed by a zero-based index.', - 'valid_indices': ['site0', 'site1'], + 'valid_indices': ['0', '1', '2', '3', '4'], 'examples': [ "session.sites['site0'].function_with_repeated_capability_type()", "session.sites['site0', 'site1'].function_with_repeated_capability_type()", From 2fed2e448edb8cb4995d18ba2b43a0143068bf02 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Tue, 25 Aug 2026 15:39:23 -0500 Subject: [PATCH 14/21] make whitespace more consistent --- build/templates/rep_caps.rst.mako | 5 ++- build/unit_tests/test_rep_caps_template.py | 8 ++-- docs/nidigital/rep_caps.rst | 50 +++++++++++----------- docs/nifgen/rep_caps.rst | 30 ++++++------- docs/nirfsg/rep_caps.rst | 40 ++++++++--------- 5 files changed, 68 insertions(+), 65 deletions(-) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 9dcc163c70..24733900a0 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -1,5 +1,6 @@ <% import build.helper as helper + import re config = template_parameters['metadata'].config module_name = config['module_name'] @@ -40,7 +41,7 @@ ${helper.get_rst_header_snippet(name, '-')} .. py:attribute:: ${module_name}.Session.${name}[] % if rep_cap_doc['description']: - ${rep_cap_doc['description'].replace('\n', '\n ')} + ${' ' + re.sub(r'\n(?=[^\n])', '\n ', rep_cap_doc['description'])} % endif % if rep_cap_doc['valid_indices']: @@ -53,7 +54,7 @@ ${helper.get_rst_header_snippet(name, '-')} ${example.split('\n\n', 1)[0].replace('\n', '\n ')} % if '\n\n' in example: - ${example.split('\n\n', 1)[1].replace('\n', '\n ')} + ${' ' + re.sub(r'\n(?=[^\n])', '\n ', example.split('\n\n', 1)[1])} % endif % endfor diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index 13462b2e8d..a04d3273f0 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -66,10 +66,12 @@ def test_rep_caps_template_preserves_default_prefixed_behavior(): assert 'If no prefix is added to the items in the parameter' in rendered assert "session.channels['0-2'].channel_enabled = True" in rendered assert "'channel0, channel1, channel2'" in rendered - assert ( - " session.channels['0-2'].channel_enabled = True\n \n" + example_description = ( " passes a string of :python:`'channel0, channel1, channel2'` to the set attribute function." - ) in rendered + ) + assert rendered.count(example_description) == 2 + assert '\n passes a string' not in rendered + assert not any(line.isspace() for line in rendered.splitlines()) def test_rep_caps_template_expands_default_documentation_fields(): diff --git a/docs/nidigital/rep_caps.rst b/docs/nidigital/rep_caps.rst index 2819d40ed8..5fc51e899c 100644 --- a/docs/nidigital/rep_caps.rst +++ b/docs/nidigital/rep_caps.rst @@ -63,15 +63,15 @@ pattern_opcode_events If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.pattern_opcode_events['0-2'].channel_enabled = True - + passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -88,15 +88,15 @@ conditional_jump_triggers If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.conditional_jump_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -113,15 +113,15 @@ sites If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.sites['0-2'].channel_enabled = True - + passes a string of :python:`'site0, site1, site2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -138,15 +138,15 @@ rio_events If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.rio_events['0-2'].channel_enabled = True - + passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -163,15 +163,15 @@ rio_triggers If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.rio_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. diff --git a/docs/nifgen/rep_caps.rst b/docs/nifgen/rep_caps.rst index c9691c7d44..030d3d52f4 100644 --- a/docs/nifgen/rep_caps.rst +++ b/docs/nifgen/rep_caps.rst @@ -41,15 +41,15 @@ script_triggers If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.script_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -66,15 +66,15 @@ markers If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.markers['0-2'].channel_enabled = True - + passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -91,15 +91,15 @@ data_markers If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.data_markers['0-2'].channel_enabled = True - + passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. diff --git a/docs/nirfsg/rep_caps.rst b/docs/nirfsg/rep_caps.rst index 1c9a2ac1ac..41fa8018dd 100644 --- a/docs/nirfsg/rep_caps.rst +++ b/docs/nirfsg/rep_caps.rst @@ -30,15 +30,15 @@ markers If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.markers['0-2'].channel_enabled = True - + passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -55,15 +55,15 @@ script_triggers If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.script_triggers['0-2'].channel_enabled = True - + passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -80,15 +80,15 @@ waveforms If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.waveforms['0-2'].channel_enabled = True - + passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. @@ -116,15 +116,15 @@ los If no prefix is added to the items in the parameter, the correct prefix will be added when the driver function call is made. - + .. code:: python - + session.los['0-2'].channel_enabled = True - + passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. - + If an invalid repeated capability is passed to the driver, the driver will return an error. - + You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix for the specific repeated capability. From 6a5105ad4a645df99f74d707fff6992a8de17e5c Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Tue, 25 Aug 2026 16:17:01 -0500 Subject: [PATCH 15/21] fix whitespace and pull from main --- build/templates/rep_caps.rst.mako | 2 ++ build/unit_tests/test_rep_caps_template.py | 6 ++++++ docs/nidcpower/rep_caps.rst | 3 +++ docs/nidigital/rep_caps.rst | 9 +++++++++ docs/nifgen/rep_caps.rst | 5 +++++ docs/nirfsg/rep_caps.rst | 8 ++++++++ docs/niscope/rep_caps.rst | 3 +++ docs/niswitch/rep_caps.rst | 2 ++ 8 files changed, 38 insertions(+) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 24733900a0..b85af0af2b 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -58,4 +58,6 @@ ${helper.get_rst_header_snippet(name, '-')} % endif % endfor + % endfor + diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index a04d3273f0..3c503b4503 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -57,6 +57,10 @@ def test_rep_caps_template_preserves_default_prefixed_behavior(): { 'prefix': 'channel', 'python_name': 'channels', + }, + { + 'prefix': '', + 'python_name': 'instruments', } ], } @@ -71,6 +75,8 @@ def test_rep_caps_template_preserves_default_prefixed_behavior(): ) assert rendered.count(example_description) == 2 assert '\n passes a string' not in rendered + assert "set attribute function.\n\n\ninstruments\n" in rendered + assert rendered.endswith('\n\n\n\n') assert not any(line.isspace() for line in rendered.splitlines()) diff --git a/docs/nidcpower/rep_caps.rst b/docs/nidcpower/rep_caps.rst index a828f90261..6078e4deab 100644 --- a/docs/nidcpower/rep_caps.rst +++ b/docs/nidcpower/rep_caps.rst @@ -34,6 +34,7 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. + instruments ----------- @@ -45,3 +46,5 @@ instruments passes a string of :python:`'0, 1, 2'` to the set attribute function. + + diff --git a/docs/nidigital/rep_caps.rst b/docs/nidigital/rep_caps.rst index 5fc51e899c..32550fc4f8 100644 --- a/docs/nidigital/rep_caps.rst +++ b/docs/nidigital/rep_caps.rst @@ -34,6 +34,7 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. + pins ---- @@ -45,6 +46,7 @@ pins passes a string of :python:`'0, 1, 2'` to the set attribute function. + instruments ----------- @@ -56,6 +58,7 @@ instruments passes a string of :python:`'0, 1, 2'` to the set attribute function. + pattern_opcode_events --------------------- @@ -81,6 +84,7 @@ pattern_opcode_events passes a string of :python:`'patternOpcodeEvent0, patternOpcodeEvent1, patternOpcodeEvent2'` to the set attribute function. + conditional_jump_triggers ------------------------- @@ -106,6 +110,7 @@ conditional_jump_triggers passes a string of :python:`'conditionalJumpTrigger0, conditionalJumpTrigger1, conditionalJumpTrigger2'` to the set attribute function. + sites ----- @@ -131,6 +136,7 @@ sites passes a string of :python:`'site0, site1, site2'` to the set attribute function. + rio_events ---------- @@ -156,6 +162,7 @@ rio_events passes a string of :python:`'RIOEvent0, RIOEvent1, RIOEvent2'` to the set attribute function. + rio_triggers ------------ @@ -181,3 +188,5 @@ rio_triggers passes a string of :python:`'RIOTrigger0, RIOTrigger1, RIOTrigger2'` to the set attribute function. + + diff --git a/docs/nifgen/rep_caps.rst b/docs/nifgen/rep_caps.rst index 030d3d52f4..5890a432ea 100644 --- a/docs/nifgen/rep_caps.rst +++ b/docs/nifgen/rep_caps.rst @@ -34,6 +34,7 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. + script_triggers --------------- @@ -59,6 +60,7 @@ script_triggers passes a string of :python:`'ScriptTrigger0, ScriptTrigger1, ScriptTrigger2'` to the set attribute function. + markers ------- @@ -84,6 +86,7 @@ markers passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function. + data_markers ------------ @@ -109,3 +112,5 @@ data_markers passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function. + + diff --git a/docs/nirfsg/rep_caps.rst b/docs/nirfsg/rep_caps.rst index 41fa8018dd..4b13100dfa 100644 --- a/docs/nirfsg/rep_caps.rst +++ b/docs/nirfsg/rep_caps.rst @@ -48,6 +48,7 @@ markers passes a string of :python:`'marker0, marker1, marker2'` to the set attribute function. + script_triggers --------------- @@ -73,6 +74,7 @@ script_triggers passes a string of :python:`'scripttrigger0, scripttrigger1, scripttrigger2'` to the set attribute function. + waveforms --------- @@ -98,6 +100,7 @@ waveforms passes a string of :python:`'waveform::0, waveform::1, waveform::2'` to the set attribute function. + ports ----- @@ -109,6 +112,7 @@ ports passes a string of :python:`'0, 1, 2'` to the set attribute function. + los --- @@ -134,6 +138,7 @@ los passes a string of :python:`'LO0, LO1, LO2'` to the set attribute function. + device_temperatures ------------------- @@ -145,6 +150,7 @@ device_temperatures passes a string of :python:`'0, 1, 2'` to the set attribute function. + channels -------- @@ -156,3 +162,5 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. + + diff --git a/docs/niscope/rep_caps.rst b/docs/niscope/rep_caps.rst index 45c220cccc..19169bc085 100644 --- a/docs/niscope/rep_caps.rst +++ b/docs/niscope/rep_caps.rst @@ -34,6 +34,7 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. + instruments ----------- @@ -45,3 +46,5 @@ instruments passes a string of :python:`'0, 1, 2'` to the set attribute function. + + diff --git a/docs/niswitch/rep_caps.rst b/docs/niswitch/rep_caps.rst index c0dde51f4f..7f141fa26b 100644 --- a/docs/niswitch/rep_caps.rst +++ b/docs/niswitch/rep_caps.rst @@ -34,3 +34,5 @@ channels passes a string of :python:`'0, 1, 2'` to the set attribute function. + + From b24a22fc1ea2a77a480c109fdf7a744d74f69973 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Wed, 26 Aug 2026 15:56:15 -0500 Subject: [PATCH 16/21] use textwrap --- build/templates/rep_caps.rst.mako | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index b85af0af2b..7b0fb26a81 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -1,6 +1,6 @@ <% import build.helper as helper - import re + import textwrap config = template_parameters['metadata'].config module_name = config['module_name'] @@ -41,7 +41,7 @@ ${helper.get_rst_header_snippet(name, '-')} .. py:attribute:: ${module_name}.Session.${name}[] % if rep_cap_doc['description']: - ${' ' + re.sub(r'\n(?=[^\n])', '\n ', rep_cap_doc['description'])} +${textwrap.indent(rep_cap_doc['description'], ' ')} % endif % if rep_cap_doc['valid_indices']: @@ -54,7 +54,7 @@ ${helper.get_rst_header_snippet(name, '-')} ${example.split('\n\n', 1)[0].replace('\n', '\n ')} % if '\n\n' in example: - ${' ' + re.sub(r'\n(?=[^\n])', '\n ', example.split('\n\n', 1)[1])} +${textwrap.indent(example.split('\n\n', 1)[1], ' ')} % endif % endfor From 99e7fb43943c0e22ddfe7bd525660e83b8da4843 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Wed, 26 Aug 2026 15:56:48 -0500 Subject: [PATCH 17/21] fix comment --- build/unit_tests/test_rep_caps_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index 3c503b4503..120e52cd1d 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -16,7 +16,7 @@ def _render_rep_caps(config): return output_path.read_text() -def test_rep_caps_template_uses_custom_documentation_overrides(): +def test_custom_documentation_overwrites_rep_caps_template_defaults(): config = { 'module_name': 'nifake', 'c_function_prefix': 'niFake_', @@ -43,7 +43,7 @@ def test_rep_caps_template_uses_custom_documentation_overrides(): assert "session.resources['dev0/res0'].channel_enabled = True" in rendered assert "session.resources['dev0/res1'].channel_enabled = True" in rendered - # Generic auto-prefix guidance should be suppressed when override disables it. + # Custom documentation should overwrite the generic auto-prefix guidance. assert 'If no prefix is added to the items in the parameter' not in rendered assert "session.resources['0-2'].channel_enabled = True" not in rendered assert "'res0, res1, res2'" not in rendered From 8bfd38877edf9c6da80a42824fb5e27ed0f06693 Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Wed, 26 Aug 2026 15:58:23 -0500 Subject: [PATCH 18/21] going to be overwritten metadata --- src/nifake/metadata/config.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/nifake/metadata/config.py b/src/nifake/metadata/config.py index 47c0275696..ea09207158 100644 --- a/src/nifake/metadata/config.py +++ b/src/nifake/metadata/config.py @@ -64,14 +64,6 @@ 'python_name': 'channels' }, { - 'documentation': { - 'description': 'Sites are identified by the ``site`` prefix followed by a zero-based index.', - 'valid_indices': ['0', '1', '2', '3', '4'], - 'examples': [ - "session.sites['site0'].function_with_repeated_capability_type()", - "session.sites['site0', 'site1'].function_with_repeated_capability_type()", - ], - }, 'prefix': 'site', 'python_name': 'sites' }, From 0bec19d51d7e32eecaf0b4c720aff114843216bd Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Wed, 26 Aug 2026 17:04:06 -0500 Subject: [PATCH 19/21] different test than default --- build/unit_tests/test_metadata_add_all.py | 45 +++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/build/unit_tests/test_metadata_add_all.py b/build/unit_tests/test_metadata_add_all.py index 36aceb5890..7ce53f93fd 100644 --- a/build/unit_tests/test_metadata_add_all.py +++ b/build/unit_tests/test_metadata_add_all.py @@ -961,9 +961,7 @@ def _compare_dicts(actual, expected): }, ], 'enum_whitelist_suffix': ['_POINT_FIVE'], - 'repeated_capabilities': [ - {'python_name': 'channels', 'prefix': '', }, - ], + 'repeated_capabilities': [], # These are added here strictly for testing. 'functions': {}, 'attributes': {}, @@ -1007,20 +1005,7 @@ def _compare_dicts(actual, expected): }, ], 'enum_whitelist_suffix': ['_POINT_FIVE'], - 'repeated_capabilities': [ - { - 'python_name': 'channels', - 'prefix': '', - 'documentation': { - 'description': '', - 'examples': [ - "session.channels['0-2'].channel_enabled = True\n\n" - "passes a string of :python:`'0, 1, 2'` to the set attribute function.", - ], - 'valid_indices': [], - }, - }, - ], + 'repeated_capabilities': [], 'use_locking': True, 'functions': functions_expected, 'attributes': attributes_expected, @@ -1032,6 +1017,26 @@ def _compare_dicts(actual, expected): } +config_with_custom_rep_cap_documentation = copy.deepcopy(config_input) +config_with_custom_rep_cap_documentation['repeated_capabilities'] = [ + { + 'python_name': 'resources', + 'prefix': 'res', + 'documentation': { + 'description': 'Resources use fully-qualified identifiers.', + 'examples': ["session.resources['dev0/res0'].channel_enabled = True"], + 'valid_indices': ['dev0/res0', 'dev0/res1'], + }, + }, +] + + +config_with_custom_rep_cap_documentation_expected = copy.deepcopy(config_expected) +config_with_custom_rep_cap_documentation_expected['repeated_capabilities'] = copy.deepcopy( + config_with_custom_rep_cap_documentation['repeated_capabilities'] +) + + def _do_the_test_add_functions_metadata(functions, expected): actual = copy.deepcopy(functions) actual = add_all_function_metadata(actual, config_input) @@ -1084,9 +1089,11 @@ def test_add_all_metadata(): actual_functions = copy.deepcopy(functions_input) actual_attributes = copy.deepcopy(attributes_input) actual_enums = copy.deepcopy(enums_input) - actual_config = copy.deepcopy(config_input) + # actual_config = copy.deepcopy(config_input) + actual_config = copy.deepcopy(config_with_custom_rep_cap_documentation) actual_config['use_locking'] = False - expected = copy.deepcopy(config_expected) + expected = copy.deepcopy(config_with_custom_rep_cap_documentation_expected) + # expected = copy.deepcopy(config_expected) expected['use_locking'] = False _do_the_test_add_all_metadata( functions=actual_functions, From d4a11063129bc6259912aa87921b1635dd438c2b Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 27 Aug 2026 10:06:20 -0500 Subject: [PATCH 20/21] fixes from PR Comments --- build/helper/metadata_add_all.py | 10 ++++++---- build/templates/rep_caps.rst.mako | 6 +++--- build/unit_tests/test_metadata_add_all.py | 9 ++++++--- build/unit_tests/test_rep_caps_template.py | 20 +++++++++++++++++--- 4 files changed, 32 insertions(+), 13 deletions(-) diff --git a/build/helper/metadata_add_all.py b/build/helper/metadata_add_all.py index 46989b4e5d..f28de7d9d8 100644 --- a/build/helper/metadata_add_all.py +++ b/build/helper/metadata_add_all.py @@ -753,10 +753,12 @@ def add_all_config_metadata(config): documentation.setdefault( 'examples', [ - ( - "session.{}['{}0-{}2'].channel_enabled = True\n\n" - "passes a string of :python:`'{}0, {}1, {}2'` to the set attribute function." - ).format(name, prefix, prefix, prefix, prefix, prefix) + { + 'code': "session.{}['{}0-{}2'].channel_enabled = True".format(name, prefix, prefix), + 'description': ( + "passes a string of :python:`'{}0, {}1, {}2'` to the set attribute function." + ).format(prefix, prefix, prefix), + } ] ) documentation.setdefault('valid_indices', []) diff --git a/build/templates/rep_caps.rst.mako b/build/templates/rep_caps.rst.mako index 7b0fb26a81..d95948fae6 100644 --- a/build/templates/rep_caps.rst.mako +++ b/build/templates/rep_caps.rst.mako @@ -51,10 +51,10 @@ ${textwrap.indent(rep_cap_doc['description'], ' ')} % for example in rep_cap_doc['examples']: .. code:: python - ${example.split('\n\n', 1)[0].replace('\n', '\n ')} +${textwrap.indent(example['code'], ' ')} -% if '\n\n' in example: -${textwrap.indent(example.split('\n\n', 1)[1], ' ')} +% if example['description']: +${textwrap.indent(example['description'], ' ')} % endif % endfor diff --git a/build/unit_tests/test_metadata_add_all.py b/build/unit_tests/test_metadata_add_all.py index 7ce53f93fd..252155c66f 100644 --- a/build/unit_tests/test_metadata_add_all.py +++ b/build/unit_tests/test_metadata_add_all.py @@ -1024,7 +1024,12 @@ def _compare_dicts(actual, expected): 'prefix': 'res', 'documentation': { 'description': 'Resources use fully-qualified identifiers.', - 'examples': ["session.resources['dev0/res0'].channel_enabled = True"], + 'examples': [ + { + 'code': "session.resources['dev0/res0'].channel_enabled = True", + 'description': 'Enables the first resource.', + } + ], 'valid_indices': ['dev0/res0', 'dev0/res1'], }, }, @@ -1089,11 +1094,9 @@ def test_add_all_metadata(): actual_functions = copy.deepcopy(functions_input) actual_attributes = copy.deepcopy(attributes_input) actual_enums = copy.deepcopy(enums_input) - # actual_config = copy.deepcopy(config_input) actual_config = copy.deepcopy(config_with_custom_rep_cap_documentation) actual_config['use_locking'] = False expected = copy.deepcopy(config_with_custom_rep_cap_documentation_expected) - # expected = copy.deepcopy(config_expected) expected['use_locking'] = False _do_the_test_add_all_metadata( functions=actual_functions, diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index 120e52cd1d..5f6bec4873 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -28,8 +28,20 @@ def test_custom_documentation_overwrites_rep_caps_template_defaults(): 'description': 'Resource repeated capabilities use fully-qualified identifiers.', 'valid_indices': ['dev0/res0', 'dev0/res1'], 'examples': [ - "session.resources['dev0/res0'].channel_enabled = True", - "session.resources['dev0/res1'].channel_enabled = True", + { + 'code': ( + "session.resources['dev0/res0'].channel_enabled = True\n" + "session.resources['dev0/res1'].channel_enabled = True" + ), + 'description': ( + 'The first line enables resource 0.\n' + 'The second line enables resource 1.' + ), + }, + { + 'code': "session.resources['dev0/res2'].channel_enabled = True", + 'description': '', + }, ], }, } @@ -42,8 +54,10 @@ def test_custom_documentation_overwrites_rep_caps_template_defaults(): assert "Valid Indices: :python:`'dev0/res0, dev0/res1'`." in rendered assert "session.resources['dev0/res0'].channel_enabled = True" in rendered assert "session.resources['dev0/res1'].channel_enabled = True" in rendered + assert "session.resources['dev0/res2'].channel_enabled = True" in rendered + assert ' The first line enables resource 0.\n The second line enables resource 1.' in rendered - # Custom documentation should overwrite the generic auto-prefix guidance. + # Custom documentation should override the generic auto-prefix guidance. assert 'If no prefix is added to the items in the parameter' not in rendered assert "session.resources['0-2'].channel_enabled = True" not in rendered assert "'res0, res1, res2'" not in rendered From 26b3c1b5678a2aef56f6ab01fe5a37b5cb86d83c Mon Sep 17 00:00:00 2001 From: elebel-emerson Date: Thu, 27 Aug 2026 15:51:25 -0500 Subject: [PATCH 21/21] Stop testing indentations --- build/unit_tests/test_rep_caps_template.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/unit_tests/test_rep_caps_template.py b/build/unit_tests/test_rep_caps_template.py index 5f6bec4873..b7c1a8c960 100644 --- a/build/unit_tests/test_rep_caps_template.py +++ b/build/unit_tests/test_rep_caps_template.py @@ -55,7 +55,8 @@ def test_custom_documentation_overwrites_rep_caps_template_defaults(): assert "session.resources['dev0/res0'].channel_enabled = True" in rendered assert "session.resources['dev0/res1'].channel_enabled = True" in rendered assert "session.resources['dev0/res2'].channel_enabled = True" in rendered - assert ' The first line enables resource 0.\n The second line enables resource 1.' in rendered + assert 'The first line enables resource 0.' in rendered + assert 'The second line enables resource 1.' in rendered # Custom documentation should override the generic auto-prefix guidance. assert 'If no prefix is added to the items in the parameter' not in rendered