Skip to content

Commit bd426a4

Browse files
authored
Merge pull request #21 from mkdocstrings/issue-17-return-types
#17 Show return types
2 parents 14d0fca + 6ef364a commit bd426a4

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

Diff for: examples/example1/docs/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
::: src/foo.bas
66
handler: vba
7+
options:
8+
heading_level: 3
79

810
## `bar/baz.bas`
911

1012
::: src/bar/baz.bas
1113
handler: vba
14+
options:
15+
heading_level: 3

Diff for: examples/example1/src/foo.bas

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Function fuzz_HotelEcho_helper( _
2121
' Name: The name
2222
' description: The description
2323
'
24+
' Returns:
25+
' A fancy ListObject
26+
'
2427
' Examples:
2528
' >>> fuzz_HotelEcho_helper(sheet, "foo", "the sheet")
2629
' ListObject(...)

Diff for: mkdocstrings_handlers/vba/_handler.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,10 @@ def render(
154154
)
155155

156156
return template.render(
157-
**{
158-
"config": final_config,
159-
"module": data,
160-
"heading_level": heading_level,
161-
"root": True,
162-
},
157+
config=final_config,
158+
module=data,
159+
heading_level=heading_level,
160+
root=True,
163161
)
164162

165163
def update_env(self, md: Markdown, config: Dict[Any, Any]) -> None:
@@ -177,23 +175,19 @@ def get_anchors(self, data: VbaModuleInfo) -> Tuple[str, ...]:
177175

178176
def get_handler(
179177
*,
180-
theme: str,
178+
theme: str = "material",
181179
custom_templates: str | None = None,
182180
config_file_path: str | None = None,
183-
paths: list[str] | None = None,
184-
locale: str = "en",
185-
**config: Any,
181+
**kwargs: Any,
186182
) -> VbaHandler:
187183
"""
188-
Simply return an instance of `VbaHandler`.
184+
Get a new `VbaHandler`.
189185
190186
Arguments:
191187
theme: The theme to use when rendering contents.
192188
custom_templates: Directory containing custom templates.
193189
config_file_path: The MkDocs configuration file path.
194-
paths: A list of paths to use as Griffe search paths.
195-
locale: The locale to use when rendering content.
196-
**config: Configuration passed to the handler.
190+
kwargs: Extra keyword arguments that we don't use.
197191
198192
Returns:
199193
An instance of `VbaHandler`.

Diff for: mkdocstrings_handlers/vba/_util.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def find_procedures(code: str) -> Generator[VbaProcedureInfo, None, None]:
162162

163163
docstring_value = "\n".join(uncomment_lines(docstring_lines))
164164

165-
# See https://mkdocstrings.github.io/griffe/usage/#using-griffe-as-a-docstring-parsing-library
165+
# See https://mkdocstrings.github.io/griffe/guide/users/how-to/parse-docstrings/
166166
docstring = Docstring(
167167
value=docstring_value,
168168
parser=Parser.google,
@@ -180,6 +180,7 @@ def find_procedures(code: str) -> Generator[VbaProcedureInfo, None, None]:
180180
for arg in procedure["signature"].args
181181
)
182182
),
183+
returns=procedure["signature"].return_type,
183184
),
184185
)
185186

Diff for: mkdocstrings_handlers/vba/templates/material/_base/procedure.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
toc_label=procedure.signature.name ~ "()") %}
1414

1515
{% if config.separate_signature %}
16-
{{ procedure.signature.name }}()
16+
{{ procedure.signature.visibility }} {{ procedure.signature.procedure_type }} {{ procedure.signature.name }}()
1717
{% else %}
1818
{% filter highlight(language="vba", inline=True) %}
19-
{{ procedure.signature.name }}
19+
{{ procedure.signature.visibility }} {{ procedure.signature.procedure_type }} {{ procedure.signature.name }}
2020
{% include "signature.html" with context %}
2121
{% endfilter %}
2222
{% endif %}

Diff for: test/test_examples.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
22
from contextlib import contextmanager
3+
from logging import WARNING
34
from pathlib import Path
45
from tempfile import TemporaryDirectory
56
from typing import Generator
@@ -29,9 +30,10 @@ def tmp_build(config_file_path: Path) -> Generator[Path, None, None]:
2930

3031
class TestExamples(unittest.TestCase):
3132
def test_example1(self) -> None:
32-
with tmp_build(examples_dir.joinpath("example1", "mkdocs.yml")) as tmp_dir:
33-
# TODO: Write assertions. For now, just check that it does not fail.
34-
pass
33+
with self.assertNoLogs(level=WARNING):
34+
with tmp_build(examples_dir.joinpath("example1", "mkdocs.yml")) as tmp_dir:
35+
# TODO: Write assertions. For now, just check that it does not fail.
36+
pass
3537

3638

3739
if __name__ == "__main__":

Diff for: test/util/test_parse_signature.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,20 @@ def test_1(self) -> None:
5757
),
5858
),
5959
(
60-
"Function Test(Optional d As Variant = Empty)",
60+
"Public Property Get asdf() As String",
61+
VbaSignatureInfo(
62+
visibility="Public",
63+
return_type="String",
64+
procedure_type="Property Get",
65+
name="asdf",
66+
args=[],
67+
),
68+
),
69+
(
70+
"Function Test(Optional d As Variant = Empty) As String",
6171
VbaSignatureInfo(
6272
visibility=None,
63-
return_type=None,
73+
return_type="String",
6474
procedure_type="Function",
6575
name="Test",
6676
args=[

0 commit comments

Comments
 (0)