npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

crates-llms-txt

v0.1.1

Published

A repository for generating content for llms.txt and llms-full.txt files used by Rust libraries.

Downloads

94

Readme

crates-llms-txt

npm version npm downloads License

This library provides a standard interface to fetch and parse Rust crate documentation and session data for use with LLMs (Large Language Models).

Features

  • Generate metadata for llms.txtllms-full.txt files
  • Parse Rust crate documentation into standardized formats
  • Support both online (docs.rs) and local crate documentation
  • Enable custom feature selection for local documentation generation
  • Cross-platform support with prebuilt binaries

Installation

npm install crates-llms-txt

Usage Examples

Basic Usage - Fetch by Crate Name

import { fromCrateName } from 'crates-llms-txt'

async function main() {
  // Fetch latest version
  const config = await fromCrateName('clap')

  // Fetch specific version
  const specificConfig = await fromCrateName('clap', '4.5.39')

  if (config) {
    console.log(`Fetched docs for ${config.libName} v${config.version}`)
    console.log(`Found ${config.sessions.length} documentation sections`)
  }
}

main()

Advanced Usage - Local Documentation Generation

import { fromLocal, fromLocalWithFeatures } from 'crates-llms-txt'

// Generate docs with all features
const allFeaturesConfig = fromLocal('./Cargo.toml', 'stable')

// Generate docs with specific features
const customConfig = fromLocalWithFeatures(
  './Cargo.toml',
  true, // no default features
  ['async', 'serde'], // specific features
  'nightly', // toolchain
)

API Reference

Online Documentation Functions

fromCrateName(libName: string, version?: string): Promise<LLMsConfig | null>

Fetches Rust crate documentation from docs.rs by crate name and version.

  • libName: string: The name of the crate as it appears on crates.io (e.g., "clap", "serde", "tokio")
  • version?: string: Optional version string. If not provided, the latest version will be fetched
  • Returns: Promise<LLMsConfig | null> - Documentation configuration or null if failed

fromUrl(url: string): Promise<LLMsConfig | null>

Fetches documentation from a direct URL to the JSON documentation.

  • url: string: Direct URL to the crate's JSON documentation (e.g., "https://docs.rs/crate/clap/latest/json")
  • Returns: Promise<LLMsConfig | null> - Documentation configuration or null if failed

fromOnline(params: LLMsConfigByCrate | LLMsConfigByUrl): Promise<LLMsConfig | null>

Unified function for fetching documentation from online sources.

  • params: Either { libName: string, version?: string } or { url: string }
  • Returns: Promise<LLMsConfig | null> - Documentation configuration or null if failed

Local Documentation Functions

fromLocal(manifestPath: string, toolchain?: string): LLMsConfig | null

Generates documentation for a local crate with all features enabled.

  • manifestPath: string: Path to the Cargo.toml file
  • toolchain?: string: Optional Rust toolchain (e.g., "stable", "nightly")
  • Returns: LLMsConfig | null - Documentation configuration or null if failed

fromLocalWithFeatures(manifestPath: string, noDefaultFeatures: boolean, features?: string[], toolchain?: string): LLMsConfig | null

Generates documentation with fine-grained feature control.

  • manifestPath: string: Path to the Cargo.toml file
  • noDefaultFeatures: boolean: Whether to disable default features
  • features?: string[]: Optional array of features to enable
  • toolchain?: string: Optional Rust toolchain
  • Returns: LLMsConfig | null - Documentation configuration or null if failed

fromLocalByRustdoc(params: LLMsConfigRustdocByAllFeatures | LLMsConfigRustdocByFeatures): LLMsConfig | null

Unified function for local documentation generation with flexible configuration.

  • params: Either all-features config or specific-features config
  • Returns: LLMsConfig | null - Documentation configuration or null if failed

TypeScript Types

interface SessionItem {
  title: string
  description: string
  link: string
}

interface FullSessionItem {
  content: string
  link: string
}

interface LLMsConfig {
  libName: string
  version: string
  sessions: SessionItem[]
  fullSessions: FullSessionItem[]
}

interface LLMsConfigByCrate {
  libName: string
  version?: string
}

interface LLMsConfigByUrl {
  url: string
}

interface LLMsConfigRustdocByAllFeatures {
  toolchain?: string
  manifestPath: string
}

interface LLMsConfigRustdocByFeatures {
  toolchain?: string
  manifestPath: string
  noDefaultFeatures: boolean
  features?: string[]
}

Supported Architectures

The crates-llms-txt package provides prebuilt binaries for the following target architectures:

| Target Triple | | ------------------------------- | | x86_64-apple-darwin | | aarch64-apple-darwin | | x86_64-pc-windows-msvc | | aarch64-pc-windows-msvc | | i686-pc-windows-msvc | | x86_64-unknown-linux-gnu | | x86_64-unknown-linux-musl | | aarch64-unknown-linux-gnu | | aarch64-unknown-linux-musl | | armv7-unknown-linux-gnueabihf |