mkdocstrings-github 0.4.2__py3-none-any.whl → 0.4.3__py3-none-any.whl
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.
- {mkdocstrings_github-0.4.2.dist-info → mkdocstrings_github-0.4.3.dist-info}/METADATA +1 -1
- {mkdocstrings_github-0.4.2.dist-info → mkdocstrings_github-0.4.3.dist-info}/RECORD +7 -7
- mkdocstrings_handlers/github/handler.py +31 -45
- mkdocstrings_handlers/github/rendering.py +5 -2
- mkdocstrings_handlers/github/templates/material/workflow.html.jinja +23 -19
- {mkdocstrings_github-0.4.2.dist-info → mkdocstrings_github-0.4.3.dist-info}/WHEEL +0 -0
- {mkdocstrings_github-0.4.2.dist-info → mkdocstrings_github-0.4.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
mkdocstrings_handlers/github/__init__.py,sha256=0WdFUIq4Xu2ZFtlZNIYCQSoqcx3Ot9Wv41_X_dwbFww,248
|
|
2
2
|
mkdocstrings_handlers/github/config.py,sha256=pSjA6gU-kC_mXQqNIIGOYEOhtX5VzZDT0H1hRFlGaj8,6089
|
|
3
|
-
mkdocstrings_handlers/github/handler.py,sha256=
|
|
3
|
+
mkdocstrings_handlers/github/handler.py,sha256=QJbZjRbllUuGs5rY6SLwaII6hsPQnioa_OmauWGL-lU,8495
|
|
4
4
|
mkdocstrings_handlers/github/objects.py,sha256=JDkY7mg_LGlIEwZHP2wSd8ZkB6RVtRsu_JEpwV-PikQ,7069
|
|
5
5
|
mkdocstrings_handlers/github/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
mkdocstrings_handlers/github/rendering.py,sha256=
|
|
6
|
+
mkdocstrings_handlers/github/rendering.py,sha256=6xcE2WwyTRW_38g7Ek55hlm53EsFFqueazFw12__DyA,2820
|
|
7
7
|
mkdocstrings_handlers/github/templates/material/action.html.jinja,sha256=87NCgz-zY16rU7tEmJETJ0gLwdzxoBrqLtp9vsVCsiw,2435
|
|
8
8
|
mkdocstrings_handlers/github/templates/material/heading.html.jinja,sha256=wnvZpNED8Dhb935qnddeDExXN-MIUz8frRRfgq-A9VA,1396
|
|
9
9
|
mkdocstrings_handlers/github/templates/material/inputs.html.jinja,sha256=CIcw3OBQdCP4e5A4srLu1v3xoOjsedIw1Zh3qxtG0-A,3482
|
|
10
10
|
mkdocstrings_handlers/github/templates/material/outputs.html.jinja,sha256=jlzVF93q5AyJfOiSl3_1VBVL3c6rjmEcS81s3sri5Gg,2670
|
|
11
11
|
mkdocstrings_handlers/github/templates/material/secrets.html.jinja,sha256=1lMJoxjjeiqetVu0mdLKmZ1faYRReeyjiYvYTZESots,2881
|
|
12
12
|
mkdocstrings_handlers/github/templates/material/style.css,sha256=R2hh1RfHwJ6XNT4YQl_txNkNXcPBZJMCBZn5kQEMQ6M,962
|
|
13
|
-
mkdocstrings_handlers/github/templates/material/workflow.html.jinja,sha256=
|
|
14
|
-
mkdocstrings_github-0.4.
|
|
15
|
-
mkdocstrings_github-0.4.
|
|
16
|
-
mkdocstrings_github-0.4.
|
|
17
|
-
mkdocstrings_github-0.4.
|
|
13
|
+
mkdocstrings_handlers/github/templates/material/workflow.html.jinja,sha256=89hEu1dagyqEV_40iTeCR4UKvdI4HlIJaUAebqugxNM,3400
|
|
14
|
+
mkdocstrings_github-0.4.3.dist-info/METADATA,sha256=0G1SP3Qs5hbC6rPz32iZ1uJT-jnaFq6X7pWNUfeHLnc,3340
|
|
15
|
+
mkdocstrings_github-0.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
mkdocstrings_github-0.4.3.dist-info/licenses/LICENSE,sha256=5enZtJ4zSp0Ps3jTqFQ4kadcx62BhgTaDNPrXWb3g3E,1069
|
|
17
|
+
mkdocstrings_github-0.4.3.dist-info/RECORD,,
|
|
@@ -4,7 +4,6 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
6
|
import re
|
|
7
|
-
import sys
|
|
8
7
|
from pathlib import Path
|
|
9
8
|
from typing import TYPE_CHECKING, Any, ClassVar, Mapping
|
|
10
9
|
|
|
@@ -68,13 +67,23 @@ class GitHubHandler(BaseHandler):
|
|
|
68
67
|
self.config = config
|
|
69
68
|
self.repo = repo
|
|
70
69
|
self.global_options = config.options.__dict__
|
|
71
|
-
self.workflows: dict[Path, Workflow] = {}
|
|
72
|
-
self.actions: dict[Path, Action] = {}
|
|
73
70
|
self.major: str = ""
|
|
74
71
|
self.semver: str = ""
|
|
75
72
|
|
|
76
73
|
# Determine owner and repo name
|
|
77
74
|
if not self.config.repo:
|
|
75
|
+
self.get_repo()
|
|
76
|
+
|
|
77
|
+
if rendering.ENV_MAJOR_TAG not in os.environ or rendering.ENV_SEMVER_TAG not in os.environ:
|
|
78
|
+
self.get_releases()
|
|
79
|
+
|
|
80
|
+
def get_repo(self) -> None:
|
|
81
|
+
# Get repo from environment variable or git remotes.
|
|
82
|
+
if os.environ.get("GITHUB_ACTIONS") == "true" and (
|
|
83
|
+
repo := os.environ.get("GITHUB_REPOSITORY")
|
|
84
|
+
):
|
|
85
|
+
self.config.repo = repo
|
|
86
|
+
else:
|
|
78
87
|
# Try each remote to find a valid GitHub owner/repo
|
|
79
88
|
owner = None
|
|
80
89
|
repo_name = None
|
|
@@ -96,41 +105,8 @@ class GitHubHandler(BaseHandler):
|
|
|
96
105
|
)
|
|
97
106
|
self.config.repo = f"{owner}/{repo_name}"
|
|
98
107
|
|
|
99
|
-
# Only run GitHub releases code if required and not in testing
|
|
100
|
-
not_testing = "pytest" not in sys.modules
|
|
101
|
-
no_custom_tags = (
|
|
102
|
-
rendering.ENV_MAJOR_TAG not in os.environ or rendering.ENV_SEMVER_TAG not in os.environ
|
|
103
|
-
)
|
|
104
|
-
if not_testing and no_custom_tags:
|
|
105
|
-
self.get_releases()
|
|
106
|
-
|
|
107
|
-
# Glob all workflow YAML files using pathlib
|
|
108
|
-
working_tree_dir = Path(repo.working_tree_dir)
|
|
109
|
-
workflows_dir = working_tree_dir / ".github" / "workflows"
|
|
110
|
-
for workflow_file in list(workflows_dir.glob("*.yml")) + list(workflows_dir.glob("*.yaml")):
|
|
111
|
-
id = str(workflow_file.relative_to(working_tree_dir))
|
|
112
|
-
workflow = Workflow.from_file(workflow_file, id)
|
|
113
|
-
if workflow is not None:
|
|
114
|
-
self.workflows[workflow_file] = workflow
|
|
115
|
-
|
|
116
|
-
# Glob all action.yaml and action.yml files, skipping .git folder entirely using pathlib
|
|
117
|
-
def find_action_files(base: Path):
|
|
118
|
-
for entry in base.iterdir():
|
|
119
|
-
if entry.is_dir():
|
|
120
|
-
if entry.name == ".git":
|
|
121
|
-
continue
|
|
122
|
-
yield from find_action_files(entry)
|
|
123
|
-
elif entry.is_file() and entry.name in ("action.yaml", "action.yml"):
|
|
124
|
-
yield entry
|
|
125
|
-
|
|
126
|
-
for action_file in find_action_files(working_tree_dir):
|
|
127
|
-
id = str(action_file.relative_to(working_tree_dir).parent)
|
|
128
|
-
action = Action.from_file(action_file, id)
|
|
129
|
-
if action is not None:
|
|
130
|
-
self.actions[action_file] = action
|
|
131
|
-
|
|
132
108
|
def get_releases(self) -> None:
|
|
133
|
-
# Get all tags from the local git repository
|
|
109
|
+
# Get all tags from the local git repository.
|
|
134
110
|
try:
|
|
135
111
|
tags = [tag.name for tag in self.repo.tags]
|
|
136
112
|
except Exception as e:
|
|
@@ -204,16 +180,26 @@ class GitHubHandler(BaseHandler):
|
|
|
204
180
|
self.env.globals["major_tag"] = self.major
|
|
205
181
|
self.env.globals["git_repo"] = self.repo
|
|
206
182
|
|
|
207
|
-
def collect(self, identifier: str, options: GitHubOptions) -> Workflow | Action:
|
|
183
|
+
def collect(self, identifier: str, options: GitHubOptions) -> Workflow | Action | None:
|
|
208
184
|
path = Path(self.repo.working_tree_dir) / identifier
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
185
|
+
|
|
186
|
+
if path.suffix in (".yml", ".yaml"):
|
|
187
|
+
if not path.is_file():
|
|
188
|
+
raise CollectionError(f"Identifier '{identifier}' is not a valid workflow file.")
|
|
189
|
+
data = Workflow.from_file(path, id=identifier)
|
|
190
|
+
elif not path.is_dir():
|
|
191
|
+
raise CollectionError(
|
|
192
|
+
f"Identifier '{identifier}' is not a valid workflow file or action directory."
|
|
193
|
+
)
|
|
194
|
+
elif (action_path := path / "action.yml").is_file():
|
|
195
|
+
data = Action.from_file(action_path, id=identifier)
|
|
196
|
+
elif (action_path := path / "action.yaml").is_file():
|
|
197
|
+
data = Action.from_file(action_path, id=identifier)
|
|
215
198
|
else:
|
|
216
|
-
raise CollectionError(
|
|
199
|
+
raise CollectionError(
|
|
200
|
+
f"Identifier '{identifier}' is not a valid workflow file or action directory."
|
|
201
|
+
)
|
|
202
|
+
return data
|
|
217
203
|
|
|
218
204
|
def render(self, data: Workflow | Action, options: GitHubOptions) -> str:
|
|
219
205
|
"""Render a template using provided data and configuration options.
|
|
@@ -23,8 +23,11 @@ def format_action_signature(context: Context, id: str, repo: str, options: GitHu
|
|
|
23
23
|
match options.signature_version:
|
|
24
24
|
case "ref":
|
|
25
25
|
try:
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
git_repo = context.environment.globals["git_repo"]
|
|
27
|
+
if isinstance(git_repo, Repo):
|
|
28
|
+
version = git_repo.head.ref.name
|
|
29
|
+
else:
|
|
30
|
+
version = "unknown"
|
|
28
31
|
except Exception:
|
|
29
32
|
version = "unknown"
|
|
30
33
|
case "major":
|
|
@@ -24,25 +24,29 @@ Context:
|
|
|
24
24
|
|
|
25
25
|
{% block signature scoped %}
|
|
26
26
|
{% if options.show_signature %}
|
|
27
|
-
{%
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
permissions
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{%
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
27
|
+
{% filter highlight(language="yaml", inline=False, linenums=False) %}
|
|
28
|
+
uses: {{ signature }}
|
|
29
|
+
{% if options.signature_show_permissions and data.permissions|length > 0 %}
|
|
30
|
+
permissions:
|
|
31
|
+
{% for scope, level in data.permissions | items %}
|
|
32
|
+
{{ scope }}: {{ level.label }}
|
|
33
|
+
{% endfor %}
|
|
34
|
+
{% endif %}
|
|
35
|
+
{% with inputs = data.inputs | order_parameters(options.parameters_order) | filter_parameters(required=True) %}
|
|
36
|
+
{% if inputs|length > 0 %}
|
|
37
|
+
with:
|
|
38
|
+
{%+ for input in inputs %}{{ input.name }}: ''{% endfor +%}
|
|
39
|
+
{% endif %}
|
|
40
|
+
{% endwith %}
|
|
41
|
+
{% if options.signature_show_secrets %}
|
|
42
|
+
{% with secrets = data.secrets | order_parameters(options.parameters_order) | filter_parameters(required=True) %}
|
|
43
|
+
{% if secrets|length > 0 %}
|
|
44
|
+
secrets:
|
|
45
|
+
{%+ for secret in secrets %}{{ secret.name }}: ''{% endfor +%}
|
|
46
|
+
{% endif %}
|
|
47
|
+
{% endwith %}
|
|
48
|
+
{% endif %}
|
|
49
|
+
{% endfilter %}
|
|
46
50
|
{% endif %}
|
|
47
51
|
{% endblock signature %}
|
|
48
52
|
|
|
File without changes
|
{mkdocstrings_github-0.4.2.dist-info → mkdocstrings_github-0.4.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|