Add a code snippet (e.g., an analysis script) to the report. Parameters ---------- code : str | pathlib.Path The code to add to the report as a string, or the path to a file as a `pathlib.Path` object. .. note:: Paths must be passed as `p
(
self,
code,
title,
*,
language="python",
tags=("code",),
section=None,
replace=False,
)
| 2392 | |
| 2393 | @fill_doc |
| 2394 | def add_code( |
| 2395 | self, |
| 2396 | code, |
| 2397 | title, |
| 2398 | *, |
| 2399 | language="python", |
| 2400 | tags=("code",), |
| 2401 | section=None, |
| 2402 | replace=False, |
| 2403 | ): |
| 2404 | """Add a code snippet (e.g., an analysis script) to the report. |
| 2405 | |
| 2406 | Parameters |
| 2407 | ---------- |
| 2408 | code : str | pathlib.Path |
| 2409 | The code to add to the report as a string, or the path to a file |
| 2410 | as a `pathlib.Path` object. |
| 2411 | |
| 2412 | .. note:: Paths must be passed as `pathlib.Path` object, since |
| 2413 | strings will be treated as literal code. |
| 2414 | title : str |
| 2415 | The title corresponding to the code. |
| 2416 | language : str |
| 2417 | The programming language of ``code``. This will be used for syntax |
| 2418 | highlighting. Can be ``'auto'`` to try to auto-detect the language. |
| 2419 | %(tags_report)s |
| 2420 | %(section_report)s |
| 2421 | |
| 2422 | .. versionadded:: 1.9 |
| 2423 | %(replace_report)s |
| 2424 | |
| 2425 | Notes |
| 2426 | ----- |
| 2427 | .. versionadded:: 0.24.0 |
| 2428 | """ |
| 2429 | tags = _check_tags(tags) |
| 2430 | language = language.lower() |
| 2431 | self._add_code( |
| 2432 | code=code, |
| 2433 | title=title, |
| 2434 | language=language, |
| 2435 | section=section, |
| 2436 | tags=tags, |
| 2437 | replace=replace, |
| 2438 | ) |
| 2439 | |
| 2440 | @fill_doc |
| 2441 | def add_sys_info(self, title, *, tags=("mne-sysinfo",), replace=False): |