@@ -51,13 +51,17 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: WPS2
5151 The collected object-tree.
5252 """
5353 final_config = ChainMap (config , self .default_config )
54+ parser_name = final_config ["docstring_style" ]
55+ parser_options = final_config ["docstring_options" ]
5456
57+ just_loaded = False
5558 module_name = identifier .split ("." , 1 )[0 ]
5659 if module_name not in self ._modules_collection :
60+ just_loaded = True
5761 loader = GriffeLoader (
5862 extensions = load_extensions (final_config .get ("extensions" , [])),
59- docstring_parser = Parser (final_config [ "docstring_style" ] ),
60- docstring_options = final_config [ "docstring_options" ] ,
63+ docstring_parser = Parser (parser_name ),
64+ docstring_options = parser_options ,
6165 modules_collection = self ._modules_collection ,
6266 lines_collection = self ._lines_collection ,
6367 )
@@ -71,6 +75,12 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: WPS2
7175 logger .warning (f"{ len (unresolved )} aliases were still unresolved after { iterations } iterations" )
7276
7377 try :
74- return self ._modules_collection [identifier ]
78+ doc_object = self ._modules_collection [identifier ]
7579 except KeyError as error : # noqa: WPS440
7680 raise CollectionError (f"{ identifier } could not be found" ) from error
81+
82+ if not just_loaded and doc_object .docstring is not None :
83+ doc_object .docstring .parser = parser_name and Parser (parser_name )
84+ doc_object .docstring .parser_options = parser_options
85+
86+ return doc_object
0 commit comments