Closed tombreit closed 2 months ago
Thanks for taking the time to write this! LGTM
I think the change might have disabled the plugin for some of the unit tests. Did the tests work locally?
I think the change might have disabled the plugin for some of the unit tests. Did the tests work locally?
Hm, looks good locally:
(.venv) ~/projects/mkdocs-git-authors-plugin (80-enabled_on_serve)
└─ $ ▶ git log -1
commit 072704756f14511d0a48af5a3a94e5825d7d2efb (HEAD -> 80-enabled_on_serve, origin/80-enabled_on_serve)
Author: Thomas Breitner <t.breitner@csl.mpg.de>
Date: Tue Mar 5 16:30:50 2024 +0100
New config option: enabled_on_serve
(.venv) ~/projects/mkdocs-git-authors-plugin (80-enabled_on_serve)
└─ $ ▶ pytest tests -vv
============================================================== test session starts ===============================================================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0 -- ~/projects/mkdocs-git-authors-plugin/.venv/bin/python3
cachedir: .pytest_cache
rootdir: ~/projects/mkdocs-git-authors-plugin
plugins: cov-4.1.0, mock-3.12.0
collected 23 items
tests/test_basic.py::test_basic_working[mkdocs.yml] PASSED [ 4%]
tests/test_basic.py::test_basic_working[mkdocs_complete_material_disabled.yml] PASSED [ 8%]
tests/test_basic.py::test_basic_working[mkdocs_complete_material.yml] PASSED [ 13%]
tests/test_basic.py::test_basic_working[mkdocs_exclude.yml] PASSED [ 17%]
tests/test_basic.py::test_basic_working[mkdocs_fallback.yml] PASSED [ 21%]
tests/test_basic.py::test_basic_working[mkdocs_genfiles.yml] PASSED [ 26%]
tests/test_basic.py::test_basic_working[mkdocs_no_email.yml] PASSED [ 30%]
tests/test_basic.py::test_basic_working[mkdocs_w_contribution_and_author_threshold.yml] PASSED [ 34%]
tests/test_basic.py::test_basic_working[mkdocs_w_contribution_sort_and_author_threshold.yml] PASSED [ 39%]
tests/test_basic.py::test_basic_working[mkdocs_w_contribution.yml] PASSED [ 43%]
tests/test_basic.py::test_basic_working[mkdocs_w_macros.yml] PASSED [ 47%]
tests/test_basic.py::test_basic_working[mkdocs_w_macros2.yml] PASSED [ 52%]
tests/test_basic.py::test_no_email PASSED [ 56%]
tests/test_basic.py::test_exclude_working PASSED [ 60%]
tests/test_basic.py::test_exclude_working_with_genfiles PASSED [ 65%]
tests/test_basic.py::test_enabled_working PASSED [ 69%]
tests/test_basic.py::test_project_with_no_commits PASSED [ 73%]
tests/test_basic.py::test_building_empty_site PASSED [ 78%]
tests/test_basic.py::test_fallback PASSED [ 82%]
tests/test_util.py::test_empty_file PASSED [ 86%]
tests/test_util.py::test_retrieve_authors PASSED [ 91%]
tests/test_util.py::test_mkdocs_in_git_subdir PASSED [ 95%]
tests/test_util.py::test_summarize_authors PASSED [100%]
=============================================================== 23 passed in 1.34s ===============================================================
And the specific test from .github/workflows/unittests.yml
:
(.venv) ~/projects/mkdocs-git-authors-plugin (80-enabled_on_serve)
└─ $ ▶ pytest --cov=mkdocs_git_authors_plugin --cov-report=xml
============================================================== test session starts ===============================================================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0
rootdir: ~/projects/mkdocs-git-authors-plugin
plugins: cov-4.1.0, mock-3.12.0
collected 23 items
tests/test_basic.py ................... [ 82%]
tests/test_util.py .... [100%]
---------- coverage: platform linux, python 3.11.8-final-0 -----------
Coverage XML written to file coverage.xml
=============================================================== 23 passed in 2.59s ===============================================================
Thanks !!
As mentioned in https://github.com/timvink/mkdocs-git-authors-plugin/issues/80 this PR introduces a new config option
enabled_on_serve
. This allows you to deactivate this plugin whenmkdocs
is called with the commandserve
.The wording/naming for this new config option is inspired by https://github.com/squidfunk/mkdocs-material/blob/master/src/plugins/info/config.py#L31
As I struggled writing a test where the MkDocs
serve
command is involved, this PR comes without a test (for now)...But honestly, I'm not sure if this new option is even necessary: the existing
enabled
option plus an environment variable works just fine.