bids-specification icon indicating copy to clipboard operation
bids-specification copied to clipboard

[ENH] Add macro to generate enum tables filtered by tags

Open ree-gupta opened this issue 3 months ago • 2 comments

Currently, some documentation manually maintain duplicate enum tables when the values already exist in schema definitions with tags.

Proposal:

Add a macro that generates tables from existing enum definitions filtered by tag:

{{ MACROS___make_enum_table("type__channels", "microephys") }}

Functionality:

  1. Takes column definition (for example, type__channels)
  2. Filters enums by tag (for example, microephys)
  3. Generates formatted table automatically

Example:

Instead of manually listing microelectrophysiology (#1705 ) channel types like LFP, HP, MUA in documentation, the macro would pull all microephys-tagged enums from the type__channels definition automatically.

Backwards compatibility: This is a documentation enhancement that doesn't change the specification itself, so it's fully backwards compatible.

Mock example:

Current manual approach:

| Value | Description |
|-------|-------------|
| LFP   | Local field potential |
| HP    | High-pass filtered signal |
| MUA   | Multi-unit activity |

Proposed macro approach:

{{ MACROS___make_enum_table("type__channels", "microephys") }}

This would automatically generate the same table by pulling from the schema.

ree-gupta avatar Sep 04 '25 14:09 ree-gupta

Sounds like a great idea!

The places to implement this would be:

  • Rendering code: https://github.com/bids-standard/bids-specification/blob/master/tools/schemacode/src/bidsschematools/render/tables.py
  • Wrapper: https://github.com/bids-standard/bids-specification/blob/master/tools/mkdocs_macros_bids/macros.py
  • Macro definition: https://github.com/bids-standard/bids-specification/blob/master/tools/mkdocs_macros_bids/main.py

effigies avatar Sep 04 '25 15:09 effigies

Thanks for links! I will try to implement it then.

ree-gupta avatar Sep 04 '25 15:09 ree-gupta