bidsschematools.render.text

Functions for rendering portions of the schema as text.

Functions

bidsschematools.render.text.append_filename_template_legend(text, pdf_format=False)

Append a legend to filename templates.

Parameters:
  • text (str) – The text to append the legend to.

  • pdf_format (bool) – Whether to format the legend for PDF output.

Returns:

The text with the legend appended.

Return type:

str

bidsschematools.render.text.define_allowed_top_directories(schema, src_path=None) str

Create a list of allowed top-level directories with their descriptions.

Parameters:
  • schema (dict) – The BIDS schema.

  • src_path (str or None) – The file where this macro is called, which may be explicitly provided by the “page.file.src_path” variable.

Returns:

string – Unordered list describing top level directories.

Return type:

str

bidsschematools.render.text.define_common_principles(schema, src_path=None)

Enumerate the common principles defined in the schema.

Parameters:
  • schema (dict) – The BIDS schema.

  • src_path (str or None) – The file where this macro is called, which may be explicitly provided by the “page.file.src_path” variable.

Returns:

string – The definitions of the common principles in a multiline string.

Return type:

str

bidsschematools.render.text.make_entity_definitions(schema, src_path=None)

Generate definitions and other relevant information for entities in the specification.

Each entity gets its own heading.

Parameters:

schema (dict) – The schema object, which is a dictionary with nested dictionaries and lists stored within it.

Returns:

text – A string containing descriptions and some formatting information about the entities in the schema.

Return type:

str

bidsschematools.render.text.make_filename_template(dstype, schema=None, src_path=None, n_dupes_to_combine=6, pdf_format=False, **kwargs)

Create codeblocks containing example filename patterns for a given datatype.

By default, this function uses HTML, instead of direct Markdown codeblocks, so that it can embed hyperlinks within the filenames.

Parameters:
  • dstype ("raw" or "deriv") – The type of files being rendered; determines if rules are found in rules.files.raw or rules.files.deriv

  • schema (dict) – The schema object, which is a dictionary with nested dictionaries and lists stored within it.

  • src_path (str or None) – The file where this macro is called, which may be explicitly provided by the “page.file.src_path” variable.

  • n_dupes_to_combine (int) – The minimum number of suffixes/extensions to combine in the template as <suffix>/<extension>.

  • pdf_format (bool, optional) – If True, the filename template will be compiled as a standard markdown code block, without any hyperlinks, so that the specification’s PDF build will look right. If False, the filename template will use HTML and include hyperlinks. This works on the website. Default is False.

  • **kwargs (dict) – Keyword arguments used to filter the schema. Example kwargs that may be used include: “suffixes”, “datatypes”, “extensions”.

Returns:

codeblock – A multiline string containing the filename templates for file types in the schema, after filtering.

Return type:

str

Notes

This function links to HTML files, rather than markdown files.

bidsschematools.render.text.make_glossary(schema, src_path=None)

Generate glossary.

Parameters:
  • schema (dict) – The schema object, which is a dictionary with nested dictionaries and lists stored within it.

  • src_path (str or None) – The file where this macro is called, which may be explicitly provided by the “page.file.src_path” variable.

Returns:

text – A string containing descriptions and some formatting information about the entities in the schema.

Return type:

str

bidsschematools.render.text.render_text(schema, key: str, src_path=None)
Parameters:
  • schema (dict) – The BIDS schema.

  • key (str) – The key of the object to render the description for: possible values correspond to the keys in schema[“objects”][object]

  • src_path (str or None) – The file where this macro is called, which may be explicitly provided by the “page.file.src_path” variable.

Returns:

desc – Description of the object.

Return type:

str

bidsschematools.render.text.value_key_table(namespace)