Skip to content

Conversation

@oatsandsugar
Copy link
Contributor

@oatsandsugar oatsandsugar commented Oct 23, 2025

This pull request introduces a new system for dynamically generating and serving language-specific documentation (for Python and TypeScript) in the framework-docs app. The main changes include adding API endpoints for documentation generation, a robust file parser and builder, middleware and routing logic for clean URLs, and updates to Next.js rewrites.

Dynamic Documentation Generation and Serving

API Endpoints

  • Added new API routes api/llm/py and api/llm/ts that generate and serve plain text documentation for Python and TypeScript, respectively, based on a requested scope. These endpoints use a shared document builder and handle errors gracefully. [1] [2]

Documentation Builder

  • Introduced llmDocGenerator.ts, which recursively collects .mdx files, parses front matter, filters content by language tags, cleans up code blocks and markup, and assembles a structured documentation output. It supports scoping, generates a table of contents, and normalizes input paths.

Routing and Middleware Enhancements

Middleware for Clean URLs

  • Added a middleware to intercept requests for documentation files (e.g., /llm-py.txt, /some/scope/llm-ts.txt), extract language and scope, and rewrite them to the corresponding API endpoints, ensuring clean and flexible URLs for documentation consumers.

Next.js Rewrites

  • Updated Next.js configuration to include rewrites for all relevant documentation file patterns, mapping them to the new API endpoints and supporting scoped documentation queries. [1] [2]

Note

Adds dynamic Python/TypeScript doc aggregation via new /api/llm/* endpoints with clean URL handling through middleware and rewrites.

  • API:
    • Add GET /api/llm/py and GET /api/llm/ts to serve plain-text, language-specific docs with optional scope and caching headers.
  • Library:
    • Introduce src/lib/llmDocGenerator.ts to collect .mdx, parse front matter, filter content by language tags, clean markup, build TOC, and support scoped aggregation.
    • Add src/lib/llmHelpers.ts for safe query param decoding.
  • Routing/Middleware:
    • Add middleware.ts to match .../llm-{py|ts}.txt (with optional scope) and rewrite to corresponding API routes.
    • Update next.config.mjs rewrites to map /llm-*.txt and /:scope*/llm-*.txt to /api/llm/{ts|py} with scope.

Written by Cursor Bugbot for commit 9035248. This will update automatically on new commits. Configure here.

Package: apps/framework-docs

- add src/lib/llmDocGenerator.ts to walk the docs MDX tree, strip front matter/imports/JSX, and
keep only the selected <Python>/<TypeScript> sections plus headings
- serve new Next API routes /llm-py.txt and /llm-ts.txt that call the generator and return plain
text bundles with cache headers so LLM clients can fetch the full docs snapshot

Tests: pnpm --filter docs lint (fails: existing next lint CLI options are unsupported)

This tells the reviewer where the work lives, what the generator does, how the routes behave, and
why linting didn't complete.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Oct 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
framework-docs Ready Ready Preview Comment Oct 23, 2025 8:21pm

- Move llm-py.txt.ts and llm-ts.txt.ts to /api/llm/py.ts and /api/llm/ts.ts
- Update llmDocGenerator.ts with latest changes
- Update next.config.mjs configuration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a system for generating and serving language-specific (Python and TypeScript) documentation aggregates designed for LLM consumption. The implementation adds API endpoints that parse MDX files, filter content by language tags, and output plain text documentation with optional scoping support.

Key Changes:

  • Added API endpoints /api/llm/py and /api/llm/ts that generate language-filtered documentation from MDX files
  • Created a documentation generator that parses front matter, filters by language tags, strips JSX/exports, and builds table of contents
  • Implemented middleware and Next.js rewrites to map clean URLs (e.g., /llm-ts.txt, /scope/llm-py.txt) to the API endpoints

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/framework-docs/src/pages/api/llm/ts.ts TypeScript documentation API endpoint with scope extraction and error handling
apps/framework-docs/src/pages/api/llm/py.ts Python documentation API endpoint (identical structure to TypeScript endpoint)
apps/framework-docs/src/lib/llmDocGenerator.ts Core documentation generator with MDX parsing, language filtering, and content cleaning logic
apps/framework-docs/next.config.mjs Added rewrites to map /llm-*.txt URLs to corresponding API endpoints
apps/framework-docs/middleware.ts Request interceptor to parse LLM documentation URLs and rewrite to API endpoints

cursor[bot]

This comment was marked as outdated.

@oatsandsugar oatsandsugar added this pull request to the merge queue Oct 23, 2025
Merged via the queue into main with commit f182fc7 Oct 23, 2025
22 checks passed
@oatsandsugar oatsandsugar deleted the llm-docs branch October 23, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants