mkdocs-git-authors-plugin 0.9.2__tar.gz → 0.9.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4}/PKG-INFO +6 -7
  2. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4}/README.md +1 -1
  3. mkdocs_git_authors_plugin-0.9.4/pyproject.toml +52 -0
  4. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/git/page.py +1 -0
  5. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/plugin.py +30 -16
  6. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/util.py +27 -0
  7. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin.egg-info/PKG-INFO +6 -7
  8. mkdocs_git_authors_plugin-0.9.4/src/mkdocs_git_authors_plugin.egg-info/SOURCES.txt +23 -0
  9. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4}/tests/test_basic.py +30 -22
  10. mkdocs_git_authors_plugin-0.9.2/mkdocs_git_authors_plugin.egg-info/SOURCES.txt +0 -23
  11. mkdocs_git_authors_plugin-0.9.2/setup.py +0 -40
  12. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4}/LICENSE +0 -0
  13. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4}/setup.cfg +0 -0
  14. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/__init__.py +0 -0
  15. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/ci.py +0 -0
  16. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/config.py +0 -0
  17. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/exclude.py +0 -0
  18. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/git/__init__.py +0 -0
  19. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/git/author.py +0 -0
  20. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/git/command.py +0 -0
  21. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/git/commit.py +0 -0
  22. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin/git/repo.py +0 -0
  23. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin.egg-info/dependency_links.txt +0 -0
  24. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin.egg-info/entry_points.txt +0 -0
  25. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin.egg-info/requires.txt +0 -0
  26. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4/src}/mkdocs_git_authors_plugin.egg-info/top_level.txt +0 -0
  27. {mkdocs_git_authors_plugin-0.9.2 → mkdocs_git_authors_plugin-0.9.4}/tests/test_util.py +0 -0
@@ -1,12 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: mkdocs-git-authors-plugin
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Mkdocs plugin to display git authors of a page
5
- Home-page: https://github.com/timvink/mkdocs-git-authors-plugin
6
- Author: Tim Vink
7
- Author-email: vinktim@gmail.com
5
+ Author-email: Tim Vink <vinktim@gmail.com>
8
6
  License: MIT
9
- Keywords: mkdocs git contributors committers authors plugin
7
+ Project-URL: Homepage, https://github.com/timvink/mkdocs-git-authors-plugin
8
+ Keywords: mkdocs,git,contributors,committers,authors,plugin
10
9
  Classifier: Operating System :: OS Independent
11
10
  Classifier: Programming Language :: Python
12
11
  Classifier: Programming Language :: Python :: 3
@@ -73,7 +72,7 @@ This plugin needs access to the last commit that touched a specific file to be a
73
72
  <summary>Change your CI settings</summary>
74
73
 
75
74
  - github actions: set `fetch_depth` to `0` ([docs](https://github.com/actions/checkout))
76
- - gitlab runners: set `GIT_DEPTH` to `1000` ([docs](https://docs.gitlab.com/ee/user/project/pipelines/settings.html#git-shallow-clone))
75
+ - gitlab runners: set `GIT_DEPTH` to `0` ([docs](https://docs.gitlab.com/ee/ci/pipelines/settings.html#limit-the-number-of-changes-fetched-during-clone))
77
76
  - bitbucket pipelines: set `clone: depth: full` ([docs](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/))
78
77
  </details>
79
78
 
@@ -46,7 +46,7 @@ This plugin needs access to the last commit that touched a specific file to be a
46
46
  <summary>Change your CI settings</summary>
47
47
 
48
48
  - github actions: set `fetch_depth` to `0` ([docs](https://github.com/actions/checkout))
49
- - gitlab runners: set `GIT_DEPTH` to `1000` ([docs](https://docs.gitlab.com/ee/user/project/pipelines/settings.html#git-shallow-clone))
49
+ - gitlab runners: set `GIT_DEPTH` to `0` ([docs](https://docs.gitlab.com/ee/ci/pipelines/settings.html#limit-the-number-of-changes-fetched-during-clone))
50
50
  - bitbucket pipelines: set `clone: depth: full` ([docs](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/))
51
51
  </details>
52
52
 
@@ -0,0 +1,52 @@
1
+ [build-system]
2
+ requires = ["setuptools>=42", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mkdocs-git-authors-plugin"
7
+ description = "Mkdocs plugin to display git authors of a page"
8
+ readme = { file = "README.md", content-type = "text/markdown" }
9
+ license = {text = "MIT"}
10
+ authors = [
11
+ {name = "Tim Vink", email = "vinktim@gmail.com"}
12
+ ]
13
+ keywords = ["mkdocs", "git", "contributors", "committers", "authors", "plugin"]
14
+ urls = {Homepage = "https://github.com/timvink/mkdocs-git-authors-plugin"}
15
+ version = "0.9.4"
16
+ requires-python = ">=3.8"
17
+ dependencies = ["mkdocs>=1.0"]
18
+ classifiers = [
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Programming Language :: Python :: 3.13",
28
+ "Programming Language :: Python :: 3 :: Only",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Topic :: Documentation",
31
+ "Topic :: Text Processing",
32
+ ]
33
+
34
+ [project.entry-points."mkdocs.plugins"]
35
+ git-authors = "mkdocs_git_authors_plugin.plugin:GitAuthorsPlugin"
36
+
37
+ [tool.setuptools]
38
+ package-dir = {"" = "src"}
39
+
40
+ [dependency-groups]
41
+ dev = [
42
+ "click>=8.1.8",
43
+ "codecov>=2.1.13",
44
+ "gitpython>=3.1.44",
45
+ "mkapi!=2.0.*",
46
+ "mkdocs>=1.6.1",
47
+ "mkdocs-git-revision-date-localized-plugin>=1.4.4",
48
+ "mkdocs-macros-plugin>=1.3.7",
49
+ "mkdocs-material>=9.6.7",
50
+ "pytest>=8.3.5",
51
+ "pytest-cov>=5.0.0",
52
+ ]
@@ -149,6 +149,7 @@ class Page(AbstractRepoObject):
149
149
  args.append("--ignore-revs-file")
150
150
  args.append(self.repo().config("ignore_commits"))
151
151
  args.append("--porcelain")
152
+ args.append("-w") # Ignore whitespace changes
152
153
  args.append(str(self._path))
153
154
  cmd = GitCommand("blame", args)
154
155
  cmd.run()
@@ -15,6 +15,8 @@ from mkdocs_git_authors_plugin.config import GitAuthorsPluginConfig
15
15
  from mkdocs_git_authors_plugin.exclude import exclude
16
16
  from mkdocs_git_authors_plugin.git.command import GitCommandError
17
17
  from mkdocs_git_authors_plugin.git.repo import Repo
18
+ from mkdocs_git_authors_plugin.util import working_directory
19
+
18
20
 
19
21
  logger = logging.getLogger("mkdocs.plugins")
20
22
 
@@ -56,20 +58,32 @@ class GitAuthorsPlugin(BasePlugin[GitAuthorsPluginConfig]):
56
58
  assert self.config.authorship_threshold_percent >= 0
57
59
  assert self.config.authorship_threshold_percent <= 100
58
60
 
61
+ self._fallback = False
62
+ # Find the git repository in the current working directory
59
63
  try:
60
64
  self._repo = Repo()
61
- self._fallback = False
65
+ except GitCommandError:
66
+ self._repo = None
67
+
68
+ # Try finding the git repository inside the documentation directory
69
+ if self._repo is None:
70
+ try:
71
+ with working_directory(config.get("docs_dir", ".")):
72
+ self._repo = Repo()
73
+ except GitCommandError:
74
+ if self.config.fallback_to_empty:
75
+ self._fallback = True
76
+ logger.warning(
77
+ "[git-authors-plugin] Unable to find a git directory and/or git is not installed."
78
+ " Option 'fallback_to_empty' set to 'true': Falling back to empty authors list"
79
+ )
80
+ else:
81
+ raise
82
+
83
+ if self._repo is not None:
62
84
  self.repo().set_config(self.config)
63
85
  raise_ci_warnings(path=self.repo()._root)
64
- except GitCommandError:
65
- if self.config.fallback_to_empty:
66
- self._fallback = True
67
- logger.warning(
68
- "[git-authors-plugin] Unable to find a git directory and/or git is not installed."
69
- " Option 'fallback_to_empty' set to 'true': Falling back to empty authors list"
70
- )
71
- else:
72
- raise
86
+
73
87
 
74
88
  def on_files(
75
89
  self, files: Files, *, config: MkDocsConfig, **kwargs
@@ -118,16 +132,16 @@ class GitAuthorsPlugin(BasePlugin[GitAuthorsPluginConfig]):
118
132
  if exclude(file.src_path, excluded_pages):
119
133
  continue
120
134
 
121
- if not hasattr(file, 'src_dir') or file.src_dir is None:
122
- logger.debug(
123
- f"[git-authors-plugin] Unable to find path for file {file.src_path}. "
124
- "Generated, in-memory files won't have a git history."
125
- )
126
- elif hasattr(file, "generated_by") and file.generated_by:
135
+ if hasattr(file, "generated_by") and file.generated_by:
127
136
  logger.debug(
128
137
  f"[git-authors-plugin] The file {file.src_path} was generated by {file.generated_by}. "
129
138
  "Generated, dynamic files won't have a git history."
130
139
  )
140
+ elif not hasattr(file, 'src_dir') or file.src_dir is None:
141
+ logger.debug(
142
+ f"[git-authors-plugin] Unable to find path for file {file.src_path}. "
143
+ "Generated, in-memory files won't have a git history."
144
+ )
131
145
  elif path := file.abs_src_path:
132
146
  if path.endswith(".md"):
133
147
  _ = self.repo().page(path)
@@ -1,6 +1,10 @@
1
1
  from datetime import datetime, timedelta, timezone
2
2
  from pathlib import Path
3
3
  from typing import Any, Dict, List
4
+ import os
5
+ from contextlib import contextmanager
6
+ from typing import Any, Generator
7
+ from pathlib import Path
4
8
 
5
9
  from mkdocs_git_authors_plugin.config import GitAuthorsPluginConfig
6
10
 
@@ -148,3 +152,26 @@ def page_authors(authors: List, path: str) -> List[Dict[str, Any]]:
148
152
  }
149
153
  for author in authors
150
154
  ]
155
+
156
+
157
+
158
+ @contextmanager
159
+ def working_directory(path) -> Generator[None, Any, None]:
160
+ """
161
+ Temporarily change working directory.
162
+ A context manager which changes the working directory to the given
163
+ path, and then changes it back to its previous value on exit.
164
+ Usage:
165
+ ```python
166
+ # Do something in original directory
167
+ with working_directory('/my/new/path'):
168
+ # Do something in new directory
169
+ # Back to old directory
170
+ ```
171
+ """
172
+ prev_cwd = os.getcwd()
173
+ os.chdir(path)
174
+ try:
175
+ yield
176
+ finally:
177
+ os.chdir(prev_cwd)
@@ -1,12 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: mkdocs-git-authors-plugin
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Mkdocs plugin to display git authors of a page
5
- Home-page: https://github.com/timvink/mkdocs-git-authors-plugin
6
- Author: Tim Vink
7
- Author-email: vinktim@gmail.com
5
+ Author-email: Tim Vink <vinktim@gmail.com>
8
6
  License: MIT
9
- Keywords: mkdocs git contributors committers authors plugin
7
+ Project-URL: Homepage, https://github.com/timvink/mkdocs-git-authors-plugin
8
+ Keywords: mkdocs,git,contributors,committers,authors,plugin
10
9
  Classifier: Operating System :: OS Independent
11
10
  Classifier: Programming Language :: Python
12
11
  Classifier: Programming Language :: Python :: 3
@@ -73,7 +72,7 @@ This plugin needs access to the last commit that touched a specific file to be a
73
72
  <summary>Change your CI settings</summary>
74
73
 
75
74
  - github actions: set `fetch_depth` to `0` ([docs](https://github.com/actions/checkout))
76
- - gitlab runners: set `GIT_DEPTH` to `1000` ([docs](https://docs.gitlab.com/ee/user/project/pipelines/settings.html#git-shallow-clone))
75
+ - gitlab runners: set `GIT_DEPTH` to `0` ([docs](https://docs.gitlab.com/ee/ci/pipelines/settings.html#limit-the-number-of-changes-fetched-during-clone))
77
76
  - bitbucket pipelines: set `clone: depth: full` ([docs](https://support.atlassian.com/bitbucket-cloud/docs/configure-bitbucket-pipelinesyml/))
78
77
  </details>
79
78
 
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/mkdocs_git_authors_plugin/__init__.py
5
+ src/mkdocs_git_authors_plugin/ci.py
6
+ src/mkdocs_git_authors_plugin/config.py
7
+ src/mkdocs_git_authors_plugin/exclude.py
8
+ src/mkdocs_git_authors_plugin/plugin.py
9
+ src/mkdocs_git_authors_plugin/util.py
10
+ src/mkdocs_git_authors_plugin.egg-info/PKG-INFO
11
+ src/mkdocs_git_authors_plugin.egg-info/SOURCES.txt
12
+ src/mkdocs_git_authors_plugin.egg-info/dependency_links.txt
13
+ src/mkdocs_git_authors_plugin.egg-info/entry_points.txt
14
+ src/mkdocs_git_authors_plugin.egg-info/requires.txt
15
+ src/mkdocs_git_authors_plugin.egg-info/top_level.txt
16
+ src/mkdocs_git_authors_plugin/git/__init__.py
17
+ src/mkdocs_git_authors_plugin/git/author.py
18
+ src/mkdocs_git_authors_plugin/git/command.py
19
+ src/mkdocs_git_authors_plugin/git/commit.py
20
+ src/mkdocs_git_authors_plugin/git/page.py
21
+ src/mkdocs_git_authors_plugin/git/repo.py
22
+ tests/test_basic.py
23
+ tests/test_util.py
@@ -20,9 +20,7 @@ import os
20
20
  import re
21
21
  import shutil
22
22
  import sys
23
- from contextlib import contextmanager
24
23
  from packaging.version import Version
25
- from typing import Any, Generator
26
24
 
27
25
  import git as gitpython
28
26
  import mkdocs
@@ -31,6 +29,8 @@ from click.testing import CliRunner, Result
31
29
  from git import Repo
32
30
  from mkdocs.__main__ import build_command
33
31
 
32
+ from mkdocs_git_authors_plugin.util import working_directory
33
+
34
34
  SITES_THAT_SHOULD_SUCCEED = [
35
35
  "mkdocs.yml",
36
36
  "mkdocs_complete_material.yml",
@@ -45,26 +45,6 @@ SITES_THAT_SHOULD_SUCCEED = [
45
45
  ]
46
46
 
47
47
 
48
- @contextmanager
49
- def working_directory(path) -> Generator[None, Any, None]:
50
- """
51
- Temporarily change working directory.
52
- A context manager which changes the working directory to the given
53
- path, and then changes it back to its previous value on exit.
54
- Usage:
55
- ```python
56
- # Do something in original directory
57
- with working_directory('/my/new/path'):
58
- # Do something in new directory
59
- # Back to old directory
60
- ```
61
- """
62
- prev_cwd = os.getcwd()
63
- os.chdir(path)
64
- try:
65
- yield
66
- finally:
67
- os.chdir(prev_cwd)
68
48
 
69
49
 
70
50
  def build_docs_setup(mkdocs_path, output_path) -> Result:
@@ -373,3 +353,31 @@ def test_mkapi_v1(tmp_path) -> None:
373
353
  r'<a href="\$api:src/mkdocs_git_authors_plugin.*" class="nav-link">API</a>',
374
354
  contents,
375
355
  )
356
+
357
+ def test_custom_docs_dir(tmp_path):
358
+
359
+ testproject_path = tmp_path / "testproject"
360
+ shutil.copytree("tests/custom_docs_dir", testproject_path)
361
+
362
+
363
+ # init git inside the docs directory
364
+ with working_directory(str(testproject_path / "documentation")):
365
+ # setup git history
366
+ repo = Repo.init(".")
367
+ assert not repo.bare
368
+ repo.git.add(all=True)
369
+ repo.index.commit("first commit")
370
+
371
+ with working_directory(str(testproject_path)):
372
+ result = build_docs_setup("mkdocs.yml", str(tmp_path / "site"))
373
+
374
+ assert (
375
+ result.exit_code == 0
376
+ ), f"'mkdocs build' command failed. Error: {result.stdout}"
377
+
378
+ index_file = tmp_path / "site" / "index.html"
379
+ assert index_file.exists(), f"{index_file} does not exist"
380
+
381
+ contents = index_file.read_text()
382
+ assert re.search("<span class='git-page-authors", contents)
383
+
@@ -1,23 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.py
4
- mkdocs_git_authors_plugin/__init__.py
5
- mkdocs_git_authors_plugin/ci.py
6
- mkdocs_git_authors_plugin/config.py
7
- mkdocs_git_authors_plugin/exclude.py
8
- mkdocs_git_authors_plugin/plugin.py
9
- mkdocs_git_authors_plugin/util.py
10
- mkdocs_git_authors_plugin.egg-info/PKG-INFO
11
- mkdocs_git_authors_plugin.egg-info/SOURCES.txt
12
- mkdocs_git_authors_plugin.egg-info/dependency_links.txt
13
- mkdocs_git_authors_plugin.egg-info/entry_points.txt
14
- mkdocs_git_authors_plugin.egg-info/requires.txt
15
- mkdocs_git_authors_plugin.egg-info/top_level.txt
16
- mkdocs_git_authors_plugin/git/__init__.py
17
- mkdocs_git_authors_plugin/git/author.py
18
- mkdocs_git_authors_plugin/git/command.py
19
- mkdocs_git_authors_plugin/git/commit.py
20
- mkdocs_git_authors_plugin/git/page.py
21
- mkdocs_git_authors_plugin/git/repo.py
22
- tests/test_basic.py
23
- tests/test_util.py
@@ -1,40 +0,0 @@
1
- from setuptools import find_packages, setup
2
-
3
- with open("README.md", "r") as fh:
4
- long_description = fh.read()
5
-
6
- setup(
7
- name="mkdocs-git-authors-plugin",
8
- version="0.9.2",
9
- description="Mkdocs plugin to display git authors of a page",
10
- long_description=long_description,
11
- long_description_content_type="text/markdown",
12
- keywords="mkdocs git contributors committers authors plugin",
13
- url="https://github.com/timvink/mkdocs-git-authors-plugin",
14
- author="Tim Vink",
15
- author_email="vinktim@gmail.com",
16
- license="MIT",
17
- python_requires=">=3.8",
18
- classifiers=[
19
- "Operating System :: OS Independent",
20
- "Programming Language :: Python",
21
- "Programming Language :: Python :: 3",
22
- "Programming Language :: Python :: 3.8",
23
- "Programming Language :: Python :: 3.9",
24
- "Programming Language :: Python :: 3.10",
25
- "Programming Language :: Python :: 3.11",
26
- "Programming Language :: Python :: 3.12",
27
- "Programming Language :: Python :: 3.13",
28
- "Programming Language :: Python :: 3 :: Only",
29
- "License :: OSI Approved :: MIT License",
30
- "Topic :: Documentation",
31
- "Topic :: Text Processing",
32
- ],
33
- install_requires=["mkdocs>=1.0"],
34
- packages=find_packages(),
35
- entry_points={
36
- "mkdocs.plugins": [
37
- "git-authors = mkdocs_git_authors_plugin.plugin:GitAuthorsPlugin"
38
- ]
39
- },
40
- )