Skip to content

All reference/functions/*.md files are empty except ta.md #3

@nanobeep

Description

@nanobeep

First, thanks for this great project! Noticed this issue and had Gemini do a quick fix for me and here's the details of the issue and resolution. Hope it helps!

From Gemini:

Title: 🐛 Bug: Most files in reference/functions/ are empty

Description:
I noticed that while reference/functions/ta.md is populated correctly, the other documentation files in the reference/functions/ directory (specifically collections.md, drawing.md, request.md, strategy.md, and general.md) are currently empty or contain only newlines.

This breaks the intended usage for LLM context retrieval, as queries regarding strategies or drawings return no reference material.

Current Behavior:

  • reference/functions/ta.md: Populated
  • reference/functions/strategy.md: Empty
  • reference/functions/drawing.md: Empty
  • reference/functions/collections.md: Empty
  • reference/functions/request.md: Empty

Suggested Fix:
It appears the build step responsible for chunking pinescriptv6reference.md into the smaller files failed or was skipped.

I wrote a Python script that correctly parses the master pinescriptv6reference.md file and distributes the functions into the categories defined in your README. You can drop this script into the root of the repo and run it to regenerate the files.

fix_reference_docs.py

import os

def main():
    source_file = "pinescriptv6reference.md"
    output_dir = "reference/functions"
    
    # Mapping prefixes/namespaces to specific files
    categories = {
        "collections.md": ["array", "matrix", "map"],
        "drawing.md": ["box", "line", "label", "polyline", "table", "linefill", 
                       "plot", "bgcolor", "fill", "hline", "barcolor"],
        "request.md": ["request"],
        "strategy.md": ["strategy"],
        "ta.md": ["ta"]
    }
    
    # Ensure output directory exists
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
        
    # Initialize content buffers
    buffers = {
        "collections.md": [],
        "drawing.md": [],
        "request.md": [],
        "strategy.md": [],
        "ta.md": [],
        "general.md": []
    }
    
    current_category = None
    
    with open(source_file, "r", encoding="utf-8") as f:
        lines = f.readlines()
        
    in_functions = False
    
    for line in lines:
        # Detect start of Functions section
        if line.strip() == "# Functions":
            in_functions = True
            continue
        
        # Detect end of Functions section (Keywords starts)
        if line.strip() == "# Keywords":
            break
            
        if not in_functions:
            continue
            
        # Detect new function definition
        if line.startswith("## "):
            func_name = line.strip()[3:].split('(')[0] # Remove '## ' and parameters
            func_name = func_name.split('<')[0] # Remove generic type like array.new<type>
            
            # Default to general
            found_cat = "general.md"
            
            # Check namespaces/prefixes
            for cat, prefixes in categories.items():
                for prefix in prefixes:
                    if func_name == prefix or func_name.startswith(prefix + "."):
                        found_cat = cat
                        break
                if found_cat != "general.md":
                    break
            
            current_category = found_cat
            
        if current_category:
            buffers[current_category].append(line)

    # Write buffers to files
    for filename, content in buffers.items():
        path = os.path.join(output_dir, filename)
        print(f"Writing {len(content)} lines to {path}")
        with open(path, "w", encoding="utf-8") as f:
            f.writelines(content)

if __name__ == "__main__":
    main()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions