From 337472a33a2b1f5a799304f124ab13777133f3f5 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Thu, 8 Jan 2026 18:10:30 +0100 Subject: [PATCH] Postprocess HTML documentation in symbol overviews within the client, not the tool --- src/serena/tools/jetbrains_plugin_client.py | 5 +++++ src/serena/tools/jetbrains_tools.py | 19 +++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/serena/tools/jetbrains_plugin_client.py b/src/serena/tools/jetbrains_plugin_client.py index c014efca..a4cad01e 100644 --- a/src/serena/tools/jetbrains_plugin_client.py +++ b/src/serena/tools/jetbrains_plugin_client.py @@ -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( diff --git a/src/serena/tools/jetbrains_tools.py b/src/serena/tools/jetbrains_tools.py index c7d38c5f..1b7fc90a 100644 --- a/src/serena/tools/jetbrains_tools.py +++ b/src/serena/tools/jetbrains_tools.py @@ -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):