Skip to content

Comments

New config option: enabled_on_serve#81

Merged
timvink merged 2 commits intotimvink:masterfrom
tombreit:80-enabled_on_serve
Mar 12, 2024
Merged

New config option: enabled_on_serve#81
timvink merged 2 commits intotimvink:masterfrom
tombreit:80-enabled_on_serve

Conversation

@tombreit
Copy link
Contributor

@tombreit tombreit commented Mar 5, 2024

As mentioned in #80 this PR introduces a new config option enabled_on_serve. This allows you to deactivate this plugin when mkdocs is called with the command serve.

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.

@timvink
Copy link
Owner

timvink commented Mar 8, 2024

Thanks for taking the time to write this! LGTM

@timvink
Copy link
Owner

timvink commented Mar 8, 2024

I think the change might have disabled the plugin for some of the unit tests. Did the tests work locally?

@tombreit
Copy link
Contributor Author

tombreit commented Mar 8, 2024

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 <[email protected]>
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 ===============================================================

…epth to 0 to fetch all history for all branches and tags; Bumped actions/checkout to v4
@timvink
Copy link
Owner

timvink commented Mar 12, 2024

Thanks !!

@timvink timvink merged commit f184834 into timvink:master Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants