Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Use SPEC_ROOT/src_path in make_filename_template #1248

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tools/mkdocs_macros_bids/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _get_source_path(level=1):
return caller.f_locals["_Context__self"]["page"].file.src_path


def make_filename_template(pdf_format=False, **kwargs):
def make_filename_template(src_path=None, pdf_format=False, **kwargs):
"""Generate a filename template snippet from the schema, based on specific filters.

Parameters
Expand All @@ -83,9 +83,13 @@ def make_filename_template(pdf_format=False, **kwargs):
A multiline string containing the filename templates for file types
in the schema, after filtering.
"""
if src_path is None:
src_path = _get_source_path()

schema_obj = schema.load_schema()
codeblock = render.make_filename_template(
schema_obj,
src_path=src_path,
pdf_format=pdf_format,
**kwargs,
)
Expand Down
8 changes: 3 additions & 5 deletions tools/schemacode/bidsschematools/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,15 @@ def make_filename_template(

Notes
-----
This function doesn't use src_path, because the hyperlinks use absolute paths to HTML files.
It would be nice, at some point, to use src_path in conjunction with paths to markdown files,
like other functions do, instead.
This function links to HTML files, rather than markdown files.
"""
if not schema:
schema = load_schema()

schema = Namespace(filter_schema(schema.to_dict(), **kwargs))
entity_order = schema["rules"]["entities"]
entities_path = "/99-appendices/09-entities.html"
glossary_path = "/99-appendices/14-glossary.html"
entities_path = "SPEC_ROOT/99-appendices/09-entities.html"
glossary_path = "SPEC_ROOT/99-appendices/14-glossary.html"

paragraph = ""
# Parent directories
Expand Down