@@ -90,26 +90,24 @@ def test_add_str_to_type_other_type(self) -> None:
9090 def test_enhance_docstring_for_references (self ) -> None :
9191 """Test docstring enhancement for referenceable functions."""
9292 original = "Original docstring."
93- param_info = {
94- "data" : {"original" : "dict" , "modified" : "dict | str" , "accepts_str" : False },
95- "text" : {"original" : "str" , "modified" : "str" , "accepts_str" : True },
96- }
9793
98- result = _enhance_docstring_for_references (original , param_info , "test_func" )
94+ result = _enhance_docstring_for_references (original , "test_func" )
9995
10096 assert "Original docstring." in result
101- assert "**Reference Support**" in result
10297 assert "All parameters accept object references" in result
103- assert "``data``: dict → dict | str" in result
104- assert "``text``: str (already accepts strings)" in result
10598 assert "test_func(data='@obj_123'" in result
99+ # Should not contain the old reference support formatting
100+ assert "**Reference Support**" not in result
101+ assert "dict → dict | str" not in result
106102
107103 def test_enhance_docstring_for_references_empty_original (self ) -> None :
108104 """Test docstring enhancement with empty original docstring."""
109- result = _enhance_docstring_for_references ("" , {}, "test_func" )
105+ result = _enhance_docstring_for_references ("" , "test_func" )
110106
111- assert "test_func function with reference support." in result
112- assert "**Reference Support**" in result
107+ assert "test_func function." in result
108+ assert "All parameters accept object references" in result
109+ # Should not contain the old reference support formatting
110+ assert "**Reference Support**" not in result
113111
114112 def test_enhance_docstring_for_explorable (self ) -> None :
115113 """Test docstring enhancement for explorable functions."""
@@ -118,16 +116,69 @@ def test_enhance_docstring_for_explorable(self) -> None:
118116 result = _enhance_docstring_for_explorable (original , "test_func" )
119117
120118 assert "Original docstring." in result
121- assert "**Output Storage**" in result
122119 assert "automatically stored and can be referenced" in result
123120 assert "object ID (e.g., ``@obj_123``)" in result
121+ # Should not contain the old output storage formatting
122+ assert "**Output Storage**" not in result
124123
125124 def test_enhance_docstring_for_explorable_empty_original (self ) -> None :
126125 """Test docstring enhancement with empty original docstring."""
127126 result = _enhance_docstring_for_explorable ("" , "test_func" )
128127
129- assert "test_func function with stored output." in result
130- assert "**Output Storage**" in result
128+ assert "test_func function." in result
129+ assert "automatically stored and can be referenced" in result
130+ # Should not contain the old output storage formatting
131+ assert "**Output Storage**" not in result
132+
133+ def test_enhance_docstring_for_references_preserves_original (self ) -> None :
134+ """Test that _enhance_docstring_for_references preserves all original content."""
135+ original = """Process data and return results.
136+
137+ This function processes the input data and returns processed results.
138+ It may raise exceptions if the data is invalid.
139+
140+ :param data: Input data to process
141+ :param options: Processing options
142+ :return: Processed results
143+ :raises ValueError: If data is invalid
144+ :raises RuntimeError: If processing fails
145+ """
146+
147+ result = _enhance_docstring_for_references (original , "test_func" )
148+
149+ # Check that all original content is preserved exactly
150+ assert "Process data and return results." in result
151+ assert "This function processes the input data" in result
152+ assert ":param data: Input data to process" in result
153+ assert ":param options: Processing options" in result
154+ assert ":return: Processed results" in result
155+ assert ":raises ValueError: If data is invalid" in result
156+ assert ":raises RuntimeError: If processing fails" in result
157+
158+ # Check that enhancement is added
159+ assert "All parameters accept object references" in result
160+ assert "test_func(data='@obj_123'" in result
161+
162+ def test_enhance_docstring_for_explorable_preserves_original (self ) -> None :
163+ """Test that _enhance_docstring_for_explorable preserves all original content."""
164+ original = """Calculate statistics from data.
165+
166+ :param values: List of numbers
167+ :return: Statistical summary dict
168+ :raises ValueError: If values is empty
169+ """
170+
171+ result = _enhance_docstring_for_explorable (original , "calc_stats" )
172+
173+ # Check that all original content is preserved exactly
174+ assert "Calculate statistics from data." in result
175+ assert ":param values: List of numbers" in result
176+ assert ":return: Statistical summary dict" in result
177+ assert ":raises ValueError: If values is empty" in result
178+
179+ # Check that enhancement is added
180+ assert "automatically stored and can be referenced" in result
181+ assert "object ID (e.g., ``@obj_123``)" in result
131182
132183
133184class TestExplorableDecorator :
@@ -205,8 +256,9 @@ def test_func() -> dict:
205256 return {}
206257
207258 assert "Original docstring." in test_func .__doc__
208- assert "**Output Storage**" in test_func .__doc__
209259 assert "automatically stored" in test_func .__doc__
260+ # Should not contain the old output storage formatting
261+ assert "**Output Storage**" not in test_func .__doc__
210262
211263 def test_explorable_with_args (self , store : ObjectStore , explorer : RichExplorer ) -> None :
212264 """Test @explorable decorated function with arguments."""
@@ -390,8 +442,9 @@ def test_func(data: dict) -> str:
390442 return "result"
391443
392444 assert "Original docstring." in test_func .__doc__
393- assert "**Reference Support**" in test_func .__doc__
394445 assert "All parameters accept object references" in test_func .__doc__
446+ # Should not contain the old reference support formatting
447+ assert "**Reference Support**" not in test_func .__doc__
395448
396449
397450class TestExplorableAndReferenceableDecorator :
@@ -465,8 +518,11 @@ def test_func(data: dict) -> dict:
465518
466519 # Should contain both reference and explorable documentation
467520 assert "Original docstring." in docstring
468- assert "**Reference Support**" in docstring
469- assert "**Output Storage**" in docstring
521+ assert "All parameters accept object references" in docstring
522+ assert "automatically stored" in docstring
523+ # Should not contain the old section formatting
524+ assert "**Reference Support**" not in docstring
525+ assert "**Output Storage**" not in docstring
470526
471527 def test_combined_decorator_signature (self , store : ObjectStore , explorer : RichExplorer ) -> None :
472528 """Test that combined decorator modifies signature correctly."""
0 commit comments