@@ -65,7 +65,7 @@ def render_function(self, item: ItemData) -> t.Iterable[str]:
6565
6666 # Add anchor for linking
6767 anchor_id = self ._generate_anchor_id (full_name )
68- yield f'<Anchor id="{ anchor_id } " / >'
68+ yield f'<Anchor id="{ anchor_id } ">'
6969 yield ""
7070
7171 # Function signature in code block (no header - code block IS the header)
@@ -99,6 +99,8 @@ def render_function(self, item: ItemData) -> t.Iterable[str]:
9999 formatted_code = self ._format_code_block_with_links (code_content , "python" )
100100 for line in formatted_code .split ("\n " ):
101101 yield line
102+
103+ yield "</Anchor>"
102104 yield ""
103105
104106 # Function docstring - use simple approach like MyST
@@ -110,7 +112,6 @@ def render_function(self, item: ItemData) -> t.Iterable[str]:
110112 processed_docstring = self ._convert_myst_directives (raw_docstring )
111113 escaped_docstring = self ._escape_fern_content (processed_docstring )
112114 yield escaped_docstring
113- yield ""
114115
115116 def render_module (self , item : ItemData ) -> t .Iterable [str ]:
116117 """Create the content for a module."""
@@ -251,8 +252,11 @@ def render_package(self, item: ItemData) -> t.Iterable[str]:
251252 yield "### Data"
252253 yield ""
253254 for child in children_by_type ["data" ]:
254- name = child ["full_name" ].split ("." )[- 1 ]
255- yield f"`{ name } `"
255+ full_name = child ["full_name" ]
256+ short_name = full_name .split ("." )[- 1 ]
257+ # Create anchor link to API section
258+ anchor_id = self ._generate_anchor_id (full_name )
259+ yield f"[`{ short_name } `](#{ anchor_id } )"
256260 yield ""
257261
258262 # API section with detailed documentation
@@ -278,7 +282,7 @@ def render_class(self, item: ItemData) -> t.Iterable[str]:
278282
279283 # Add anchor for linking
280284 anchor_id = self ._generate_anchor_id (full_name )
281- yield f'<Anchor id="{ anchor_id } " / >'
285+ yield f'<Anchor id="{ anchor_id } ">'
282286 yield ""
283287
284288 # Build class signature with constructor args
@@ -298,6 +302,8 @@ def render_class(self, item: ItemData) -> t.Iterable[str]:
298302 formatted_code = self ._format_code_block_with_links (code_content , "python" )
299303 for line in formatted_code .split ("\n " ):
300304 yield line
305+
306+ yield "</Anchor>"
301307 yield ""
302308
303309 # Class content (wrapped in HTML div for proper indentation)
@@ -424,7 +430,7 @@ def render_data(self, item: ItemData) -> t.Iterable[str]:
424430
425431 # Add anchor for linking
426432 anchor_id = self ._generate_anchor_id (full_name )
427- yield f'<Anchor id="{ anchor_id } " / >'
433+ yield f'<Anchor id="{ anchor_id } ">'
428434 yield ""
429435
430436 # Data signature in code block with enhanced formatting
@@ -436,6 +442,8 @@ def render_data(self, item: ItemData) -> t.Iterable[str]:
436442 formatted_code = self ._format_code_block_with_links (code_content , "python" )
437443 for line in formatted_code .split ("\n " ):
438444 yield line
445+
446+ yield "</Anchor>"
439447 yield ""
440448
441449 # Data content (wrapped in HTML div for proper indentation)
@@ -479,7 +487,6 @@ def render_data(self, item: ItemData) -> t.Iterable[str]:
479487 yield formatted_line
480488 else :
481489 yield ""
482- yield ""
483490
484491 def generate_summary (
485492 self , objects : list [ItemData ], alias : dict [str , str ] | None = None
@@ -750,12 +757,8 @@ def _format_code_block_with_links(self, code: str, language: str = "python") ->
750757 import re
751758
752759 word_pattern = r"\b" + re .escape (short_name ) + r"\b"
753- if re .search (word_pattern , code ) and item ["type" ] in (
754- "class" ,
755- "function" ,
756- "method" ,
757- ):
758- # Use the corrected page mapping logic
760+ if re .search (word_pattern , code ):
761+ # Link all documented items that appear in code
759762 page_name = self ._get_page_for_item (full_name )
760763 page_slug = self ._generate_slug (page_name )
761764 anchor_id = self ._generate_anchor_id (full_name )
0 commit comments