Postprocess HTML documentation in symbol overviews within the client, not the tool

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-01-08 18:10:30 +01:00
1 parent 01d0f26164
commit 337472a33a
2 files changed
+14 -10

No files matched your search

@@ -258,6 +258,11 @@ class JetBrainsPluginClient(ToStringMixin):
request_data = {"relativePath": relative_path, "depth": depth, "includeFileDocumentation": include_file_documentation}
response = cast(jb.GetSymbolsOverviewResponse, self._make_request("POST", "/getSymbolsOverview", request_data))
self._postprocess_symbol_collection_response(response)
# process file documentation
if "documentation" in response:
response["documentation"] = render_html(response["documentation"])
return response
def get_supertypes(
+9 -10
View File
@@ -3,7 +3,6 @@ from collections import defaultdict
from typing import Any, Literal
import serena.tools.jetbrains_types as jb
from serena.text_utils import render_html
from serena.tools import Tool, ToolMarkerOptional, ToolMarkerSymbolicRead
from serena.tools.jetbrains_plugin_client import JetBrainsPluginClient
@@ -117,7 +116,7 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp
"""
@staticmethod
def _transform_symbols_to_compact_format(symbols: list[dict[str, Any]]) -> dict[str, list]:
def _transform_symbols_to_compact_format(symbols: list[jb.SymbolDTO]) -> dict[str, list]:
"""
Transform symbol overview from verbose format to compact grouped format.
@@ -143,7 +142,7 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp
result[kind].append({name: children_dict})
else:
# Symbol has no children: just add the name
result[kind].append(name)
result[kind].append(name) # type: ignore
return result
@@ -167,14 +166,14 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp
:return: a JSON object containing the symbols grouped by kind in a compact format.
"""
with JetBrainsPluginClient.from_project(self.project) as client:
response_dict = client.get_symbols_overview(relative_path=relative_path, depth=depth)
documentation = response_dict.pop("documentation", None)
symbol_overview = client.get_symbols_overview(relative_path=relative_path, depth=depth, include_file_documentation=False)
symbols = symbol_overview["symbols"]
result: dict[str, Any] = {"symbols": self._transform_symbols_to_compact_format(symbols)}
documentation = symbol_overview.pop("documentation", None)
if documentation:
response_dict["docstring"] = render_html(documentation) # type: ignore
symbols = response_dict["symbols"]
response_dict["symbols"] = self._transform_symbols_to_compact_format(symbols) # type: ignore
result = self._to_json(response_dict)
return self._limit_length(result, max_answer_chars)
result["docstring"] = documentation
json_result = self._to_json(result)
return self._limit_length(json_result, max_answer_chars)
class JetBrainsTypeHierarchyTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOptional):