teachbooks.external_content.headers module

Add headers to external .md, .rst and .ipynb files.

teachbooks.external_content.headers.add_header_admonitions(repo: Path, header: str)

Add header to a file.

Parameters:
  • repo – Path to the git repo cloned by the external content routine.

  • header – Preformatted admonition header

teachbooks.external_content.headers.add_md_admonition(file: Path, header: str)

Add an admonition containing text to the top of markdown file file.

teachbooks.external_content.headers.add_nb_admonition(file: Path, header: str)

Add an admonition containing text to the top of notebook `file.

teachbooks.external_content.headers.add_origin_notes(repo: Path, cfg: dict[str, str], base_url: str, version: str) None

Add a note denoting the origin of a certain file.

Parameters:
  • repo – Path to the repository git cloned by the enternal-content routine.

  • cfg – TeachBooks configuration.

  • base_url – Base URL of the file’s repository.

  • version – Name of the version (tag, branch or commit hash).

teachbooks.external_content.headers.add_rst_admonition(file: Path, header: str)

Add an admonition top of reST file.

To do this we make use of the include directive and write the admonition as a separate markdown file which will be parsed by myst.

teachbooks.external_content.headers.format_header(cfg: dict, base_url: str, version: str) str

Generate the admonition header based on the user’s config.

teachbooks.external_content.headers.prepend(file: Path, text: str)

Prepend string text to plaintext file file.