Skip to content

Commit

Permalink
fix doc generate bug when class is defined in another class (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
wzh1994 authored Nov 14, 2024
1 parent 124ea47 commit 69b8ba4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/scripts/lazynote/editor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, gen_docstring: Callable[[Optional[str], str], str], pattern:
self.pattern = pattern
self.module = module
self.module_dict = self.create_module_dict(module)
self.current_class: Optional[str] = None
self.current_class: Optional[str] = ''

def create_module_dict(self, module: Any) -> Dict[str, Any]:
"""
Expand Down Expand Up @@ -89,7 +89,7 @@ def visit_ClassDef(self, node: cst.ClassDef) -> None:
Args:
node (cst.ClassDef): The ClassDef node.
"""
self.current_class = node.name.value
self.current_class = f'{self.current_class}.{node.name.value}'.lstrip('.')

def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef:
"""
Expand All @@ -102,7 +102,7 @@ def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef
Returns:
cst.ClassDef: The updated ClassDef node with a new docstring.
"""
self.current_class = None
self.current_class = self.current_class[:(lambda x: 0 if x < 0 else x)(self.current_class.rfind('.'))]
obj = self._get_obj_by_name(original_node.name.value)
docstring = obj.__doc__ if obj else None
return self._update_node_with_new_docstring(original_node, updated_node, docstring)
Expand Down

0 comments on commit 69b8ba4

Please sign in to comment.