From f51a271201ce8f1598a35c64d131ba02691401d3 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Fri, 15 Nov 2024 13:33:46 +0100 Subject: [PATCH] [ENH] generate separate page for each BEP (#569) --- .gitignore | 1 + .remarkignore | 1 + data/beps/beps.yml | 128 ++++++++++++++++++++++-------- docs/extensions/beps.md | 4 +- makefile | 5 +- templates/bep_page_md.jinja | 75 +++++++++++++++++ templates/beps_table_md.jinja | 11 +-- tools/build/generate_bep_pages.py | 43 ++++++++++ 8 files changed, 227 insertions(+), 41 deletions(-) create mode 100644 templates/bep_page_md.jinja create mode 100644 tools/build/generate_bep_pages.py diff --git a/.gitignore b/.gitignore index 8ad61f9a..a96dba9c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ bep_leads.tsv output_gh_summary.png .all-contributorsrc +docs/extensions/beps # ignore for now files that are copied from the bids examples and spe docs/examples/ diff --git a/.remarkignore b/.remarkignore index 4f78c206..bb5f71d8 100644 --- a/.remarkignore +++ b/.remarkignore @@ -1,3 +1,4 @@ docs/collaboration/bids_github/ docs/datasets/examples.md docs/extensions/macros_doc.md +docs/extensions/beps diff --git a/data/beps/beps.yml b/data/beps/beps.yml index 7dacad52..a2c1350f 100644 --- a/data/beps/beps.yml +++ b/data/beps/beps.yml @@ -2,26 +2,32 @@ # template # - number: # title: -# display -# link: +# display: +# google_doc: +# pull_request: +# html_preview: # leads: # # MUST match given-names and family-names from the bids specification citation.cff # - given-names: ' ' # family-names: ' ' +# bids_maintainers: +# - given-names: ' ' +# family-names: ' ' # status: # blocking: +# communication_channel: # pull_request_created: # pull_request_merged: - number: '004' title: Susceptibility Weighted Imaging - link: https://docs.google.com/document/d/1kyw9mGgacNqeMbp4xZet3RnDhcMmf4_BmRgKaOkO2Sc/ + google_doc: https://docs.google.com/document/d/1kyw9mGgacNqeMbp4xZet3RnDhcMmf4_BmRgKaOkO2Sc/ content: - raw leads: - given-names: ' ' family-names: ' ' - email: + bids_maintainers: status: blocking: - Looking for a new leader. @@ -31,14 +37,18 @@ - number: '011' title: Structural preprocessing derivatives - link: https://docs.google.com/document/d/1YG2g4UkEio4t_STIBOqYOwneLEs1emHIXbGKynx7V0Y/ + google_doc: https://docs.google.com/document/d/1YG2g4UkEio4t_STIBOqYOwneLEs1emHIXbGKynx7V0Y/ + pull_request: https://github.com/bids-standard/bids-specification/pull/518 + html_preview: https://bids-specification--518.org.readthedocs.build/en/518/05-derivatives/04-structural-derivatives.html content: - derivative leads: - given-names: Viviana family-names: Siless + bids_maintainers: + - given-names: Christopher J. + family-names: Markiewicz status: - - '[**HTML preview**](https://bids-specification--518.org.readthedocs.build/en/518/05-derivatives/04-structural-derivatives.html)' - Stability! (We haven't touched it in a bit.) blocking: - Staleness! (We haven't touched it in a bit.) @@ -49,14 +59,18 @@ - number: '012' title: Functional preprocessing derivatives - link: https://github.com/bids-standard/bids-specification/pull/519 + google_doc: + pull_request: https://github.com/bids-standard/bids-specification/pull/519 + html_preview: https://bids-specification--519.org.readthedocs.build/en/519/derivatives/functional-derivatives.html content: - derivative leads: + - given-names: Christopher J. + family-names: Markiewicz + bids_maintainers: - given-names: Christopher J. family-names: Markiewicz status: - - '[**HTML preview**](https://bids-specification--519.org.readthedocs.build/en/519/derivatives/functional-derivatives.html)' - Moderate reworking, post-BEP23 meeting. "boldmap" suffix. - Schema implemented; waiting on full schema validation to merge. blocking: @@ -68,12 +82,15 @@ - number: '014' title: Affine transformations and nonlinear field warps - link: https://docs.google.com/document/d/11gCzXOPUbYyuQx8fErtMO9tnOKC3kTWiL9axWkkILNE/ + google_doc: https://docs.google.com/document/d/11gCzXOPUbYyuQx8fErtMO9tnOKC3kTWiL9axWkkILNE/ content: - derivative leads: - given-names: Oscar family-names: Esteban + bids_maintainers: + - given-names: Christopher J. + family-names: Markiewicz status: - After the kick-off meeting (2019), progress locked on developing a prototype of a new HDF5-based format (X5) - Minor bug fixes and features to support more transforms @@ -88,7 +105,7 @@ - number: '016' title: Diffusion weighted imaging derivatives - link: https://github.com/bids-standard/bids-bep016 + pull_request: https://github.com/bids-standard/bids-bep016 content: - derivative leads: @@ -96,6 +113,7 @@ family-names: Pestilli - given-names: Oscar family-names: Esteban + bids_maintainers: status: - adapted general spatial derivatives proposal, meaning using map, like `dwimap` - decided on using `params-` to denote different file types, for example `param-md` or `param-fa` @@ -108,13 +126,14 @@ - number: '017' title: Generic BIDS connectivity data schema display: Connectivity schema - link: https://docs.google.com/document/d/1ugBdUF6dhElXdj3u9vw0iWjE6f_Bibsro3ah7sRV0GA/ + google_doc: https://docs.google.com/document/d/1ugBdUF6dhElXdj3u9vw0iWjE6f_Bibsro3ah7sRV0GA/ content: - derivative leads: - given-names: Eugene P. family-names: Duff email: eugene.duff@paediatrics.ox.ac.uk + bids_maintainers: status: - specified different formats for dense and sparse matrices - 'proposed arrays in h5 or zarr to cover multi-dimensional matrices (for example: dynamic connectivity)' @@ -126,7 +145,8 @@ - number: '020' title: Eye Tracking including Gaze Position and Pupil Size display: Eye Tracking - link: https://github.com/bids-standard/bids-specification/pull/1128 + pull_request: https://github.com/bids-standard/bids-specification/pull/1128 + html_preview: https://bids-specification--1128.org.readthedocs.build/en/1128/modality-specific-files/physiological-recordings.html#eye-tracking content: - raw leads: @@ -134,18 +154,24 @@ family-names: Draschkow - given-names: Martin family-names: Szinte + bids_maintainers: + - given-names: Rémi + family-names: Gau status: - 'Revision of physiology and continuous recordings: clarification of current specs and `_stim` files moved into tasks specification' - Working on an eye tracking data converter - Generation of BIDS-examples blocking: + communication_channel: https://matrix.to/#/#bids-bep020:matrix.org google_doc_created: 2018-04 pull_request_created: 2022-06 pull_request_merged: - number: '021' title: Common Electrophysiological Derivatives - link: https://docs.google.com/document/d/1PmcVs7vg7Th-cGC-UrX8rAhKUHIzOI-uIOh69_mvdlw/ + google_doc: https://docs.google.com/document/d/1PmcVs7vg7Th-cGC-UrX8rAhKUHIzOI-uIOh69_mvdlw/ + pull_request: https://github.com/bids-standard/bids-specification/pull/1680 + html_preview: https://bids-specification.readthedocs.io/en/bep021/derivatives/ephys.html content: - derivative leads: @@ -164,7 +190,6 @@ - given-names: Christine family-names: Rogers status: - - '[**HTML preview**](https://bids-specification.readthedocs.io/en/bep021/derivatives/ephys.html)' - 'Focus on raw-ish data: channels by time: epoching, filtering, interpolation...' - 'All provenance tracking: outsourced to BEP028 (“provenance”)' - Re-using existing (raw) data formats where applicable @@ -179,7 +204,7 @@ - number: '023' title: PET Preprocessing derivatives - link: https://docs.google.com/document/d/1yzsd1J9GT-aA0DWhdlgNr5LCu6_gvbjLyfvYq2FuxlY/ + google_doc: https://docs.google.com/document/d/1yzsd1J9GT-aA0DWhdlgNr5LCu6_gvbjLyfvYq2FuxlY/ content: - derivative leads: @@ -189,6 +214,9 @@ family-names: Searle - given-names: Melanie family-names: Ganz-Benjaminsen + bids_maintainers: + - given-names: Anthony + family-names: Galassi status: - Defined all the necessary components to be included in the specification - Alignment with other modalities obtained at Copenhagen BIDS derivatives meeting @@ -205,12 +233,13 @@ - number: '024' title: Computed Tomography scan - link: https://docs.google.com/document/d/1fqnJZ18x5LJC8jiJ8yvPHUGFzNBZ6gW2kywYrUKWtuo/ + google_doc: https://docs.google.com/document/d/1fqnJZ18x5LJC8jiJ8yvPHUGFzNBZ6gW2kywYrUKWtuo/ content: - raw leads: - given-names: Hugo family-names: Boniface + bids_maintainers: status: - Lead seeking more contributors and experts. blocking: @@ -220,13 +249,13 @@ - number: '026' title: Microelectrode Recordings - link: https://docs.google.com/document/d/14KC1d5-Lx-7ZSMtwS7pVAAvz-2WR_uoo5FvsNirzqJw/ + google_doc: https://docs.google.com/document/d/14KC1d5-Lx-7ZSMtwS7pVAAvz-2WR_uoo5FvsNirzqJw/ content: - raw leads: - given-names: ' ' family-names: ' ' - email: + bids_maintainers: status: - BEP is open to new leadership, see also [BEP032 (animal electrophys)](https://docs.google.com/document/d/1oG-C8T-dWPqfVzL2W8HO3elWK8NIh2cOCPssRGv23n0/) blocking: @@ -237,7 +266,7 @@ - number: '028' title: Provenance - link: https://docs.google.com/document/d/1vw3VNDof5cecv2PkFp7Lw_pNUTUo8-m8V4SIdtGJVKs/ + google_doc: https://docs.google.com/document/d/1vw3VNDof5cecv2PkFp7Lw_pNUTUo8-m8V4SIdtGJVKs/ content: - metadata leads: @@ -245,6 +274,7 @@ family-names: Ghosh - given-names: Camille family-names: Maumet + bids_maintainers: status: - '[Specification](https://bids.neuroimaging.io/bep028)' - '[Set of examples](https://github.com/bids-standard/BEP028_BIDSprov)' @@ -257,7 +287,9 @@ - number: '032' title: Animal electrophysiology - link: https://docs.google.com/document/d/1oG-C8T-dWPqfVzL2W8HO3elWK8NIh2cOCPssRGv23n0/ + google_doc: https://docs.google.com/document/d/1oG-C8T-dWPqfVzL2W8HO3elWK8NIh2cOCPssRGv23n0/ + pull_request: https://github.com/bids-standard/bids-specification/pull/1705 + html_preview: https://bids-specification--1705.org.readthedocs.build/en/1705/modality-specific-files/microelectrode-electrophysiology.html content: - raw leads: @@ -265,8 +297,10 @@ family-names: Takerkart - given-names: Benjamin family-names: Dichter + bids_maintainers: + - given-names: Rémi + family-names: Gau status: - - '[**HTML preview**](https://bids-specification--1705.org.readthedocs.build/en/1705/modality-specific-files/microelectrode-electrophysiology.html)' - Decided on the new name, modalities, datatypes - Nearly finalized added metadata - 'Target: finalize & merge PR into the BIDS specs in Fall 2024' @@ -278,7 +312,7 @@ - number: '033' title: Advanced Diffusion Weighted Imaging - link: https://docs.google.com/document/d/1en4ByORlPqwDfZwNOOBTj0GwpYBcS0_2peqreTOvwDU/ + google_doc: https://docs.google.com/document/d/1en4ByORlPqwDfZwNOOBTj0GwpYBcS0_2peqreTOvwDU/ content: - raw leads: @@ -288,6 +322,7 @@ family-names: Beltrachini - given-names: Filip family-names: Szczepankiewicz + bids_maintainers: status: - 'New BEP, seeking contributors and collecting community feedback relating to: priority sequences to support, best supported binary structured formats (e.g. CBOR? HDF5? MsgPack?).' @@ -300,7 +335,8 @@ - number: '034' title: Computational modeling - link: https://github.com/bids-standard/bids-specification/pull/967 + pull_request: https://github.com/bids-standard/bids-specification/pull/967 + html_preview: https://bids-specification--967.org.readthedocs.build/en/967/modality-specific-files/computational-models.html content: - derivative - metadata @@ -309,6 +345,7 @@ family-names: Schirner - given-names: Petra family-names: Ritter + bids_maintainers: status: - sim2bids app created - easier to bring neural simulation data (especially in The Virtual Brain format) into the proposed BIDS Comp Model format @@ -323,7 +360,7 @@ - number: '035' title: Modular extensions for individual participant data mega-analyses with non-compliant derivatives display: Mega-analyses - link: https://docs.google.com/document/d/1tFRNumQyIgjXBNC3brFDLO9FaikjL84noxK6Om-Ctik/ + google_doc: https://docs.google.com/document/d/1tFRNumQyIgjXBNC3brFDLO9FaikjL84noxK6Om-Ctik/ content: - derivative leads: @@ -333,6 +370,9 @@ family-names: Kincses - given-names: Tamas family-names: Spisak + bids_maintainers: + - given-names: Rémi + family-names: Gau status: - Meta-data harmonization with a term-mapper goes to BEP043 - 'Persperctive: Repeated community review of the simplified proposal' @@ -344,7 +384,7 @@ - number: '036' title: Phenotypic Data Guidelines - link: https://docs.google.com/document/d/1WTkfES8L0vItZVyyR68fc-9cO03jS-kCnMnw6602pbc/ + google_doc: https://docs.google.com/document/d/1WTkfES8L0vItZVyyR68fc-9cO03jS-kCnMnw6602pbc/ content: - raw leads: @@ -354,6 +394,9 @@ family-names: Guay - given-names: Sebastian family-names: Urchs + bids_maintainers: + - given-names: Rémi + family-names: Gau status: - Dropping “Segregated” data format in favor of “Aggregated” blocking: @@ -364,7 +407,7 @@ - number: '037' title: Non-Invasive Brain Stimulation - link: https://docs.google.com/document/d/1drYd7kaNbHTcYPR3T_CRDsPcEbFSV7JbJUmhMPeWMqY/ + google_doc: https://docs.google.com/document/d/1drYd7kaNbHTcYPR3T_CRDsPcEbFSV7JbJUmhMPeWMqY/ content: - raw leads: @@ -376,6 +419,9 @@ family-names: Miniussi - given-names: Marta family-names: Bortoletto + bids_maintainers: + - given-names: Rémi + family-names: Gau status: - Updated BEP structure that eliminates new `.json` or `.tsv` - Stimulation parameters and hardware will be integrated in the `events.tsv` and `events.json ` @@ -387,7 +433,7 @@ - number: '038' title: Atlases - link: https://docs.google.com/document/d/1RxW4cARr3-EiBEcXjLpSIVidvnUSHE7yJCUY91i5TfM/ + google_doc: https://docs.google.com/document/d/1RxW4cARr3-EiBEcXjLpSIVidvnUSHE7yJCUY91i5TfM/ content: - raw leads: @@ -400,6 +446,7 @@ email: eugene.duff@paediatrics.ox.ac.uk - given-names: Anthony family-names: Galassi + bids_maintainers: status: - consolidation of different proposals - atlases defined by template/reference space and modalities @@ -411,7 +458,7 @@ - number: '039' title: Dimensionality reduction-based networks - link: https://docs.google.com/document/d/1GTWsj0MFQedXjOaNk6H0or6IDVFyMAysrJ9I4Zmpz2E/ + google_doc: https://docs.google.com/document/d/1GTWsj0MFQedXjOaNk6H0or6IDVFyMAysrJ9I4Zmpz2E/ content: - raw leads: @@ -425,6 +472,7 @@ family-names: Pestilli - given-names: Peer family-names: Herholz + bids_maintainers: status: - adapted general spatial derivatives proposal, meaning using `map`, for example `eegmap` and `boldmap` for spatial components - decided on `model-` and `items-` as keys to denote the utilized model and component number, if files are 3D, respectively @@ -436,7 +484,7 @@ - number: '040' title: Functional Ultrasound - link: https://docs.google.com/document/d/1W3z01mf1E8cfg_OY7ZGqeUeOKv659jCHQBXavtmT-T8/ + google_doc: https://docs.google.com/document/d/1W3z01mf1E8cfg_OY7ZGqeUeOKv659jCHQBXavtmT-T8/ content: - raw leads: @@ -446,6 +494,9 @@ family-names: Diebolt - given-names: Thomas family-names: Deffieux + bids_maintainers: + - given-names: Rémi + family-names: Gau status: - All issues raised on the original BEP have been resolved. - Regular meetings with contributors scheduled. @@ -460,10 +511,13 @@ - number: '041' title: Statistical Model Derivatives - link: https://docs.google.com/document/d/1KHzp-yk8KXvkUIhtN71WU0m4P4kKT9C1yvI-i9_kNeY/ + google_doc: https://docs.google.com/document/d/1KHzp-yk8KXvkUIhtN71WU0m4P4kKT9C1yvI-i9_kNeY/ content: - derivative leads: + - given-names: Taylor + family-names: Salo + bids_maintainers: - given-names: Taylor family-names: Salo status: @@ -476,12 +530,13 @@ - number: '042' title: Electromyography - link: https://docs.google.com/document/d/1G5_Eu2OemcZXS9xOGINPA6SUTaZOml7LBmZCMnUhTXA/ + google_doc: https://docs.google.com/document/d/1G5_Eu2OemcZXS9xOGINPA6SUTaZOml7LBmZCMnUhTXA/ content: - raw leads: - given-names: Seyed family-names: Yahya Shirazi + bids_maintainers: status: - Approved on May 2024, inviting collaborators (please join) - BEP will follow EEG-BIDS with EMG-specific metadata, etc. @@ -493,10 +548,15 @@ - number: '043' title: BIDS Term Mapping - link: https://docs.google.com/document/d/1LACjc5hFXDpa2l_QddBPR41Vce_gglGv9WeuBB7LsBU/ + google_doc: https://docs.google.com/document/d/1LACjc5hFXDpa2l_QddBPR41Vce_gglGv9WeuBB7LsBU/ content: - metadata leads: + - given-names: Christopher J. + family-names: Markiewicz + - given-names: Eric A. + family-names: Earl + bids_maintainers: - given-names: Christopher J. family-names: Markiewicz - given-names: Eric A. @@ -512,6 +572,7 @@ - number: '044' title: Stimuli + google_doc: https://docs.google.com/document/d/1DoQghbJlQksCHEFs0boT816p3ejX2Hd9l-OWDTXFtV8/edit leads: - given-names: Seyed family-names: Yahya Shirazi @@ -523,6 +584,9 @@ family-names: Robbins - given-names: Scott family-names: Makeig + bids_maintainers: + - given-names: Rémi + family-names: Gau update: | - To harmonize and make more reusable stimuli content under stimuli/. - Collecting community comments and feedback. All collaborators are welcome. diff --git a/docs/extensions/beps.md b/docs/extensions/beps.md index 4a17c5b8..5687f704 100644 --- a/docs/extensions/beps.md +++ b/docs/extensions/beps.md @@ -2,6 +2,8 @@ You can contribute to ongoing BIDS Extension Proposals (BEPs). +## Active BEPs + Below is a table of currently-active BEPs. Note that all of the extension ideas that are not backwards compatible and thus will have to wait for BIDS 2.0 are listed on the @@ -25,7 +27,7 @@ https://facelessuser.github.io/pymdown-extensions/extensions/snippets/#snippets- {{ MACROS___generate_beps_table(file="beps_completed.yml", type="completed") }} -
+## Others Some proposals that set out to extend the BIDS specification have instead lead to other outcomes such as: diff --git a/makefile b/makefile index 1693697e..fe5952b3 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ all: update serve: update mkdocs serve -a localhost:8080 -update: update_from_spec update_contributors update_datasets_examples tmp_figures +update: update_from_spec update_contributors update_datasets_examples tmp_figures update_bep_pages package.json: npm install `cat npm-requirements.txt` @@ -23,6 +23,9 @@ update_datasets_examples: @echo " ---------------------------------- " python data/datasets/examples/tools/print_dataset_listing.py docs/datasets/examples.md +update_bep_pages: + @echo " ---------------------------------- " + python tools/build/generate_bep_pages.py # Figures .PHONY: tmp/affiliations.html tmp/bids_timeline.html tmp/citation_per_year.html tmp/openneuro_data_growth.html diff --git a/templates/bep_page_md.jinja b/templates/bep_page_md.jinja new file mode 100644 index 00000000..19fe5700 --- /dev/null +++ b/templates/bep_page_md.jinja @@ -0,0 +1,75 @@ +--- +hide: + - navigation + - toc +--- + +# BEP {{ bep.number }}: {% if bep.display %} {{ bep.display }} {% else %} {{ bep.title }} {% endif %} + +{% if bep.communication_channel %} +!!! note + + Get in touch with people working on this BIDS extension: [{{ bep.communication_channel }}]({{ bep.communication_channel }}) +{% endif %} + +{% if bep.pull_request %} +**Pull request**: [{{ bep.pull_request }}]({{ bep.pull_request }} ) +{% else %} +**Google doc**: [{{ bep.google_doc }}]({{ bep.google_doc }} ) +{% endif %} + +## Content + +{% for content in bep.content %} +- {{ content }} +{% endfor %} + +## Lead(s) + +{% for person in bep.leads %} +{% if person.email %} +- [{{ person["given-names"] }} {{ person["family-names"] }}](mailto:{{ person.email }}) +{% else %} +- {{ person["given-names"] }} {{ person["family-names"] }} +{% endif %} +{% endfor %} + +{% if bep.status %} +## Status + +{% for item in bep.status %} +- {{ item }} +{% endfor %} +{% endif %} + +{% if bep.blocking %} +## Blockers + +{% for item in bep.blocking %} +- {{ item }} +{% endfor %} +{% endif %} + +{% if bep.bids_maintainers %} +## BIDS maintainers + +{% for person in bep.bids_maintainers %} +- {{ person["given-names"] }} {{ person["family-names"] }} +{% endfor %} +{% endif %} + +## Preview + + diff --git a/templates/beps_table_md.jinja b/templates/beps_table_md.jinja index b4c2ce59..68b05053 100644 --- a/templates/beps_table_md.jinja +++ b/templates/beps_table_md.jinja @@ -1,13 +1,10 @@ -{% if type == "completed" %} -| Extension | Title | Content | Lead(s) | -| :--------: | :---- | :----- | :----- | -{% elif type == "other" %} +{% if type == "other" %} | Extension | Title | Content | Lead(s) | Outcome | | :--------: | :---- | :----- | :----- | :------ | {% else %} -| Extension | Title | Content | Lead(s) | Last update | Problems | -| :--------: | :---- | :----- | :----- | :---------- | :------- | +| Extension | Title | Content | Lead(s) | +| :--------: | :---- | :----- | :----- | {% endif %} {% for bep in include %} -| [BEP {{ bep.number }}]({{ bep.link }}) | {% if bep.display %} {{ bep.display }} {% else %} {{ bep.title }} {% endif %} | {% for content in bep.content %} {{ content }} {% endfor %} | {% for person in bep.leads %} {% if person.email %} [{{ person["given-names"] }} {{ person["family-names"] }}](mailto:{{ person.email }}) {% else %} {{ person["given-names"] }} {{ person["family-names"] }} {% endif %}
{% endfor %} | {% if bep.status %} {% for item in bep.status %} - {{ item }}
{% endfor %} {% endif %} | {% if bep.blocking %} {% for item in bep.blocking %} - {{ item }}
{% endfor %} {% endif %} | +| [BEP {{ bep.number }}](./beps/bep_{{ bep.number }}.md) | {% if bep.display %} {{ bep.display }} {% else %} {{ bep.title }} {% endif %} | {% for content in bep.content %} {{ content }} {% endfor %} | {% for person in bep.leads %} {% if person.email %} [{{ person["given-names"] }} {{ person["family-names"] }}](mailto:{{ person.email }}) {% else %} {{ person["given-names"] }} {{ person["family-names"] }} {% endif %}
{% endfor %} | {% endfor %} diff --git a/tools/build/generate_bep_pages.py b/tools/build/generate_bep_pages.py new file mode 100644 index 00000000..547b9d09 --- /dev/null +++ b/tools/build/generate_bep_pages.py @@ -0,0 +1,43 @@ +"""Generate a page for each BEP based on its metadata.""" + +import ruamel.yaml +from jinja2 import Environment, FileSystemLoader, select_autoescape +from rich import print + +from bids_website.utils import root_dir + +yaml = ruamel.yaml.YAML() +yaml.indent(mapping=2, sequence=4, offset=2) + +TEMPLATES_DIR = root_dir() / "templates" + +WEBSITE_DATA_DIR = root_dir() / "data" + + +def return_jinja_env() -> Environment: + return Environment( + loader=FileSystemLoader(TEMPLATES_DIR), + autoescape=select_autoescape(), + lstrip_blocks=True, + trim_blocks=True, + ) + + +def generate_bep_page(bep: dict) -> str: + env = return_jinja_env() + template = env.get_template("bep_page_md.jinja") + content = template.render(bep=bep) + output_file = ( + root_dir() / "docs" / "extensions" / "beps" / f"bep_{bep['number']}.md" + ) + output_file.parent.mkdir(exist_ok=True, parents=True) + output_file.write_text(content) + print(f" generated: {output_file}") + + +BEPS = yaml.load(WEBSITE_DATA_DIR / "beps" / "beps.yml") + +for bep in BEPS: + print(bep["number"]) + assert "google_doc" in bep or "pull_request" in bep + generate_bep_page(bep)