66
77Outputs:
88 llms.txt - Concise LLM overview (~4-6KB)
9- llms-full.txt - Comprehensive method reference (~200-300KB)
9+ llms-full.txt - Compact method reference
1010"""
1111
1212import inspect
@@ -84,7 +84,6 @@ def extract_docstring_info(method):
8484 # First non-empty line(s) before :param or https:// is the description
8585 desc_lines = []
8686 param_lines = []
87- rest_lines = []
8887 in_params = False
8988 in_rest = False
9089
@@ -102,7 +101,7 @@ def extract_docstring_info(method):
102101 in_rest = True
103102
104103 if in_rest :
105- rest_lines . append ( line )
104+ continue
106105 elif in_params :
107106 param_lines .append (line )
108107 elif stripped .startswith ("https://" ):
@@ -129,47 +128,7 @@ def extract_docstring_info(method):
129128 # Continuation line for multi-line param descriptions
130129 current_param ["desc" ] += " " + stripped
131130
132- # Extract response example from rest, converting RST to Markdown
133- response_text = "\n " .join (rest_lines )
134- # Convert RST code blocks to Markdown fences
135- response_text = re .sub (
136- r"\.\. code-block:: (\w+)" ,
137- r"```\1" ,
138- response_text ,
139- )
140- # Add closing fences: a code block ends when indentation returns to base level
141- # after a ```lang line
142- result_lines = []
143- in_code_block = False
144- for line in response_text .split ("\n " ):
145- stripped = line .strip ()
146- if stripped .startswith ("```" ) and not stripped == "```" :
147- in_code_block = True
148- result_lines .append (stripped )
149- elif in_code_block :
150- if stripped == "" and result_lines and result_lines [- 1 ] == "" :
151- # Skip double blank lines inside code blocks
152- continue
153- # RST code blocks are indented; unindented non-empty line ends the block
154- if stripped and not line .startswith (" " ) and not line .startswith ("\t " ):
155- result_lines .append ("```" )
156- result_lines .append ("" )
157- in_code_block = False
158- result_lines .append (line )
159- else :
160- # Remove one level of RST indentation (4 spaces), preserve inner indentation
161- if line .startswith (" " ):
162- line = line [4 :]
163- result_lines .append (line )
164- else :
165- result_lines .append (line )
166- if in_code_block :
167- result_lines .append ("```" )
168- response_text = "\n " .join (result_lines )
169- # Convert RST field markup to plain text
170- response_text = re .sub (r":returns:\s*" , "**Returns:** " , response_text )
171-
172- return description , params , response_text
131+ return description , params , ""
173132
174133
175134def generate_llms_txt (methods_by_category , total_count ):
@@ -426,7 +385,11 @@ async def main():
426385
427386
428387def generate_llms_full_txt (methods_by_category , total_count ):
429- """Generate the comprehensive llms-full.txt content."""
388+ """Generate a compact llms-full.txt method reference.
389+
390+ Uses a dense format: one heading + description + param list per method,
391+ no response examples. Keeps the file small enough to fit in LLM context.
392+ """
430393 lines = []
431394 lines .append ("# python-binance — Full Method Reference" )
432395 lines .append ("" )
@@ -445,51 +408,30 @@ def generate_llms_full_txt(methods_by_category, total_count):
445408 lines .append (f"- [{ cat } ](#{ anchor } ) ({ count } methods)" )
446409 lines .append ("" )
447410
448- # Method details by category
411+ # Method details by category — compact format
449412 for cat in sorted (methods_by_category .keys ()):
450413 lines .append (f"## { cat } " )
451414 lines .append ("" )
452415
453416 for name , method in methods_by_category [cat ]:
454417 sig_str = get_signature_str (method )
455- description , params , response_text = extract_docstring_info (method )
418+ description , params , _ = extract_docstring_info (method )
456419
420+ # Method heading with signature
457421 lines .append (f"### `client.{ name } ({ sig_str } )`" )
458- lines .append ("" )
459422 if description :
460- lines .append (description )
461- lines .append ("" )
423+ lines .append (f"> { description } " )
462424
463425 if params :
464- lines .append ("**Parameters:**" )
465426 for p in params :
466- type_str = f" ({ p ['type' ]} )" if p ["type" ] else ""
467- desc_str = f" — { p ['desc' ]} " if p ["desc" ] else ""
427+ type_str = f": { p ['type' ]} " if p ["type" ] else ""
428+ # Truncate long descriptions to keep file compact
429+ desc = p ["desc" ]
430+ if len (desc ) > 80 :
431+ desc = desc [:77 ] + "..."
432+ desc_str = f" — { desc } " if desc else ""
468433 lines .append (f"- `{ p ['name' ]} `{ type_str } { desc_str } " )
469- lines .append ("" )
470-
471- # Include response examples if present (trimmed)
472- if response_text .strip ():
473- # Extract just the returns and response example, skip raises
474- resp_lines = response_text .strip ().split ("\n " )
475- filtered = []
476- skip = False
477- for rl in resp_lines :
478- if rl .strip ().startswith (":raises:" ):
479- skip = True
480- continue
481- if not skip :
482- filtered .append (rl )
483- if skip and rl .strip () and not rl .strip ().startswith (":" ):
484- skip = False
485- filtered .append (rl )
486-
487- resp_text = "\n " .join (filtered ).strip ()
488- if resp_text :
489- lines .append (resp_text )
490- lines .append ("" )
491-
492- lines .append ("---" )
434+
493435 lines .append ("" )
494436
495437 return "\n " .join (lines )
0 commit comments