Skip to content

Commit f526816

Browse files
committed
fix: Allow passing null as docstring style
Issue #2: #2
1 parent a65f6b1 commit f526816

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/mkdocstrings_handlers/python/collector.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: WPS2
5252
final_config = ChainMap(config, self.default_config)
5353
parser_name = final_config["docstring_style"]
5454
parser_options = final_config["docstring_options"]
55+
parser = parser_name and Parser(parser_name)
5556

5657
just_loaded = False
5758
module_name = identifier.split(".", 1)[0]
5859
if module_name not in self._modules_collection:
5960
just_loaded = True
6061
loader = GriffeLoader(
6162
extensions=load_extensions(final_config.get("extensions", [])),
62-
docstring_parser=Parser(parser_name),
63+
docstring_parser=parser,
6364
docstring_options=parser_options,
6465
modules_collection=self._modules_collection,
6566
lines_collection=self._lines_collection,
@@ -79,7 +80,7 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: WPS2
7980
raise CollectionError(f"{identifier} could not be found") from error
8081

8182
if not just_loaded and doc_object.docstring is not None:
82-
doc_object.docstring.parser = parser_name and Parser(parser_name)
83+
doc_object.docstring.parser = parser
8384
doc_object.docstring.parser_options = parser_options
8485

8586
return doc_object

tests/test_collector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ def test_collect_module():
2323
"""Assert existing module can be collected."""
2424
collector = PythonCollector()
2525
assert collector.collect("mkdocstrings", {})
26+
27+
28+
def test_collect_with_null_parser():
29+
"""Assert we can pass `None` as parser when collecting."""
30+
collector = PythonCollector()
31+
assert collector.collect("mkdocstrings", {"docstring_style": None})

0 commit comments

Comments
 (0)