Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docstring_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def parse_jsdoc(docstring: str) -> Dict[str, Any]:
as description, parameters, return values, exceptions, examples, and other
tags. It handles the removal of opening and closing markers, splits the content
into lines, and categorizes each line based on whether it is part of a tag or
the main description.
the main description. The function also manages the parsing of individual tags
and their corresponding content.

Args:
docstring (str): The JSDoc string to parse.
Expand Down Expand Up @@ -93,7 +94,8 @@ def _process_tag(tag: str, content: List[str], result: Dict[str, Any]) -> None:

The function processes different types of JSDoc tags such as `param`,
`returns`, `throws`, `example`, and others, updating the provided result
dictionary accordingly.
dictionary accordingly. It handles nested parameters, optional parameters with
default values, and various other tag formats.

Args:
tag (str): The tag name (without the @ symbol).
Expand Down
13 changes: 8 additions & 5 deletions docstring_parser/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ def extract_type_info(type_str: str) -> Dict[str, Any]:

This function parses the input type string to determine if it represents a
union of types, a generic/template type with parameters, or a simple type. It
returns a dictionary containing the parsed type information.
returns a dictionary containing the parsed type information. The function
checks for union types by looking for the '|' character, identifies
generics/templates using regular expressions, and handles nested generics by
managing bracket levels.

Args:
type_str (str): The type string from a JSDoc tag.
Expand Down Expand Up @@ -63,9 +66,9 @@ def extract_type_info(type_str: str) -> Dict[str, Any]:


def merge_jsdoc_objects(base: Dict[str, Any], overlay: Dict[str, Any]) -> Dict[str, Any]:
"""Merge two JSDoc objects, with the overlay taking precedence.
"""Merge two JSDoc objects with the overlay taking precedence.

The function merges two dictionaries representing JSDoc objects. If a key
This function merges two dictionaries representing JSDoc objects. If a key
exists in both the base and overlay, the value from the overlay takes
precedence. For keys like 'params' and 'throws', it combines the lists while
ensuring that items with matching names are updated rather than duplicated.
Expand Down Expand Up @@ -133,8 +136,8 @@ def remove_jsdoc_component(jsdoc_obj: Dict[str, Any], component_type: str, ident
"""Remove a specified component from a JSDoc object.

This function modifies the provided JSDoc object by removing a component based
on the given type and identifier. If no identifier is provided, it removes all
instances of the component type. The function handles various component types
on the given type and identifier. If no identifier is provided, it removes all
instances of the component type. The function handles various component types
such as 'description', 'param', 'returns', 'throws', 'example', and 'tag'.

Args:
Expand Down