mkdocstrings-github 0.7.1__py3-none-any.whl → 0.8.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocstrings-github
3
- Version: 0.7.1
3
+ Version: 0.8.0
4
4
  Summary: A GitHub Action handler for mkdocstrings
5
5
  Author-email: Mark Hu <watermarkhu@gmail.com>
6
6
  License: MIT
@@ -23,6 +23,7 @@ Classifier: Typing :: Typed
23
23
  Requires-Python: <3.15,>=3.10
24
24
  Requires-Dist: gitpython<4,>=3.1.45
25
25
  Requires-Dist: mkdocstrings<2,>=1
26
+ Requires-Dist: ruamel-yaml-clib<1,>=0.2.14
26
27
  Requires-Dist: ruamel-yaml<1,>=0.18.16
27
28
  Requires-Dist: typing-extensions>=4.0; python_version < '3.11'
28
29
  Description-Content-Type: text/markdown
@@ -1,18 +1,18 @@
1
1
  mkdocstrings_handlers/github/__init__.py,sha256=0WdFUIq4Xu2ZFtlZNIYCQSoqcx3Ot9Wv41_X_dwbFww,248
2
- mkdocstrings_handlers/github/config.py,sha256=G__jcRZkhltdwwh1YJWbx9xEdblF9mTc4_L1NEWE6Bw,7873
3
- mkdocstrings_handlers/github/handler.py,sha256=xRT_GEcbcko5sqtj3eLqsPW2cFsLY4xImw-_K-GhwLE,8966
2
+ mkdocstrings_handlers/github/config.py,sha256=iUgoIFoICXpIk7RPEGjLLTuLnG-BvcOknH1o2rsSvwA,8274
3
+ mkdocstrings_handlers/github/handler.py,sha256=mDmXhLrkNFGln9bDODnLN9UuZJXJsoNDkwjSiWQQU4o,9248
4
4
  mkdocstrings_handlers/github/objects.py,sha256=2gKgrkkyBem3a0MUpffAH5C5asLk8Dqgqf6ntZuTxCo,9317
5
5
  mkdocstrings_handlers/github/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- mkdocstrings_handlers/github/rendering.py,sha256=N92Gbm9Qi4I2EZC69JsEixO1AdHuf1du9isJNXG4vhQ,7192
6
+ mkdocstrings_handlers/github/rendering.py,sha256=Ef4WxnE6bqb20-QjGwKcvSXceebGGPtME1OiTFXLqM4,8408
7
7
  mkdocstrings_handlers/github/templates/material/_macros.html.jinja,sha256=1TNUgoOIxm-a1S7eiESrW1fYuzXOjrwFqXQSyA4tkkU,1576
8
- mkdocstrings_handlers/github/templates/material/action.html.jinja,sha256=C7S8I9bjnrEUahyDB7CkFxtakFrr53KE3t3uyczBPzc,2864
8
+ mkdocstrings_handlers/github/templates/material/action.html.jinja,sha256=unNZDj_E7MbjNvGY4FMq3aRFpYNp-LCnio6Cca4dgI4,3019
9
9
  mkdocstrings_handlers/github/templates/material/heading.html.jinja,sha256=wnvZpNED8Dhb935qnddeDExXN-MIUz8frRRfgq-A9VA,1396
10
10
  mkdocstrings_handlers/github/templates/material/inputs.html.jinja,sha256=UE8RmfMlF6np7CP-920CwgkbXIcKNgl9KgK1BJ588GM,3271
11
11
  mkdocstrings_handlers/github/templates/material/outputs.html.jinja,sha256=Z9QD1KSALLDS9VEyugWG1BHpLCHTKYEx4TEQkKIoC3M,2693
12
12
  mkdocstrings_handlers/github/templates/material/secrets.html.jinja,sha256=jQ_HaG2ivbZTH74pyV4BAFGQu5Vn03kA_vaEbTSABds,2839
13
13
  mkdocstrings_handlers/github/templates/material/style.css,sha256=Nfmds-xHtPJ_IzOv5svA7ih5talHDTiQryN_n0DGdZs,1553
14
- mkdocstrings_handlers/github/templates/material/workflow.html.jinja,sha256=VS3AqT0OgX6QPFCwN63tULM9tC4t6FGtOoVCixQGPl4,4543
15
- mkdocstrings_github-0.7.1.dist-info/METADATA,sha256=6_amp3l5Ca4j7xDcyPTV8x7LfkQwRcK-9xuVsUu6Pzc,4052
16
- mkdocstrings_github-0.7.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
- mkdocstrings_github-0.7.1.dist-info/licenses/LICENSE,sha256=5enZtJ4zSp0Ps3jTqFQ4kadcx62BhgTaDNPrXWb3g3E,1069
18
- mkdocstrings_github-0.7.1.dist-info/RECORD,,
14
+ mkdocstrings_handlers/github/templates/material/workflow.html.jinja,sha256=lTdssopSZVvEeenNIzD9zKYhLts7nk8kgWYaIuzPTrE,4698
15
+ mkdocstrings_github-0.8.0.dist-info/METADATA,sha256=xnzS9p-rgldre9eokEDG0rvIa458XeH7tC5-OsR0rRE,4095
16
+ mkdocstrings_github-0.8.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
17
+ mkdocstrings_github-0.8.0.dist-info/licenses/LICENSE,sha256=5enZtJ4zSp0Ps3jTqFQ4kadcx62BhgTaDNPrXWb3g3E,1069
18
+ mkdocstrings_github-0.8.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.28.0
2
+ Generator: hatchling 1.31.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -127,6 +127,21 @@ class GitHubOptions(BaseModel):
127
127
  description="The version string to use if [`signature_version`][mkdocstrings_handlers.github.config.GitHubOptions.signature_version] is set to `string`.",
128
128
  )
129
129
 
130
+ signature_prematter: str = Field(
131
+ default="",
132
+ description="Text to render before the signature code block.",
133
+ )
134
+
135
+ signature_indent: int = Field(
136
+ default=0,
137
+ description="Number of spaces to indent the signature by.",
138
+ )
139
+
140
+ signature_postmatter: str = Field(
141
+ default="",
142
+ description="Text to render after the signature code block.",
143
+ )
144
+
130
145
  # Parameter options
131
146
  show_inputs: bool = Field(
132
147
  default=True,
@@ -168,16 +168,18 @@ class GitHubHandler(BaseHandler):
168
168
  self.env.lstrip_blocks = True
169
169
  self.env.keep_trailing_newline = False
170
170
  self.env.filters["format_action_signature"] = rendering.format_action_signature
171
+ self.env.filters["indent_text"] = rendering.indent_text
172
+ self.env.filters["wrap_signature_block"] = rendering.wrap_signature_block
171
173
  self.env.filters["order_parameters"] = rendering.order_parameters
172
174
  self.env.filters["filter_parameters"] = rendering.filter_parameters
173
175
  self.env.filters["group_parameters"] = rendering.group_parameters
174
176
  self.env.filters["anchor_id"] = rendering.anchor_id
175
177
  self.env.filters["as_string"] = rendering.as_string
176
178
  self.env.filters["generate_mermaid_flowchart"] = rendering.generate_mermaid_flowchart
177
- self.env.globals["semver_tag"] = self.semver
178
- self.env.globals["major_tag"] = self.major
179
- self.env.globals["git_repo"] = self.repo
180
- self.env.globals["repository_name"] = self.get_repository_name()
179
+ self.env.globals["semver_tag"] = self.semver # ty: ignore[invalid-assignment]
180
+ self.env.globals["major_tag"] = self.major # ty: ignore[invalid-assignment]
181
+ self.env.globals["git_repo"] = self.repo # ty: ignore[invalid-assignment]
182
+ self.env.globals["repository_name"] = self.get_repository_name() # ty: ignore[invalid-assignment]
181
183
 
182
184
  def collect(self, identifier: str, options: GitHubOptions) -> Workflow | Action | None:
183
185
  working_tree_dir = self.repo.working_tree_dir
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ import textwrap
4
5
  from collections import OrderedDict
5
6
  from typing import TYPE_CHECKING, Sequence
6
7
 
@@ -41,6 +42,48 @@ def format_action_signature(context: Context, id: str, repo: str, options: GitHu
41
42
  return f"{name}@{version}"
42
43
 
43
44
 
45
+ def indent_text(text: str, indent: int) -> str:
46
+ """Indent every line of a block of text by a given number of spaces.
47
+
48
+ Args:
49
+ text: The text to indent.
50
+ indent: Number of spaces to indent by. Negative values are treated as 0.
51
+
52
+ Returns:
53
+ The indented text.
54
+ """
55
+ if indent <= 0:
56
+ return text
57
+ prefix = " " * indent
58
+ return "\n".join(prefix + line if line else line for line in text.split("\n"))
59
+
60
+
61
+ def wrap_signature_block(
62
+ body: str,
63
+ indent: int = 0,
64
+ prematter: str = "",
65
+ postmatter: str = "",
66
+ ) -> str:
67
+ """Wrap a signature body with optional indentation and surrounding matter.
68
+
69
+ Args:
70
+ body: The signature body.
71
+ indent: Number of spaces to indent the body by.
72
+ prematter: Text to render before the body.
73
+ postmatter: Text to render after the body.
74
+
75
+ Returns:
76
+ The formatted signature block.
77
+ """
78
+ body = textwrap.dedent(body)
79
+ body = indent_text(body, indent)
80
+ if prematter and not prematter.endswith("\n"):
81
+ prematter += "\n"
82
+ if postmatter and not postmatter.startswith("\n"):
83
+ postmatter = "\n" + postmatter
84
+ return f"{prematter}{body}{postmatter}"
85
+
86
+
44
87
  def group_parameters(
45
88
  parameters: Sequence[Input | Output | Secret],
46
89
  do_group: bool,
@@ -29,6 +29,7 @@ Context:
29
29
  {% with inputs = data.inputs | order_parameters(options.parameters_order) | filter_parameters(required=True) %}
30
30
  <div class="annotate">
31
31
  {% filter highlight(language="yaml", inline=False, linenums=False) %}
32
+ {% filter wrap_signature_block(options.signature_indent, options.signature_prematter, options.signature_postmatter) %}
32
33
  - uses: {{ signature }}
33
34
  {% if inputs|length > 0 %}
34
35
  with:
@@ -36,6 +37,7 @@ Context:
36
37
  {{ input.name }}: ({{ loop.index }})
37
38
  {% endfor %}
38
39
  {% endif %}
40
+ {% endfilter %}
39
41
  {% endfilter %}
40
42
  </div>
41
43
  <ol>
@@ -27,6 +27,7 @@ Context:
27
27
  {% with inputs = data.inputs | order_parameters(options.parameters_order) | filter_parameters(required=True), secrets = data.secrets | order_parameters(options.parameters_order) | filter_parameters(required=True) %}
28
28
  <div class="annotate">
29
29
  {% filter highlight(language="yaml", inline=False, linenums=False) %}
30
+ {% filter wrap_signature_block(options.signature_indent, options.signature_prematter, options.signature_postmatter) %}
30
31
  uses: {{ signature }}
31
32
  {% if options.signature_show_permissions and data.permissions|length > 0 %}
32
33
  {% if data.permission_read_all %}
@@ -54,6 +55,7 @@ Context:
54
55
  {% endfor %}
55
56
  {% endif %}
56
57
  {% endif %}
58
+ {% endfilter %}
57
59
  {% endfilter %}
58
60
  </div>
59
61
  <ol>