{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "50ce8f20",
   "metadata": {},
   "source": [
    "# Thebe\n",
    "\n",
    "Thebe (via `sphinx-thebe`) is a special-case for this theme because it is particularly useful for interactive notebook use-cases.\n",
    "This page shows off major Thebe functionality and discusses some gotchas.\n",
    "\n",
    "When this page loads, activate Thebe by clicking the {guilabel}`Live Code` button at the top.\n",
    "\n",
    "## Code style\n",
    "\n",
    "Thebe uses CodeMirror in the background, which uses different styles than pygments, which is used for static code syntax highlighting.\n",
    "\n",
    "Static code:\n",
    "\n",
    "```\n",
    "import tempfile\n",
    "import os\n",
    "import time\n",
    "\n",
    "def test_upper():\n",
    "    assert True\n",
    "    in_file = tempfile.NamedTemporaryFile(delete=False, mode='w')\n",
    "    out_file = tempfile.NamedTemporaryFile(delete=False)\n",
    "    out_file.close()\n",
    "    in_file.write(\"test123\\nthetest\")\n",
    "    in_file.close()\n",
    "    file_to_upper(in_file.name, out_file.name)\n",
    "    with open(out_file.name, 'r') as f:\n",
    "        data = f.read()\n",
    "        assert data == \"TEST123\\nTHETEST\"\n",
    "    os.unlink(in_file.name)\n",
    "    os.unlink(out_file.name)\n",
    "```\n",
    "\n",
    "Runnable thebe code:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2d2264a9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import tempfile\n",
    "import os\n",
    "import time\n",
    "\n",
    "def test_upper():\n",
    "    assert True\n",
    "    in_file = tempfile.NamedTemporaryFile(delete=False, mode='w')\n",
    "    out_file = tempfile.NamedTemporaryFile(delete=False)\n",
    "    out_file.close()\n",
    "    in_file.write(\"test123\\nthetest\")\n",
    "    in_file.close()\n",
    "    file_to_upper(in_file.name, out_file.name)\n",
    "    with open(out_file.name, 'r') as f:\n",
    "        data = f.read()\n",
    "        assert data == \"TEST123\\nTHETEST\"\n",
    "    os.unlink(in_file.name)\n",
    "    os.unlink(out_file.name)"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "formats": "md:myst",
   "text_representation": {
    "extension": ".md",
    "format_name": "myst"
   }
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  },
  "source_map": [
   11,
   48
  ]
 },
 "nbformat": 4,
 "nbformat_minor": 5
}