@@ -223,7 +223,9 @@ def convert_to_mintlify_format(docs_dir):
223223 # 2. Fix links to README/index to point to landing page
224224 content = re .sub (r'\]\(\.\./README' , '](../' , content )
225225 content = re .sub (r'\]\(\.\./index' , '](../' , content )
226- content = re .sub (r'\]\(README' , '](typescript-sdk' , content )
226+ # Don't convert self-referential README anchor links - they'll be fixed later in extract_members_to_separate_files()
227+ # Only convert non-anchor README links
228+ content = re .sub (r'\]\(README\)' , '](typescript-sdk)' , content )
227229
228230 # 3. Fix all TypeDoc-generated links to lowercase
229231 # Paths that already have directory structure (../classes/, ../interfaces/, etc.)
@@ -249,6 +251,25 @@ def convert_to_mintlify_format(docs_dir):
249251 content = re .sub (r'\]\(\.\./interfaces/([^)#]+)(#[^)]+)?\)' , lambda m : f'](./typescript-sdk/interfaces/{ m .group (1 ).lower ()} { m .group (2 ) or "" } )' , content )
250252 content = re .sub (r'\]\(\.\./functions/([^)#]+)(#[^)]+)?\)' , lambda m : f'](./typescript-sdk/functions/{ m .group (1 ).lower ()} { m .group (2 ) or "" } )' , content )
251253 content = re .sub (r'\]\(\.\./type-aliases/([^)#]+)(#[^)]+)?\)' , lambda m : f'](./typescript-sdk/type-aliases/{ m .group (1 ).lower ()} { m .group (2 ) or "" } )' , content )
254+
255+ # Fix self-referential anchor links like (README#anchor) that appear in Table of Contents
256+ # We'll scan the content to determine if each anchor refers to a function or type alias
257+ # First, extract all type alias names (they have the Ƭ symbol)
258+ type_alias_names = set ()
259+ type_alias_matches = re .findall (r'###\s+([A-Za-z][A-Za-z0-9]*)\n\nƬ' , content )
260+ for name in type_alias_matches :
261+ type_alias_names .add (name .lower ())
262+
263+ # Now convert README anchor links to proper paths based on whether they're type aliases or functions
264+ def fix_readme_anchor (match ):
265+ anchor = match .group (1 ).lower ()
266+ if anchor in type_alias_names :
267+ return f'](./typescript-sdk/type-aliases/{ anchor } )'
268+ else :
269+ # Assume it's a function if not a type alias
270+ return f'](./typescript-sdk/functions/{ anchor } )'
271+
272+ content = re .sub (r'\]\(README#([a-zA-Z][a-zA-Z0-9-]*)\)' , fix_readme_anchor , content )
252273
253274 # Special handling for index files (README.md)
254275 # These files are at the root level and link directly to subdirectories
@@ -298,9 +319,10 @@ def extract_members_to_separate_files(docs_path):
298319 functions_dir .mkdir (exist_ok = True )
299320
300321 # Find and extract each function section
301- # Pattern to match function sections (from ### functionName to the next ### or end)
322+ # Pattern to match function sections (from ### functionName followed by ▸ symbol to the next ### or end)
323+ # The ▸ symbol (U+25B8) is used by TypeDoc to mark function signatures
302324 function_pattern = re .compile (
303- r'(### (init|login|op|requireCurrentCallStackEntry|requireCurrentChildSummary|weaveAudio|weaveImage|wrapOpenAI )\n.*?)(?=\n### |\Z)' ,
325+ r'(### ([a-zA-Z][a-zA-Z0-9]* )\n\n▸ .*?)(?=\n### |\Z)' ,
304326 re .DOTALL
305327 )
306328
@@ -445,12 +467,19 @@ def organize_for_mintlify(temp_output, final_output):
445467 else :
446468 shutil .copy2 (item , dest )
447469
448- # Move README.mdx to typescript-sdk.mdx landing page if it exists
449- readme_path = final_path / "README.mdx"
470+ # Move readme.mdx to typescript-sdk.mdx landing page if it exists
471+ # Check for both uppercase and lowercase versions (case sensitivity)
472+ readme_path = final_path / "readme.mdx"
473+ readme_path_upper = final_path / "README.mdx"
474+
450475 if readme_path .exists ():
451476 landing_path = final_path .parent / "typescript-sdk.mdx"
452477 readme_path .rename (landing_path )
453- print (" ✓ Created typescript-sdk.mdx landing page from README" )
478+ print (" ✓ Created typescript-sdk.mdx landing page from readme.mdx" )
479+ elif readme_path_upper .exists ():
480+ landing_path = final_path .parent / "typescript-sdk.mdx"
481+ readme_path_upper .rename (landing_path )
482+ print (" ✓ Created typescript-sdk.mdx landing page from README.mdx" )
454483
455484 # Extract functions and type aliases to separate files if they're consolidated
456485 extract_members_to_separate_files (final_path )
0 commit comments