diff --git a/pyproject.toml b/pyproject.toml index a5dc62e..3f1c817 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ GitHub = "https://github.com/jpsca/writeadoc" dev = [ "ipdb>=0.13.13", "pytest-cov>=7.0.0", + "pytest-mock>=3.15.1", "ruff>=0.12.4", "tox-uv", "ty>=0.0.1a15", diff --git a/src/writeadoc/main.py b/src/writeadoc/main.py index fa3fcde..094ee9f 100644 --- a/src/writeadoc/main.py +++ b/src/writeadoc/main.py @@ -133,11 +133,17 @@ def cli(self): default=False, help="Generate a `llms.txt` file with all the markdown content", ) + build_parser.add_argument( + "--boring", + action="store_true", + default=False, + help="Remove the random messages from the log output" + ) args = parser.parse_args() if args.command == "build": - self.cli_build(archive=args.archive, llm=args.llm) + self.cli_build(archive=args.archive, llm=args.llm, boring=args.boring) elif args.command in (None, "run"): self.cli_run() else: @@ -168,7 +174,7 @@ def shutdown(*args): signal.signal(signal.SIGINT, shutdown) signal.signal(signal.SIGTERM, shutdown) - def cli_build(self, *, archive: bool, llm: bool = False) -> None: + def cli_build(self, *, archive: bool, llm: bool = False, boring: bool = False) -> None: """Build the documentation for deployment. """ if archive: @@ -182,23 +188,25 @@ def cli_build(self, *, archive: bool, llm: bool = False) -> None: variant.build_dir = self.build_dir variant.prefix = f"{self.prefix}/{prefix}" if self.prefix else prefix - self.build(devmode=False, llm=llm) + self.build(devmode=False, llm=llm, boring=boring) print("\nDocumentation built successfully.") if archive: print(f"Archived documentation is available in the `archive/{self.site.version}` folder.") else: print("Documentation is available in the `build` folder.") - def build(self, *, devmode: bool = True, llm: bool = False) -> None: - messages = get_random_messages(3) - print(f"{messages[0]}...") + def build(self, *, devmode: bool = True, llm: bool = False, boring: bool = False) -> None: + if not boring: + messages = get_random_messages(3) + print(f"{messages[0]}...") for variant in self.variants.values(): variant.build(devmode=devmode, llm=llm) print("Processing pages...") nav, pages = self.pages_processor.run(self.pages) - print(f"{messages[1]}...") + if not boring: + print(f"{messages[1]}...") self.site.nav = nav self.site.pages = pages @@ -209,7 +217,8 @@ def build(self, *, devmode: bool = True, llm: bool = False) -> None: print("Rendering pages...") for page in pages: self._render_page(page) - print(f"{messages[2]}...") + if not boring: + print(f"{messages[2]}...") if llm: print("Building llms.txt...") diff --git a/tests/test_cli_build.py b/tests/test_cli_build.py new file mode 100644 index 0000000..664a04c --- /dev/null +++ b/tests/test_cli_build.py @@ -0,0 +1,60 @@ +from unittest.mock import call + +import pytest + +from writeadoc.main import Docs + + +@pytest.fixture +def docs(tmp_root): + (tmp_root / "comp").mkdir() + (tmp_root / "comp" / "test.jx").write_text("