You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-12Lines changed: 28 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,10 @@
1
1
# mkdocs-git-committers-plugin-2
2
2
3
3
MkDocs plugin for displaying a list of committers associated with a file in
4
-
mkdocs. The plugin uses [GitHub's GraphQL
5
-
API](https://docs.github.com/en/graphql) to fetch the list of contributors for
6
-
each page.
4
+
mkdocs. The plugin uses GitHub or GitLab API to fetch the list of contributors
5
+
for each page.
6
+
7
+
🥳 NEW! Works with GitLab too!
7
8
8
9
For ease of use, this plugin is integrated in the [material for
9
10
mkdocs](https://squidfunk.github.io/mkdocs-material/) theme by [Martin
@@ -23,37 +24,52 @@ Install the plugin using pip:
23
24
24
25
Activate the plugin in `mkdocs.yml`:
25
26
27
+
For a repository hosted on GitHub:
28
+
26
29
```yaml
27
30
plugins:
28
31
- git-committers:
29
32
repository: organization/repository
30
-
branch: main
31
-
token: !ENV ["MKDOCS_GIT_COMMITTERS_APIKEY"]
32
33
```
33
34
34
-
If the token is not set in `mkdocs.yml` it will be read from the `MKDOCS_GIT_COMMITTERS_APIKEY` environment variable.
35
+
For a repository hosted on GitLab:
35
36
36
-
**Change in 2.0.0: if no token is present, the plugin will NOT add provide git committers.**
37
+
```yaml
38
+
plugins:
39
+
- git-committers:
40
+
gitlab_repository: 12345678
41
+
token: !ENV ["GH_TOKEN"]
42
+
```
37
43
38
-
> **Note:** If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.
44
+
For a repository hosted on GitLab, you need to provide a token so that the
45
+
plugin can access the GitLab API. If the token is not set in `mkdocs.yml` it
46
+
will be read from the `MKDOCS_GIT_COMMITTERS_APIKEY` environment variable.
39
47
40
-
More information about plugins in the [MkDocs documentation][mkdocs-plugins].
48
+
For a repository hosted on GitHub, you can provide a token to increase the rate
49
+
limit and go beyond the default 60 requests per hour per IP address. The plugin
50
+
will make one request per mkdocs document. The token does not need any scope:
51
+
uncheck everything when creating the GitHub Token at
- `enabled` - Disables plugin if set to `False` for e.g. local builds (default: `True`)
45
-
- `repository`- The name of the repository, e.g. 'ojacques/mkdocs-git-committers-plugin-2'
58
+
- `repository`- For GitHub, the name of the repository, e.g. 'ojacques/mkdocs-git-committers-plugin-2'
59
+
- `gitlab_repository`- For GitLab, the project ID, e.g. '12345678'
46
60
- `branch` - The name of the branch to get contributors from. Example: 'master'(default)
47
61
- `token` - A github fine-grained token for GitHub GraphQL API calls (classic tokens work too). The token does not need any scope: uncheck everything when creating the GitHub Token at [github.com/settings/personal-access-tokens/new](https://github.com/settings/personal-access-tokens/new), unless you access private repositories.
48
-
- `enterprise_hostname` - For GitHub enterprise: the enterprise hostname.
62
+
- `enterprise_hostname` - For GitHub enterprise: the GitHub enterprise hostname.
63
+
- `gitlab_hostname` - For GitLab: the GitLab hostname if different from gitlab.com (self-hosted).
49
64
- `docs_path`- the path to the documentation folder. Defaults to `docs`.
50
-
- `cache_dir`- The path which holds the authors cache file to speed up documentation builds. Defaults to `.cache/plugin/git-committers/`. The cache file is named `page-authors.json.json`.
65
+
- `cache_dir`- The path which holds the authors cache file to speed up documentation builds. Defaults to `.cache/plugin/git-committers/`. The cache file is named `page-authors.json`.
51
66
- `exclude` - Specify a list of page source paths (one per line) that should not have author(s) or last commit date included (excluded from processing by this plugin). Default is empty. Examples:
LOG.warning("git-committers plugin now requires a GitHub token. Set it under 'token' mkdocs.yml config or MKDOCS_GIT_COMMITTERS_APIKEY environment variable.")
LOG.error("git-committers plugin: GitLab API requires a token. Set it under 'token' mkdocs.yml config or MKDOCS_GIT_COMMITTERS_APIKEY environment variable.")
77
+
else:
78
+
LOG.warning("git-committers plugin may require a GitHub or GitLab token if you exceed the API rate limit or for private repositories. Set it under 'token' mkdocs.yml config or MKDOCS_GIT_COMMITTERS_APIKEY environment variable.")
63
79
self.localrepo=Repo(".")
64
80
self.branch=self.config['branch']
65
81
self.excluded_pages=self.config['exclude']
66
82
returnconfig
67
83
68
-
# Get unique contributors for a given path using GitHub GraphQL API
69
-
defget_contributors_to_path(self, path):
70
-
# Query GraphQL API, and get a list of unique authors
LOG.error("git-committers: error fetching contributors for "+path)
143
+
ifr.status_code==403orr.status_code==401:
144
+
LOG.error("git-committers: "+str(r.status_code) +" "+r.reason+" - You may have exceeded the API rate limit or need to be authorized. You can set a token under 'token' mkdocs.yml config or MKDOCS_GIT_COMMITTERS_APIKEY environment variable.")
Copy file name to clipboardExpand all lines: setup.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -9,8 +9,8 @@
9
9
10
10
setup(
11
11
name="mkdocs-git-committers-plugin-2",
12
-
version="2.0.1",
13
-
description="An MkDocs plugin to create a list of contributors on the page. The git-committers plugin will seed the template context with a list of github committers and other useful GIT info such as last modified date",
12
+
version="2.1.0",
13
+
description="An MkDocs plugin to create a list of contributors on the page. The git-committers plugin will seed the template context with a list of GitHub or GitLab committers and other useful GIT info such as last modified date",
0 commit comments