Pkg.go.dev to LLM.txt Formatter

Extracts Go package documentation (API definitions, examples) from pkg.go.dev and converts it into a structured LLM.txt format, suitable for local AI/LLM reference and analysis.

نووسەر
hellowor
Daily installs
0
Total installs
0
Ratings
0 0 0
وەشان
0.1.1
Created
2025-06-07
Updated
2025-06-07
Size
22.5 KB
مۆڵەت
MIT
Applies to

This UserScript is designed to assist Go developers and AI enthusiasts by transforming Go package documentation pages on pkg.go.dev into a structured, plain text format (LLM.txt). This format is optimized for ingestion by local Large Language Models (LLMs), facilitating offline search, analysis, and reference of Go package APIs and examples.

The script intelligently extracts key information including:

  • Package Overview: The main description of the package.
  • Examples: Code examples provided within the documentation, including their titles and any associated output.
  • Constants & Variables: Definitions and descriptions of package-level constants and variables.
  • Functions: Signatures, descriptions, and associated examples for package-level functions.
  • Types: Definitions for structs, interfaces, etc., along with their descriptions and examples.
  • Constructors & Methods: For each type, its associated constructor functions and methods are extracted, including their signatures, descriptions, and examples.

The output LLM.txt file uses Markdown-like formatting (e.g., ## for headings, ```go for code blocks) to maintain readability and structure, making it easier for LLMs to parse and understand the context of different documentation sections.

How to Use

  1. Installation:

    • Ensure you have a UserScript manager extension installed in your browser (e.g., Tampermonkey, Greasemonkey, Violentmonkey).
    • Install this script by navigating to its download URL (e.g., from Greasy Fork) and clicking the "Install" button, or by manually adding the script code to your UserScript manager.
  2. Navigate to a Go Package Page:

  3. Locate and Click the Download Button:

    • Once the page has loaded, you will see a "Download llm.txt" button appear in the bottom-right corner of the screen.
    • Click this button.
  4. Extraction and Download:

    • The script will wait for a brief moment (approximately 1 second) to allow the dynamic content on the page (especially code examples) to fully load.
    • It will then process the page content, extract the documentation, and format it.
    • A file named [package_name]_llm.txt (e.g., fmt_llm.txt or github.com_go-rod_rod_lib_launcher_llm.txt) will be automatically downloaded to your browser's default download location.
  5. Using the .txt File:

    • You can now use this .txt file as a reference document for your local LLM. Import it into your LLM's knowledge base or use it as context for your queries.