]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🔨 Update docs.py script to enable dirty reload conditionally (#11986)
authorSebastián Ramírez <tiangolo@gmail.com>
Fri, 9 Aug 2024 21:30:19 +0000 (16:30 -0500)
committerGitHub <noreply@github.com>
Fri, 9 Aug 2024 21:30:19 +0000 (16:30 -0500)
scripts/docs.py

index fd2dd78f1429b33f776c13c2245fbc4ddd6ea068..5ef54888997a808fda45736238b6b1e379d2e4d4 100644 (file)
@@ -251,6 +251,7 @@ def live(
     lang: str = typer.Argument(
         None, callback=lang_callback, autocompletion=complete_existing_lang
     ),
+    dirty: bool = False,
 ) -> None:
     """
     Serve with livereload a docs site for a specific language.
@@ -265,11 +266,12 @@ def live(
     if lang is None:
         lang = "en"
     lang_path: Path = docs_path / lang
+    # Enable line numbers during local development to make it easier to highlight
+    args = ["mkdocs", "serve", "--dev-addr", "127.0.0.1:8008"]
+    if dirty:
+        args.append("--dirty")
     subprocess.run(
-        ["mkdocs", "serve", "--dev-addr", "127.0.0.1:8008", "--dirty"],
-        env={**os.environ, "LINENUMS": "true"},
-        cwd=lang_path,
-        check=True,
+        args, env={**os.environ, "LINENUMS": "true"}, cwd=lang_path, check=True
     )