prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Docs don't auto-reload in dev
  Because we only read docs once, changes to the Markdown files require manually killing and restarting the server.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `ocfweb/docs/markdown_based.py`
  Content:
  ```
  1 """Documents backed by Markdown.
  2 
  3 This is the most common type of doc. It reads a Markdown fil and renders it in
  4 a standard template.
  5 
  6 Markdown documents can specify the meta attributes:
  7 
  8     - [[!meta title="Page title"]]
  9       Changes the page title; all templates must specify this.
  10 
  11     - [[!meta template="my_template.html"]]
  12       Changes the page template; most templates should *not* specify this,
  13       unless they want to customize something (e.g. the sidebar)
  14 """
  15 import os
  16 from functools import partial
  17 from pathlib import Path
  18 
  19 from django.shortcuts import render
  20 
  21 from ocfweb.component.markdown import markdown_and_toc
  22 from ocfweb.component.markdown import text_and_meta
  23 from ocfweb.docs.doc import Document
  24 
  25 
  26 DOCS_DIR = Path(__file__).parent.joinpath('docs')
  27 
  28 
  29 def render_markdown_doc(meta, text, doc, request):
  30     html, toc = markdown_and_toc(text)
  31     return render(
  32         request,
  33         meta.get('template', 'doc.html'),
  34         {
  35             'title': doc.title,
  36             'doc': doc,
  37             'html': html,
  38             'toc': toc,
  39         },
  40     )
  41 
  42 
  43 def get_markdown_docs():
  44     for path in DOCS_DIR.glob('**/*.md'):
  45         name, _ = os.path.splitext(str(path.relative_to(DOCS_DIR)))
  46 
  47         # sanity check that the file is under the directory we expect
  48         assert DOCS_DIR in path.parents
  49 
  50         with path.open() as f:
  51             text, meta = text_and_meta(f)
  52 
  53         if 'title' not in meta:
  54             raise ValueError('Document {} lacks required title meta variable.'.format(name))
  55 
  56         yield Document(
  57             name='/' + name,
  58             title=meta['title'],
  59             render=partial(render_markdown_doc, meta, text)
  60         )
  61
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/ocfweb/docs/markdown_based.py b/ocfweb/docs/markdown_based.py
  --- a/ocfweb/docs/markdown_based.py
  +++ b/ocfweb/docs/markdown_based.py
  @@ -1,6 +1,6 @@
   """Documents backed by Markdown.
   
  -This is the most common type of doc. It reads a Markdown fil and renders it in
  +This is the most common type of doc. It reads a Markdown file and renders it in
   a standard template.
   
   Markdown documents can specify the meta attributes:
  @@ -16,6 +16,7 @@
   from functools import partial
   from pathlib import Path
   
  +from django.conf import settings
   from django.shortcuts import render
   
   from ocfweb.component.markdown import markdown_and_toc
  @@ -26,13 +27,20 @@
   DOCS_DIR = Path(__file__).parent.joinpath('docs')
   
   
  -def render_markdown_doc(meta, text, doc, request):
  +def render_markdown_doc(path, meta, text, doc, request):
  +
  +    # Reload markdown docs if in development
  +    if settings.DEBUG:
  +        with path.open() as f:
  +            text, meta = text_and_meta(f)
  +
       html, toc = markdown_and_toc(text)
  +
       return render(
           request,
           meta.get('template', 'doc.html'),
           {
  -            'title': doc.title,
  +            'title': meta['title'],
               'doc': doc,
               'html': html,
               'toc': toc,
  @@ -56,5 +64,5 @@
           yield Document(
               name='/' + name,
               title=meta['title'],
  -            render=partial(render_markdown_doc, meta, text)
  +            render=partial(render_markdown_doc, path, meta, text),
           )
  
verification_info: {"golden_diff": "diff --git a/ocfweb/docs/markdown_based.py b/ocfweb/docs/markdown_based.py\n--- a/ocfweb/docs/markdown_based.py\n+++ b/ocfweb/docs/markdown_based.py\n@@ -1,6 +1,6 @@\n \"\"\"Documents backed by Markdown.\n \n-This is the most common type of doc. It reads a Markdown fil and renders it in\n+This is the most common type of doc. It reads a Markdown file and renders it in\n a standard template.\n \n Markdown documents can specify the meta attributes:\n@@ -16,6 +16,7 @@\n from functools import partial\n from pathlib import Path\n \n+from django.conf import settings\n from django.shortcuts import render\n \n from ocfweb.component.markdown import markdown_and_toc\n@@ -26,13 +27,20 @@\n DOCS_DIR = Path(__file__).parent.joinpath('docs')\n \n \n-def render_markdown_doc(meta, text, doc, request):\n+def render_markdown_doc(path, meta, text, doc, request):\n+\n+    # Reload markdown docs if in development\n+    if settings.DEBUG:\n+        with path.open() as f:\n+            text, meta = text_and_meta(f)\n+\n     html, toc = markdown_and_toc(text)\n+\n     return render(\n         request,\n         meta.get('template', 'doc.html'),\n         {\n-            'title': doc.title,\n+            'title': meta['title'],\n             'doc': doc,\n             'html': html,\n             'toc': toc,\n@@ -56,5 +64,5 @@\n         yield Document(\n             name='/' + name,\n             title=meta['title'],\n-            render=partial(render_markdown_doc, meta, text)\n+            render=partial(render_markdown_doc, path, meta, text),\n         )\n", "issue": "Docs don't auto-reload in dev\nBecause we only read docs once, changes to the Markdown files require manually killing and restarting the server.\n\n", "before_files": [{"content": "\"\"\"Documents backed by Markdown.\n\nThis is the most common type of doc. It reads a Markdown fil and renders it in\na standard template.\n\nMarkdown documents can specify the meta attributes:\n\n    - [[!meta title=\"Page title\"]]\n      Changes the page title; all templates must specify this.\n\n    - [[!meta template=\"my_template.html\"]]\n      Changes the page template; most templates should *not* specify this,\n      unless they want to customize something (e.g. the sidebar)\n\"\"\"\nimport os\nfrom functools import partial\nfrom pathlib import Path\n\nfrom django.shortcuts import render\n\nfrom ocfweb.component.markdown import markdown_and_toc\nfrom ocfweb.component.markdown import text_and_meta\nfrom ocfweb.docs.doc import Document\n\n\nDOCS_DIR = Path(__file__).parent.joinpath('docs')\n\n\ndef render_markdown_doc(meta, text, doc, request):\n    html, toc = markdown_and_toc(text)\n    return render(\n        request,\n        meta.get('template', 'doc.html'),\n        {\n            'title': doc.title,\n            'doc': doc,\n            'html': html,\n            'toc': toc,\n        },\n    )\n\n\ndef get_markdown_docs():\n    for path in DOCS_DIR.glob('**/*.md'):\n        name, _ = os.path.splitext(str(path.relative_to(DOCS_DIR)))\n\n        # sanity check that the file is under the directory we expect\n        assert DOCS_DIR in path.parents\n\n        with path.open() as f:\n            text, meta = text_and_meta(f)\n\n        if 'title' not in meta:\n            raise ValueError('Document {} lacks required title meta variable.'.format(name))\n\n        yield Document(\n            name='/' + name,\n            title=meta['title'],\n            render=partial(render_markdown_doc, meta, text)\n        )\n", "path": "ocfweb/docs/markdown_based.py"}], "after_files": [{"content": "\"\"\"Documents backed by Markdown.\n\nThis is the most common type of doc. It reads a Markdown file and renders it in\na standard template.\n\nMarkdown documents can specify the meta attributes:\n\n    - [[!meta title=\"Page title\"]]\n      Changes the page title; all templates must specify this.\n\n    - [[!meta template=\"my_template.html\"]]\n      Changes the page template; most templates should *not* specify this,\n      unless they want to customize something (e.g. the sidebar)\n\"\"\"\nimport os\nfrom functools import partial\nfrom pathlib import Path\n\nfrom django.conf import settings\nfrom django.shortcuts import render\n\nfrom ocfweb.component.markdown import markdown_and_toc\nfrom ocfweb.component.markdown import text_and_meta\nfrom ocfweb.docs.doc import Document\n\n\nDOCS_DIR = Path(__file__).parent.joinpath('docs')\n\n\ndef render_markdown_doc(path, meta, text, doc, request):\n\n    # Reload markdown docs if in development\n    if settings.DEBUG:\n        with path.open() as f:\n            text, meta = text_and_meta(f)\n\n    html, toc = markdown_and_toc(text)\n\n    return render(\n        request,\n        meta.get('template', 'doc.html'),\n        {\n            'title': meta['title'],\n            'doc': doc,\n            'html': html,\n            'toc': toc,\n        },\n    )\n\n\ndef get_markdown_docs():\n    for path in DOCS_DIR.glob('**/*.md'):\n        name, _ = os.path.splitext(str(path.relative_to(DOCS_DIR)))\n\n        # sanity check that the file is under the directory we expect\n        assert DOCS_DIR in path.parents\n\n        with path.open() as f:\n            text, meta = text_and_meta(f)\n\n        if 'title' not in meta:\n            raise ValueError('Document {} lacks required title meta variable.'.format(name))\n\n        yield Document(\n            name='/' + name,\n            title=meta['title'],\n            render=partial(render_markdown_doc, path, meta, text),\n        )\n", "path": "ocfweb/docs/markdown_based.py"}]}