Class: DocsKit::LlmsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- DocsKit::LlmsController
- Defined in:
- app/controllers/docs_kit/llms_controller.rb
Overview
Serves the two AI-readable artifacts (llmstxt.org) from the registry, with zero authoring — the host app wires the routes (the engine is glue-only, no routes of its own), so a site keeps full control over path, auth, and omission:
# config/routes.rb
get "/llms.txt" => "docs_kit/llms#index"
get "/llms-full.txt" => "docs_kit/llms#full"
#index → the llms.txt index (brand, tagline, nav-grouped links to each page's
.md twin). #full → llms-full.txt (every page's Markdown concatenated). Both
are text/plain and HTTP-cached: the response revalidates on the registry's
own content plus DocsKit::VERSION, so a page/gem change busts the cache while
an unchanged registry serves a 304.
All the text shaping lives in DocsKit::LlmsText (pure, Rails-free). This controller only threads the Rails view context: #full renders each page to Markdown via DocsKit::MarkdownExport (which needs url helpers/CSRF), then hands the [title, markdown] pairs to LlmsText.full.
Instance Method Summary collapse
Instance Method Details
#full ⇒ Object
37 38 39 40 41 42 43 |
# File 'app/controllers/docs_kit/llms_controller.rb', line 37 def full pairs = DocsKit::LlmsText.pages(docs_config).map do |page| [page.title, render_page_markdown(page)] end body = DocsKit::LlmsText.full(docs_config, pairs) render_text(body) if stale_llms?(body) end |