Skip to content

Commit ae7fd3a

Browse files
committed
Merge remote-tracking branch 'upstream/maint/1.10.1'
2 parents 6d002b2 + 3d0f1c6 commit ae7fd3a

File tree

14 files changed

+156
-43
lines changed

14 files changed

+156
-43
lines changed

mkdocs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ nav:
5151
- Website: https://bids.neuroimaging.io/getting_started/
5252
- Tutorials: https://bids.neuroimaging.io/getting_started/tutorials/
5353
- GitHub repository: https://github.com/bids-standard/bids-starter-kit
54+
exclude_docs: |
55+
README.md
56+
pregh-changes.md
5457
theme:
5558
name: material
5659
favicon: images/favicon.png

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ dependencies = [
55
"bidsschematools[render]",
66
"mkdocs>=1.1.0",
77
"mkdocs-material>=5.4",
8-
"pymdown-extensions>=7.0.0",
8+
"pymdown-extensions>=9.2.0",
99
"mkdocs-branchcustomization-plugin~=0.1.3",
1010
"mkdocs-macros-plugin",
1111
"mkdocs-redirects",
@@ -60,3 +60,7 @@ replace = """NEXT_VERSION_HERE
6060
- '{new_version}'
6161
- """
6262
include_bumps = ['pre_label']
63+
64+
[[tool.mypy.overrides]]
65+
module = ["pymdownx.*"]
66+
ignore_missing_imports = true

src/common-principles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ Example:
591591
```
592592

593593
Each level can be described with a string as in the example above,
594-
or with an object containing the fields [`Description`](./glossary.md#description-metadata)
594+
or with an object containing the fields [`Description`](./glossary.md#description-sense-1-metadata)
595595
and [`TermURL`](./glossary.md#termurl-metadata)
596596
like in the example below.
597597

src/derivatives/imaging.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ standard BIDS labels:
548548

549549
```tsv
550550
index name abbreviation
551-
137 pars opercularis IFGop
552-
138 pars triangularis IFGtr
553-
139 pars orbitalis IFGor
551+
137 pars opercularis IFGop
552+
138 pars triangularis IFGtr
553+
139 pars orbitalis IFGor
554554
```
555555

556556
<!-- Link Definitions -->

src/modality-specific-files/microscopy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ Additional optional columns MAY be used to describe other subjects' attributes.
420420
`participants.tsv` example:
421421
```tsv
422422
participant_id species strain strain_rrid
423-
sub-01 mus musculus C57BL/6J RRID:IMSR_JAX:000664
424-
sub-02 mus musculus C57BL/6J RRID:IMSR_JAX:000664
423+
sub-01 mus musculus C57BL/6J RRID:IMSR_JAX:000664
424+
sub-02 mus musculus C57BL/6J RRID:IMSR_JAX:000664
425425
```
426426

427427
`participants.json` example:

src/modality-specific-files/positron-emission-tomography.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ Knudsen et al. 2020
314314
recommends recording participant body weight.
315315
If recorded once per participant, these data SHOULD be included in the
316316
[Participants file](../modality-agnostic-files/data-summary-files.md#participants-file) or as
317-
[Phenotypic and assessment data](../modality-agnostic-files/data-summary-files.md#phenotypic-and-assessment-data).
317+
[Phenotypic and assessment data](../modality-agnostic-files/phenotypic-and-assessment-data.md#phenotypic-and-assessment-data).
318318

319319
For example:
320320

tools/schemacode/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ render = [
4343
"tabulate",
4444
"pandas",
4545
"markdown-it-py",
46+
"pymdown-extensions>=9.2",
4647
]
4748
tests = [
4849
"bidsschematools[validation,render,expressions]",

tools/schemacode/src/bidsschematools/render/tables.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def _make_object_table(
7373
# except for subobjects (if table_type) and
7474
# "additional columns" (field_name.startswith("**"))
7575
if table_type and not field_name.startswith("**"):
76-
field_name = f"[{field_name}]({GLOSSARY_PATH}.md#objects.{table_type}.{element})"
76+
sub = table_type if table_type != "subobject" else "metadata"
77+
field_name = f"[{field_name}]({GLOSSARY_PATH}.md#objects.{sub}.{element})"
7778

7879
# Grab any requirement level information and text to be added to the description string
7980
requirement_info, description_addendum = field_info[element]["table_info"]
@@ -297,6 +298,10 @@ def make_entity_table(schema, tablefmt="github", src_path=None, **kwargs):
297298
formats = ["Format"]
298299
table = [formats]
299300

301+
suffix_map = {
302+
obj.value: key for key, obj in schema.objects.suffixes.items()
303+
}
304+
300305
# Compose header and formats first
301306
for long_name in schema.rules.entities:
302307
entity = schema.objects.entities[long_name]
@@ -320,7 +325,7 @@ def make_entity_table(schema, tablefmt="github", src_path=None, **kwargs):
320325

321326
for (dtype, entities), suffixes in rows.items():
322327
suf_str = " ".join(
323-
f"[{suffix}]({GLOSSARY_PATH}.md#objects.suffixes.{suffix})" for suffix in suffixes
328+
f"[{suffix}]({GLOSSARY_PATH}.md#objects.suffixes.{suffix_map[suffix]})" for suffix in suffixes
324329
)
325330
# TODO: <br> is specific for html form
326331
fmt_str = f"[{dtype}]({GLOSSARY_PATH}.md#objects.datatypes.{dtype})<br>({suf_str})"

tools/schemacode/src/bidsschematools/render/text.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def make_glossary(schema, src_path=None):
152152
if obj_desc is None:
153153
raise ValueError(f"{obj_marker} has no description.")
154154

155+
if "sense 1" in obj_key:
156+
text += f'\n<a name="{obj_marker.split("__", 1)[0]}"></a>'
155157
text += f'\n<a name="{obj_marker}"></a>'
156158
text += f"\n## {obj_key}\n\n"
157159
text += f"**Name**: {obj_def['display_name']}\n\n"

tools/schemacode/src/bidsschematools/render/tsv.py

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
from markdown_it import MarkdownIt
88
from tabulate import tabulate
99

10+
from ..utils import filter_warnings, in_context
11+
from .utils import propagate_fence_exception
1012

13+
14+
@in_context(filter_warnings(["error"]))
15+
@propagate_fence_exception
1116
def fence(
1217
source: str,
1318
language: str,
@@ -27,32 +32,26 @@ def fence(
2732

2833
classes[:0] = ["tsv-table", "index" if linenums else "noindex"]
2934

30-
try:
31-
df = pd.read_csv(
32-
io.StringIO(source),
33-
sep="\t",
34-
dtype=str,
35-
index_col=False,
36-
keep_default_na=False,
37-
header=None if "noheader" in attrs else "infer",
38-
)
39-
md_table = tabulate(
40-
df, # type: ignore
41-
tablefmt="github",
42-
showindex=linenums,
43-
headers="keys",
44-
numalign="right",
45-
)
46-
html = MarkdownIt("commonmark").enable("table").render(md_table)
47-
if "noheader" in attrs:
48-
html = re.sub("<thead>.+</thead>", "", html, flags=re.DOTALL)
49-
50-
html = html.replace("<table>", f'<table class="{" ".join(classes)}">')
51-
52-
# Remove newlines from HTML to prevent copy-paste from inserting spaces
53-
return html.replace("\n", "")
54-
except Exception:
55-
import traceback
56-
57-
exc = traceback.format_exc()
58-
return f"<pre>{exc}</pre>"
35+
df = pd.read_csv(
36+
io.StringIO(source),
37+
sep="\t",
38+
dtype=str,
39+
index_col=False,
40+
keep_default_na=False,
41+
header=None if "noheader" in attrs else "infer",
42+
)
43+
md_table = tabulate(
44+
df, # type: ignore
45+
tablefmt="github",
46+
showindex=linenums,
47+
headers="keys",
48+
numalign="right",
49+
)
50+
html = MarkdownIt("commonmark").enable("table").render(md_table)
51+
if "noheader" in attrs:
52+
html = re.sub("<thead>.+</thead>", "", html, flags=re.DOTALL)
53+
54+
html = html.replace("<table>", f'<table class="{" ".join(classes)}">')
55+
56+
# Remove newlines from HTML to prevent copy-paste from inserting spaces
57+
return html.replace("\n", "")

0 commit comments

Comments
 (0)