mkdocs-branchcustomization-plugin 0.1.2__tar.gz → 1.0.0__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 (22) hide show
  1. mkdocs_branchcustomization_plugin-1.0.0/LICENSE +21 -0
  2. mkdocs_branchcustomization_plugin-1.0.0/PKG-INFO +54 -0
  3. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/README.md +9 -4
  4. mkdocs_branchcustomization_plugin-1.0.0/mkdocs_branchcustomization_plugin/__init__.py +3 -0
  5. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/mkdocs_branchcustomization_plugin/_version.py +4 -4
  6. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/mkdocs_branchcustomization_plugin/plugin.py +17 -11
  7. mkdocs_branchcustomization_plugin-1.0.0/mkdocs_branchcustomization_plugin.egg-info/PKG-INFO +54 -0
  8. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/mkdocs_branchcustomization_plugin.egg-info/SOURCES.txt +2 -3
  9. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/mkdocs_branchcustomization_plugin.egg-info/entry_points.txt +0 -1
  10. mkdocs_branchcustomization_plugin-1.0.0/pyproject.toml +40 -0
  11. mkdocs_branchcustomization_plugin-1.0.0/setup.cfg +4 -0
  12. mkdocs_branchcustomization_plugin-1.0.0/setup.py +9 -0
  13. mkdocs-branchcustomization-plugin-0.1.2/MANIFEST.in +0 -2
  14. mkdocs-branchcustomization-plugin-0.1.2/PKG-INFO +0 -52
  15. mkdocs-branchcustomization-plugin-0.1.2/mkdocs_branchcustomization_plugin/__init__.py +0 -4
  16. mkdocs-branchcustomization-plugin-0.1.2/mkdocs_branchcustomization_plugin.egg-info/PKG-INFO +0 -52
  17. mkdocs-branchcustomization-plugin-0.1.2/setup.cfg +0 -46
  18. mkdocs-branchcustomization-plugin-0.1.2/setup.py +0 -19
  19. mkdocs-branchcustomization-plugin-0.1.2/versioneer.py +0 -1822
  20. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/mkdocs_branchcustomization_plugin.egg-info/dependency_links.txt +0 -0
  21. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/mkdocs_branchcustomization_plugin.egg-info/requires.txt +0 -0
  22. {mkdocs-branchcustomization-plugin-0.1.2 → mkdocs_branchcustomization_plugin-1.0.0}/mkdocs_branchcustomization_plugin.egg-info/top_level.txt +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Christopher J Markiewicz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: mkdocs-branchcustomization-plugin
3
+ Version: 1.0.0
4
+ Summary: Update mkdocs configuration based on the git branch
5
+ Author-email: "Christopher J. Markiewicz" <markiewicz@stanford.edu>
6
+ Maintainer-email: "Christopher J. Markiewicz" <markiewicz@stanford.edu>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/effigies/mkdocs-branchcustomization-plugin
9
+ Platform: OS Independent
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Provides: mkdocs_branchcustomization_plugin
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: mkdocs
18
+ Requires-Dist: gitpython
19
+ Dynamic: license-file
20
+
21
+ # MkDocs Branch Customization Plugin
22
+
23
+ This plugin allows configuration options to be overridden on a per-branch basis.
24
+ Branches are matched with regular expressions.
25
+
26
+ An example for adding CSS to the `master` branch might be:
27
+
28
+ ```YAML
29
+ plugins:
30
+ - branchcustomization:
31
+ update_config:
32
+ - branch: /master/
33
+ extra_css:
34
+ - css/master_branch.css
35
+ ```
36
+
37
+ Note that this will *override* the global `extra_css` value.
38
+
39
+ To customize every branch *except* `master`:
40
+
41
+ ```YAML
42
+ plugins:
43
+ - branchcustomization:
44
+ update_config:
45
+ - branch: /(?!^master$)/
46
+ +extra_css:
47
+ - css/draft.css
48
+ extra_js:
49
+ - js/draft.js
50
+ ```
51
+
52
+ In this case the `+extra_css` indicates that this list should be *appended* to
53
+ the global `extra_css` value, rather than overriding it, while `extra_js` overrides
54
+ the global value.
@@ -10,7 +10,8 @@ plugins:
10
10
  - branchcustomization:
11
11
  update_config:
12
12
  - branch: /master/
13
- extra_css: css/master_branch.css
13
+ extra_css:
14
+ - css/master_branch.css
14
15
  ```
15
16
 
16
17
  Note that this will *override* the global `extra_css` value.
@@ -22,8 +23,12 @@ plugins:
22
23
  - branchcustomization:
23
24
  update_config:
24
25
  - branch: /(?!^master$)/
25
- extra_css: css/draft.css
26
- extra_js: js/draft.js
26
+ +extra_css:
27
+ - css/draft.css
28
+ extra_js:
29
+ - js/draft.js
27
30
  ```
28
31
 
29
- This is just to demonstrate that multiple configuration options can be overridden.
32
+ In this case the `+extra_css` indicates that this list should be *appended* to
33
+ the global `extra_css` value, rather than overriding it, while `extra_js` overrides
34
+ the global value.
@@ -0,0 +1,3 @@
1
+
2
+ from . import _version
3
+ __version__ = _version.get_versions()['version']
@@ -1,5 +1,5 @@
1
1
 
2
- # This file was generated by 'versioneer.py' (0.18) from
2
+ # This file was generated by 'versioneer.py' (0.29) from
3
3
  # revision-control system data, or from the parent directory name of an
4
4
  # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
5
  # of this file.
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2019-12-13T11:24:53-0500",
11
+ "date": "2026-09-30T11:44:19-0400",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "a7d4788070a79de79cd8fd04fa8d6c609afed78c",
15
- "version": "0.1.2"
14
+ "full-revisionid": "52867a3400aaf4dcd7fca44b5f5112b012e032a6",
15
+ "version": "1.0.0"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -5,16 +5,17 @@ from mkdocs.config.config_options import Type
5
5
  import git
6
6
 
7
7
 
8
- def get_best_name(repo):
8
+ def get_best_branch_name(repo):
9
9
  head = repo.head
10
10
  # We're on a branch, just go with it
11
11
  if not head.is_detached:
12
12
  return repo.active_branch.name
13
- # This commit is the current master
14
- if repo.heads.master.commit == head.commit:
15
- return 'master'
16
- # Prioritize tags and then branches in lexical order
17
- for ref in repo.tags + repo.heads:
13
+ # This commit is the current main/master
14
+ for main in ('main', 'master'):
15
+ if main in repo.heads and repo.heads[main].commit == head.commit:
16
+ return main
17
+ # Check local branches in lexical order
18
+ for ref in repo.heads:
18
19
  if ref.commit == head.commit:
19
20
  return ref.name
20
21
 
@@ -33,8 +34,7 @@ def get_best_name(repo):
33
34
  if ref.commit == head.commit:
34
35
  return ref.remote_head
35
36
 
36
- # Fallback to the commit hash
37
- return head.commit.hexsha
37
+ return None
38
38
 
39
39
 
40
40
  class BranchPlugin(BasePlugin):
@@ -47,9 +47,9 @@ class BranchPlugin(BasePlugin):
47
47
  self.repo = git.Repo('.', search_parent_directories=True)
48
48
 
49
49
  def on_config(self, config):
50
- branch_name = get_best_name(self.repo)
50
+ branch_name = get_best_branch_name(self.repo)
51
51
  log.debug(f"Detected HEAD name: {branch_name}")
52
- if self.config['update_config']:
52
+ if branch_name is not None and self.config['update_config']:
53
53
  for rule in self.config['update_config']:
54
54
  match = rule.pop('branch', None)
55
55
  if match is None or (match[0], match[-1]) != ('/', '/'):
@@ -58,6 +58,12 @@ class BranchPlugin(BasePlugin):
58
58
  if re.match(match[1:-1], branch_name):
59
59
  log.info(f"Branch {branch_name} matched rule {match}; "
60
60
  f"updating {tuple(rule.keys())}")
61
- config.update(rule)
61
+ for key, val in rule.items():
62
+ if key.startswith('+'):
63
+ key = key[1:]
64
+ orig = config.get(key, type(val)())
65
+ config[key] = orig + val
66
+ else:
67
+ config[key] = val
62
68
 
63
69
  return config
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: mkdocs-branchcustomization-plugin
3
+ Version: 1.0.0
4
+ Summary: Update mkdocs configuration based on the git branch
5
+ Author-email: "Christopher J. Markiewicz" <markiewicz@stanford.edu>
6
+ Maintainer-email: "Christopher J. Markiewicz" <markiewicz@stanford.edu>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/effigies/mkdocs-branchcustomization-plugin
9
+ Platform: OS Independent
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Provides: mkdocs_branchcustomization_plugin
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: mkdocs
18
+ Requires-Dist: gitpython
19
+ Dynamic: license-file
20
+
21
+ # MkDocs Branch Customization Plugin
22
+
23
+ This plugin allows configuration options to be overridden on a per-branch basis.
24
+ Branches are matched with regular expressions.
25
+
26
+ An example for adding CSS to the `master` branch might be:
27
+
28
+ ```YAML
29
+ plugins:
30
+ - branchcustomization:
31
+ update_config:
32
+ - branch: /master/
33
+ extra_css:
34
+ - css/master_branch.css
35
+ ```
36
+
37
+ Note that this will *override* the global `extra_css` value.
38
+
39
+ To customize every branch *except* `master`:
40
+
41
+ ```YAML
42
+ plugins:
43
+ - branchcustomization:
44
+ update_config:
45
+ - branch: /(?!^master$)/
46
+ +extra_css:
47
+ - css/draft.css
48
+ extra_js:
49
+ - js/draft.js
50
+ ```
51
+
52
+ In this case the `+extra_css` indicates that this list should be *appended* to
53
+ the global `extra_css` value, rather than overriding it, while `extra_js` overrides
54
+ the global value.
@@ -1,8 +1,7 @@
1
- MANIFEST.in
1
+ LICENSE
2
2
  README.md
3
- setup.cfg
3
+ pyproject.toml
4
4
  setup.py
5
- versioneer.py
6
5
  mkdocs_branchcustomization_plugin/__init__.py
7
6
  mkdocs_branchcustomization_plugin/_version.py
8
7
  mkdocs_branchcustomization_plugin/plugin.py
@@ -1,3 +1,2 @@
1
1
  [mkdocs.plugins]
2
2
  branchcustomization = mkdocs_branchcustomization_plugin.plugin:BranchPlugin
3
-
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.2", "versioneer"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mkdocs-branchcustomization-plugin"
7
+ authors = [{name = "Christopher J. Markiewicz", email = "markiewicz@stanford.edu"}]
8
+ maintainers = [{name = "Christopher J. Markiewicz", email = "markiewicz@stanford.edu"}]
9
+ readme = "README.md"
10
+ classifiers = [
11
+ "Development Status :: 5 - Production/Stable",
12
+ "Operating System :: OS Independent",
13
+ "Programming Language :: Python :: 3",
14
+ ]
15
+ license = "MIT"
16
+ description = "Update mkdocs configuration based on the git branch"
17
+ requires-python = ">=3.10"
18
+ dependencies = [
19
+ "mkdocs",
20
+ "gitpython",
21
+ ]
22
+ dynamic = ["version"]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/effigies/mkdocs-branchcustomization-plugin"
26
+
27
+ [project.entry-points."mkdocs.plugins"]
28
+ branchcustomization = "mkdocs_branchcustomization_plugin.plugin:BranchPlugin"
29
+
30
+ [tool.setuptools]
31
+ platforms = ["OS Independent"]
32
+ provides = ["mkdocs_branchcustomization_plugin"]
33
+
34
+ [tool.versioneer]
35
+ VCS = "git"
36
+ style = "pep440"
37
+ versionfile_source = "mkdocs_branchcustomization_plugin/_version.py"
38
+ versionfile_build = "mkdocs_branchcustomization_plugin/_version.py"
39
+ tag_prefix = ""
40
+ parentdir_prefix = ""
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python
2
+ from setuptools import setup
3
+ import versioneer
4
+
5
+ if __name__ == "__main__":
6
+ setup(
7
+ version=versioneer.get_version(),
8
+ cmdclass=versioneer.get_cmdclass(),
9
+ )
@@ -1,2 +0,0 @@
1
- include versioneer.py
2
- include mkdocs_branchcustomization_plugin/_version.py
@@ -1,52 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: mkdocs-branchcustomization-plugin
3
- Version: 0.1.2
4
- Summary: Update mkdocs configuration based on the git branch
5
- Home-page: https://github.com/effigies/mkdocs-branchcustomization-plugin
6
- Author: Christopher J. Markiewicz
7
- Author-email: markiewicz@stanford.edu
8
- Maintainer: Christopher J. Markiewicz
9
- Maintainer-email: markiewicz@stanford.edu
10
- License: MIT License
11
- Description: # MkDocs Branch Customization Plugin
12
-
13
- This plugin allows configuration options to be overridden on a per-branch basis.
14
- Branches are matched with regular expressions.
15
-
16
- An example for adding CSS to the `master` branch might be:
17
-
18
- ```YAML
19
- plugins:
20
- - branchcustomization:
21
- update_config:
22
- - branch: /master/
23
- extra_css: css/master_branch.css
24
- ```
25
-
26
- Note that this will *override* the global `extra_css` value.
27
-
28
- To customize every branch *except* `master`:
29
-
30
- ```YAML
31
- plugins:
32
- - branchcustomization:
33
- update_config:
34
- - branch: /(?!^master$)/
35
- extra_css: css/draft.css
36
- extra_js: js/draft.js
37
- ```
38
-
39
- This is just to demonstrate that multiple configuration options can be overridden.
40
-
41
- Platform: OS Independent
42
- Classifier: Development Status :: 3 - Alpha
43
- Classifier: License :: OSI Approved :: MIT License
44
- Classifier: Operating System :: OS Independent
45
- Classifier: Programming Language :: Python
46
- Classifier: Programming Language :: Python :: 3.5
47
- Classifier: Programming Language :: Python :: 3.6
48
- Classifier: Programming Language :: Python :: 3.7
49
- Classifier: Programming Language :: Python :: 3.8
50
- Provides: mkdocs_branchcustomization_plugin
51
- Requires-Python: >=3.6
52
- Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
@@ -1,4 +0,0 @@
1
-
2
- from ._version import get_versions
3
- __version__ = get_versions()['version']
4
- del get_versions
@@ -1,52 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: mkdocs-branchcustomization-plugin
3
- Version: 0.1.2
4
- Summary: Update mkdocs configuration based on the git branch
5
- Home-page: https://github.com/effigies/mkdocs-branchcustomization-plugin
6
- Author: Christopher J. Markiewicz
7
- Author-email: markiewicz@stanford.edu
8
- Maintainer: Christopher J. Markiewicz
9
- Maintainer-email: markiewicz@stanford.edu
10
- License: MIT License
11
- Description: # MkDocs Branch Customization Plugin
12
-
13
- This plugin allows configuration options to be overridden on a per-branch basis.
14
- Branches are matched with regular expressions.
15
-
16
- An example for adding CSS to the `master` branch might be:
17
-
18
- ```YAML
19
- plugins:
20
- - branchcustomization:
21
- update_config:
22
- - branch: /master/
23
- extra_css: css/master_branch.css
24
- ```
25
-
26
- Note that this will *override* the global `extra_css` value.
27
-
28
- To customize every branch *except* `master`:
29
-
30
- ```YAML
31
- plugins:
32
- - branchcustomization:
33
- update_config:
34
- - branch: /(?!^master$)/
35
- extra_css: css/draft.css
36
- extra_js: js/draft.js
37
- ```
38
-
39
- This is just to demonstrate that multiple configuration options can be overridden.
40
-
41
- Platform: OS Independent
42
- Classifier: Development Status :: 3 - Alpha
43
- Classifier: License :: OSI Approved :: MIT License
44
- Classifier: Operating System :: OS Independent
45
- Classifier: Programming Language :: Python
46
- Classifier: Programming Language :: Python :: 3.5
47
- Classifier: Programming Language :: Python :: 3.6
48
- Classifier: Programming Language :: Python :: 3.7
49
- Classifier: Programming Language :: Python :: 3.8
50
- Provides: mkdocs_branchcustomization_plugin
51
- Requires-Python: >=3.6
52
- Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
@@ -1,46 +0,0 @@
1
- [metadata]
2
- url = https://github.com/effigies/mkdocs-branchcustomization-plugin
3
- author = Christopher J. Markiewicz
4
- author_email = markiewicz@stanford.edu
5
- maintainer = Christopher J. Markiewicz
6
- maintainer_email = markiewicz@stanford.edu
7
- classifiers =
8
- Development Status :: 3 - Alpha
9
- License :: OSI Approved :: MIT License
10
- Operating System :: OS Independent
11
- Programming Language :: Python
12
- Programming Language :: Python :: 3.5
13
- Programming Language :: Python :: 3.6
14
- Programming Language :: Python :: 3.7
15
- Programming Language :: Python :: 3.8
16
- license = MIT License
17
- description = Update mkdocs configuration based on the git branch
18
- long_description = file:README.md
19
- long_description_content_type = text/markdown; charset=UTF-8; variant=GFM
20
- platforms = OS Independent
21
- provides =
22
- mkdocs_branchcustomization_plugin
23
-
24
- [options]
25
- python_requires = >=3.6
26
- install_requires =
27
- mkdocs
28
- gitpython
29
- packages = find:
30
-
31
- [options.entry_points]
32
- mkdocs.plugins =
33
- branchcustomization = mkdocs_branchcustomization_plugin.plugin:BranchPlugin
34
-
35
- [versioneer]
36
- vcs = git
37
- style = pep440
38
- versionfile_source = mkdocs_branchcustomization_plugin/_version.py
39
- versionfile_build = mkdocs_branchcustomization_plugin/_version.py
40
- tag_prefix =
41
- parentdir_prefix =
42
-
43
- [egg_info]
44
- tag_build =
45
- tag_date = 0
46
-
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env python
2
- import sys
3
- import os
4
-
5
- from setuptools import setup
6
- import versioneer
7
-
8
- # Give setuptools a hint to complain if it's too old a version
9
- # 30.3.0 allows us to put most metadata in setup.cfg
10
- # Should match pyproject.toml
11
- SETUP_REQUIRES = ['setuptools >= 30.3.0']
12
- # This enables setuptools to install wheel on-the-fly
13
- SETUP_REQUIRES += ['wheel'] if 'bdist_wheel' in sys.argv else []
14
-
15
- if __name__ == "__main__":
16
- setup(name='mkdocs-branchcustomization-plugin',
17
- setup_requires=SETUP_REQUIRES,
18
- version=versioneer.get_version(),
19
- cmdclass=versioneer.get_cmdclass())