mkdocstrings-github 0.2.6__py3-none-any.whl → 0.4.0__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.2.6.dist-info → mkdocstrings_github-0.4.0.dist-info}/METADATA +4 -3
- {mkdocstrings_github-0.2.6.dist-info → mkdocstrings_github-0.4.0.dist-info}/RECORD +10 -10
- mkdocstrings_handlers/github/config.py +0 -5
- mkdocstrings_handlers/github/handler.py +13 -74
- mkdocstrings_handlers/github/rendering.py +14 -0
- mkdocstrings_handlers/github/templates/material/inputs.html.jinja +14 -4
- mkdocstrings_handlers/github/templates/material/outputs.html.jinja +4 -0
- mkdocstrings_handlers/github/templates/material/secrets.html.jinja +5 -0
- {mkdocstrings_github-0.2.6.dist-info → mkdocstrings_github-0.4.0.dist-info}/WHEEL +0 -0
- {mkdocstrings_github-0.2.6.dist-info → mkdocstrings_github-0.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mkdocstrings-github
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A GitHub Action handler for mkdocstrings
|
|
5
5
|
Author-email: Mark Hu <watermarkhu@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -14,15 +14,15 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
18
|
Classifier: Topic :: Documentation
|
|
18
19
|
Classifier: Topic :: Software Development
|
|
19
20
|
Classifier: Topic :: Software Development :: Documentation
|
|
20
21
|
Classifier: Topic :: Utilities
|
|
21
22
|
Classifier: Typing :: Typed
|
|
22
|
-
Requires-Python: <3.
|
|
23
|
+
Requires-Python: <3.15,>=3.10
|
|
23
24
|
Requires-Dist: gitpython~=3.1.45
|
|
24
25
|
Requires-Dist: mkdocstrings~=0.29
|
|
25
|
-
Requires-Dist: pygithub~=2.8.1
|
|
26
26
|
Requires-Dist: typing-extensions>=4.0; python_version < '3.11'
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
|
|
@@ -37,6 +37,7 @@ Description-Content-Type: text/markdown
|
|
|
37
37
|
[](https://github.com/watermarkhu/mkdocstrings-github/actions/workflows/qualify.yaml)
|
|
38
38
|
[](https://watermarkhu.nl/mkdocstrings-github)
|
|
39
39
|
[](https://pypi.org/project/mkdocstrings-github/)
|
|
40
|
+
[](https://codecov.io/github/watermarkhu/mkdocstrings-github)
|
|
40
41
|
|
|
41
42
|
<!-- --8<-- [end:header] -->
|
|
42
43
|
<!-- --8<-- [start:install] -->
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
mkdocstrings_handlers/github/__init__.py,sha256=0WdFUIq4Xu2ZFtlZNIYCQSoqcx3Ot9Wv41_X_dwbFww,248
|
|
2
|
-
mkdocstrings_handlers/github/config.py,sha256=
|
|
3
|
-
mkdocstrings_handlers/github/handler.py,sha256=
|
|
2
|
+
mkdocstrings_handlers/github/config.py,sha256=pSjA6gU-kC_mXQqNIIGOYEOhtX5VzZDT0H1hRFlGaj8,6089
|
|
3
|
+
mkdocstrings_handlers/github/handler.py,sha256=xRvBMbQexYB-qWivLzNMMSP87fzPM3cPYBi1qZNrVDw,7931
|
|
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=tJeAsSaijqSC2IkxYsIXq7d0lR2A3aB5PRUcFFTFpVU,2705
|
|
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
|
-
mkdocstrings_handlers/github/templates/material/inputs.html.jinja,sha256=
|
|
10
|
-
mkdocstrings_handlers/github/templates/material/outputs.html.jinja,sha256=
|
|
11
|
-
mkdocstrings_handlers/github/templates/material/secrets.html.jinja,sha256=
|
|
9
|
+
mkdocstrings_handlers/github/templates/material/inputs.html.jinja,sha256=CIcw3OBQdCP4e5A4srLu1v3xoOjsedIw1Zh3qxtG0-A,3482
|
|
10
|
+
mkdocstrings_handlers/github/templates/material/outputs.html.jinja,sha256=jlzVF93q5AyJfOiSl3_1VBVL3c6rjmEcS81s3sri5Gg,2670
|
|
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
13
|
mkdocstrings_handlers/github/templates/material/workflow.html.jinja,sha256=E1VUi2w7_NDkpS9VNrWRV52hhyhQvnKUrjPbV_j0Qcg,3312
|
|
14
|
-
mkdocstrings_github-0.
|
|
15
|
-
mkdocstrings_github-0.
|
|
16
|
-
mkdocstrings_github-0.
|
|
17
|
-
mkdocstrings_github-0.
|
|
14
|
+
mkdocstrings_github-0.4.0.dist-info/METADATA,sha256=01wUyZdvlbDHBFUqUP8Qmobe61BfAS-_HsI_6nak4cQ,3309
|
|
15
|
+
mkdocstrings_github-0.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
mkdocstrings_github-0.4.0.dist-info/licenses/LICENSE,sha256=5enZtJ4zSp0Ps3jTqFQ4kadcx62BhgTaDNPrXWb3g3E,1069
|
|
17
|
+
mkdocstrings_github-0.4.0.dist-info/RECORD,,
|
|
@@ -171,11 +171,6 @@ class GitHubOptions(BaseModel):
|
|
|
171
171
|
class GitHubConfig(BaseModel):
|
|
172
172
|
"""Configuration options for the GitHub handler."""
|
|
173
173
|
|
|
174
|
-
hostname: str = Field(
|
|
175
|
-
default="github.com",
|
|
176
|
-
description="The hostname of the GitHub instance to use. This is only needed for GitHub Enterprise installations.",
|
|
177
|
-
)
|
|
178
|
-
|
|
179
174
|
repo: str = Field(
|
|
180
175
|
default="",
|
|
181
176
|
description="""The GitHub repository in the format *owner/repo*.
|
|
@@ -4,7 +4,6 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import os
|
|
6
6
|
import re
|
|
7
|
-
import subprocess
|
|
8
7
|
import sys
|
|
9
8
|
from pathlib import Path
|
|
10
9
|
from typing import TYPE_CHECKING, Any, ClassVar, Mapping
|
|
@@ -18,7 +17,6 @@ from mkdocstrings import (
|
|
|
18
17
|
get_logger,
|
|
19
18
|
)
|
|
20
19
|
|
|
21
|
-
from github import Auth, Github
|
|
22
20
|
from mkdocstrings_handlers.github import rendering
|
|
23
21
|
from mkdocstrings_handlers.github.config import GitHubConfig, GitHubOptions
|
|
24
22
|
from mkdocstrings_handlers.github.objects import Action, Workflow
|
|
@@ -108,80 +106,20 @@ class GitHubHandler(BaseHandler):
|
|
|
108
106
|
self.actions[action_file] = action
|
|
109
107
|
|
|
110
108
|
def get_releases(self) -> None:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
elif gh_host.startswith("api."):
|
|
118
|
-
base_url = f"https://{gh_host}"
|
|
119
|
-
else:
|
|
120
|
-
base_url = f"https://api.{gh_host}"
|
|
121
|
-
|
|
122
|
-
_logger.debug(f"Using GitHub API base URL: {base_url}")
|
|
109
|
+
# Get all tags from the local git repository
|
|
110
|
+
try:
|
|
111
|
+
tags = [tag.name for tag in self.repo.tags]
|
|
112
|
+
except Exception as e:
|
|
113
|
+
_logger.warning(f"Could not get git tags from repository: {e}")
|
|
114
|
+
return
|
|
123
115
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
_logger.debug(f"Using GitHub authentication from environment variable {token_key}")
|
|
127
|
-
elif (token_key := "GITHUB_TOKEN") in os.environ:
|
|
128
|
-
gh = Github(base_url=base_url, auth=Auth.Token(os.environ[token_key]))
|
|
129
|
-
_logger.debug(f"Using GitHub authentication from environment variable {token_key}")
|
|
130
|
-
else:
|
|
131
|
-
try:
|
|
132
|
-
gh = Github(base_url=base_url, auth=Auth.NetrcAuth())
|
|
133
|
-
_logger.debug("Using GitHub authentication from .netrc")
|
|
134
|
-
except RuntimeError:
|
|
135
|
-
try:
|
|
136
|
-
token = subprocess.check_output(
|
|
137
|
-
["gh", "auth", "token"], text=True, env=os.environ
|
|
138
|
-
).strip()
|
|
139
|
-
if token:
|
|
140
|
-
gh = Github(base_url=base_url, auth=Auth.Token(token))
|
|
141
|
-
_logger.debug("Using GitHub authentication from gh cli.")
|
|
142
|
-
else:
|
|
143
|
-
raise RuntimeError("No token from gh auth token")
|
|
144
|
-
except Exception:
|
|
145
|
-
_logger.warning(
|
|
146
|
-
"Could not authenticate with GitHub to get releases. "
|
|
147
|
-
"Consider setting .netrc, environment variable GH_TOKEN, "
|
|
148
|
-
"or using GitHub CLI (`gh auth login`) to get GitHub releases.",
|
|
149
|
-
)
|
|
150
|
-
gh = Github(base_url=base_url)
|
|
151
|
-
|
|
152
|
-
# Determine owner and repo name
|
|
153
|
-
if "/" in self.config.repo:
|
|
154
|
-
owner, repo_name = self.config.repo.split("/", 1)
|
|
155
|
-
else:
|
|
156
|
-
# Try each remote to find a valid GitHub owner/repo
|
|
157
|
-
owner = None
|
|
158
|
-
repo_name = None
|
|
159
|
-
for remote in self.repo.remotes:
|
|
160
|
-
for url in remote.urls:
|
|
161
|
-
match = re.search(
|
|
162
|
-
r"(?P<host>[\w\.-]+)[/:](?P<owner>[^/]+)/(?P<repo>[^/.]+?)(?:\.git)?$",
|
|
163
|
-
url,
|
|
164
|
-
)
|
|
165
|
-
if match:
|
|
166
|
-
owner = match.group("owner")
|
|
167
|
-
repo_name = match.group("repo")
|
|
168
|
-
break
|
|
169
|
-
if owner and repo_name:
|
|
170
|
-
break
|
|
171
|
-
if not (owner and repo_name):
|
|
172
|
-
raise PluginError(
|
|
173
|
-
f"Could not determine GitHub repository owner/name from config.repo='{self.config.repo}' or any git remote URL."
|
|
174
|
-
)
|
|
175
|
-
self.config.repo = f"{owner}/{repo_name}"
|
|
176
|
-
|
|
177
|
-
# Get releases
|
|
178
|
-
gh_repo = gh.get_repo(f"{owner}/{repo_name}")
|
|
179
|
-
releases = list(gh_repo.get_releases())
|
|
180
|
-
for release in releases:
|
|
181
|
-
tag = release.tag_name
|
|
116
|
+
# Find matching tags
|
|
117
|
+
for tag in tags:
|
|
182
118
|
if not self.semver and SEMVER_PATTERN.match(tag):
|
|
119
|
+
_logger.info(f"Using git tag '{tag}' for semver.")
|
|
183
120
|
self.semver = tag
|
|
184
121
|
if not self.major and MAJOR_PATTERN.match(tag):
|
|
122
|
+
_logger.info(f"Using git tag '{tag}' for major.")
|
|
185
123
|
self.major = tag
|
|
186
124
|
if self.semver and self.major:
|
|
187
125
|
break
|
|
@@ -194,8 +132,8 @@ class GitHubHandler(BaseHandler):
|
|
|
194
132
|
else: # not self.major
|
|
195
133
|
messages = ("'vX'", "'major'")
|
|
196
134
|
_logger.warning(
|
|
197
|
-
f"Could not find suitable
|
|
198
|
-
f"Make sure there are
|
|
135
|
+
f"Could not find suitable git tags in repository. "
|
|
136
|
+
f"Make sure there are tags matching {messages[0]}, "
|
|
199
137
|
f"if you wish to use option signature_version {messages[1]}.",
|
|
200
138
|
)
|
|
201
139
|
|
|
@@ -223,6 +161,7 @@ class GitHubHandler(BaseHandler):
|
|
|
223
161
|
self.env.filters["order_parameters"] = rendering.order_parameters
|
|
224
162
|
self.env.filters["filter_parameters"] = rendering.filter_parameters
|
|
225
163
|
self.env.filters["anchor_id"] = rendering.anchor_id
|
|
164
|
+
self.env.filters["as_string"] = rendering.as_string
|
|
226
165
|
self.env.globals["semver_tag"] = self.semver
|
|
227
166
|
self.env.globals["major_tag"] = self.major
|
|
228
167
|
self.env.globals["git_repo"] = self.repo
|
|
@@ -72,3 +72,17 @@ def filter_parameters(
|
|
|
72
72
|
def anchor_id(name: str, prefix: str, parent_id: str) -> str:
|
|
73
73
|
anchor = f"{parent_id}--{prefix}.{name}"
|
|
74
74
|
return anchor.replace(" ", "-")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def as_string(value: bool | str | int | float | None) -> str:
|
|
78
|
+
match value:
|
|
79
|
+
case bool():
|
|
80
|
+
return "true" if value else "false"
|
|
81
|
+
case str():
|
|
82
|
+
return value
|
|
83
|
+
case int() | float():
|
|
84
|
+
return str(value)
|
|
85
|
+
case None:
|
|
86
|
+
return ""
|
|
87
|
+
case _:
|
|
88
|
+
raise TypeError(f"Unsupported type: {type(value)}")
|
|
@@ -11,10 +11,16 @@ Context:
|
|
|
11
11
|
{{ log.debug("Rendering inputs of " + data.id) }}
|
|
12
12
|
{% endblock logs %}
|
|
13
13
|
|
|
14
|
+
{# If there are no inputs, do not render anything. #}
|
|
15
|
+
{% if inputs | length > 0 %}
|
|
16
|
+
|
|
14
17
|
{% set header_id -%}
|
|
15
18
|
inputs-{{ data.id | replace('/', '-') | replace('.', '') | lower }}
|
|
16
19
|
{%- endset %}
|
|
17
20
|
|
|
21
|
+
{% set default_column = inputs | selectattr("default") | list | length > 0 %}
|
|
22
|
+
|
|
23
|
+
{# Render the inputs section #}
|
|
18
24
|
{% if options.parameters_section_style == "table" %}
|
|
19
25
|
{% block table_style scoped %}
|
|
20
26
|
<p>
|
|
@@ -26,7 +32,7 @@ Context:
|
|
|
26
32
|
<tr>
|
|
27
33
|
<th>Name</th>
|
|
28
34
|
<th>Description</th>
|
|
29
|
-
<th>Default</th>
|
|
35
|
+
{% if default_column %}<th>Default</th>{% endif %}
|
|
30
36
|
</tr>
|
|
31
37
|
</thead>
|
|
32
38
|
<tbody>
|
|
@@ -50,11 +56,13 @@ Context:
|
|
|
50
56
|
<td>
|
|
51
57
|
{{ input.description | convert_markdown(options.heading_level, data.id) }}
|
|
52
58
|
</td>
|
|
59
|
+
{% if default_column %}
|
|
53
60
|
<td>
|
|
54
|
-
{% if input.default %}
|
|
55
|
-
<code>{{ input.default }}</code>
|
|
61
|
+
{% if input.default is not none %}
|
|
62
|
+
<code>{{ input.default | as_string }}</code>
|
|
56
63
|
{% endif %}
|
|
57
64
|
</td>
|
|
65
|
+
{% endif %}
|
|
58
66
|
</tr>
|
|
59
67
|
{% endfor %}
|
|
60
68
|
</tbody>
|
|
@@ -80,7 +88,7 @@ Context:
|
|
|
80
88
|
</div>
|
|
81
89
|
{% if input.default is not none %}
|
|
82
90
|
<div class="doc-md-description">
|
|
83
|
-
Default: <code>{{ input.default }}</code>
|
|
91
|
+
Default: <code>{{ input.default | as_string }}</code>
|
|
84
92
|
</div>
|
|
85
93
|
{% endif %}
|
|
86
94
|
</li>
|
|
@@ -88,3 +96,5 @@ Context:
|
|
|
88
96
|
</ul>
|
|
89
97
|
{% endblock list_style %}
|
|
90
98
|
{% endif %}
|
|
99
|
+
|
|
100
|
+
{% endif %}
|
|
@@ -11,6 +11,9 @@ Context:
|
|
|
11
11
|
{{ log.debug("Rendering outputs of " + data.id) }}
|
|
12
12
|
{% endblock logs %}
|
|
13
13
|
|
|
14
|
+
{# If there are no outputs, do not render anything. #}
|
|
15
|
+
{% if outputs | length > 0 %}
|
|
16
|
+
|
|
14
17
|
{% set header_id -%}
|
|
15
18
|
outputs-{{ data.id | replace('/', '-') | replace('.', '') | lower }}
|
|
16
19
|
{%- endset %}
|
|
@@ -72,3 +75,4 @@ Context:
|
|
|
72
75
|
{% endblock list_style %}
|
|
73
76
|
{% endif %}
|
|
74
77
|
|
|
78
|
+
{% endif %}
|
|
@@ -11,6 +11,9 @@ Context:
|
|
|
11
11
|
{{ log.debug("Rendering secrets of " + data.id) }}
|
|
12
12
|
{% endblock logs %}
|
|
13
13
|
|
|
14
|
+
{# If there are no secrets, do not render anything. #}
|
|
15
|
+
{% if secrets | length > 0 %}
|
|
16
|
+
|
|
14
17
|
{% set header_id -%}
|
|
15
18
|
secrets-{{ data.id | replace('/', '-') | replace('.', '') | lower }}
|
|
16
19
|
{%- endset %}
|
|
@@ -76,3 +79,5 @@ Context:
|
|
|
76
79
|
</ul>
|
|
77
80
|
{% endblock list_style %}
|
|
78
81
|
{% endif %}
|
|
82
|
+
|
|
83
|
+
{% endif %}
|
|
File without changes
|
{mkdocstrings_github-0.2.6.dist-info → mkdocstrings_github-0.4.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|