Generating llms.txt

Generate llms.txt, companion llms-*.txt files, and docs_tree metadata from pkg/skill.py and the single site reading order.

ship-docs builds llms.txt and llms-*.txt companion files directly into _docs/ without importing the target package, while ship-export persists the same reading order into pkg/_modidx.py for installed doc(). Run ship-llms to print llms.txt to stdout or write it with --out. Page order matches the site sidebar (sidebar-links or discovered page order), with optional llms-exclude and llms-extra overrides in ship.toml or [tool.fastship].

ship-llms
ship-llms --out _docs/llms.txt --base-url https://example.com/docs/

Resolving project doc trees

Extract (title, description, order, has_body) from .ipynb, .qmd, .md, and .py files and derive the LLM catalog from the single site reading order.

doc_meta

def doc_meta(
    path:str | pathlib._local.Path, # Path to `.ipynb`, `.qmd`, `.md`, or `.py`
)->tuple[str, str, float, bool]: # `(title, desc, order, has_body)`

Extract (title, desc, order, has_body) from frontmatter, notebook headers, or Python docstrings.

docs_tree

def docs_tree(
    root:str | pathlib._local.Path, # Project or site root directory
    docs_dir:str | pathlib._local.Path=None, # Content directory (`ship/`, `nbs/`, `docs/`, or `.`)
    *, mod_urls:dict=None, # Optional `{module: rel_url}` map
    url_fn:<built-in function callable>=None, # Maps HTML dest path to published Markdown URL (defaults to `.md`)
    pages:list=None, # Optional pre-discovered `Page` objects (skips rescanning `docs_dir`)
    sidebar_links:list=None, # Optional explicit reading order overriding site config
    llms_exclude:list | set=None, # Optional section/path names excluded from `llms.txt`
    llms_extra:dict=None, # Optional `{section: [mod | [title, href[, desc]], ...]}` entries appended to `llms.txt`
    settings:dict=None, # Optional site settings dict passed to `resolve_nav`
)->dict:

Resolve project docs into {section: items | {desc?, items?, Sub: ...}} from the single site reading order.

Building llms.txt

Parse skill.py via AST, render llms.txt and llms-*.txt companion files into _docs/, and persist docs into pkg/_modidx.py.

parse_skill

def parse_skill(
    path:str | pathlib._local.Path, # Path to a `skill.py` file
)->fastcore.basics.AttrDict: # `AttrDict(summary, body, docs, base_url)`

Parse skill.py's docstring and literal __docs__ / __base_url__ via AST without importing it.

pkg_llms

def pkg_llms(
    path:str | pathlib._local.Path, # Package directory containing `skill.py`
    base_url:str='', # Published docs base URL (normalized to end with `/`)
    mod_urls:dict=None, # Optional `{module_name: rel_url}` for modules with web doc pages
    docs:dict=None, # Resolved project docs catalog (used as final when passed; else falls back to `skill.py` + autodiscovery)
    summary:str='', # Fallback summary when `skill.py` is absent
    body:str='', # Fallback body (e.g. exported index markdown) when `skill.py` is absent
)->tuple[str, dict[str, str]]: # `(llms_txt, {companion_filename: content})`

Build llms.txt and pure-docstring companion files from path/skill.py (or summary/body fallback) without importing it.

project_llms

def project_llms(
    root:str | pathlib._local.Path=None, # Project root directory (defaults to current project)
    data:dict=None, # Optional parsed `pyproject.toml` mapping
    base_url:str=None, # Override published docs base URL
    ship_path:str | pathlib._local.Path=None, # Optional content directory override (defaults to `cfg.ship_path`)
    *, pkg_path:str | pathlib._local.Path=None, # Optional package directory override
    pages:list=None, # Optional pre-built `Page` list
    mod_urls:dict=None, # Optional pre-computed `{module: rel_url}` map
    ship:dict=None, # Optional parsed fastship settings dict
)->tuple[dict[str, str], dict | None]: # `({filename: content}, docs_for_modidx)`

Build the project's llms.txt and llms-*.txt files in memory from the single page list.

sync_pkg_docs

def sync_pkg_docs(
    root:str | pathlib._local.Path=None, # Project root directory (defaults to current project)
    data:dict=None, # Optional parsed `pyproject.toml` mapping
    ship_path:str | pathlib._local.Path=None, # Optional content directory override (defaults to `cfg.ship_path`)
)->pathlib._local.Path | None: # Path to `pkg/_modidx.py` when updated, else `None`

Persist the project's resolved docs catalog into pkg/_modidx.py for installed doc().

llms_cli

def llms_cli(
    path:str=None, # Project directory (defaults to current project)
    out:str=None, # Output file or directory to write `llms.txt` and companions (prints `llms.txt` to stdout when omitted)
    base_url:str=None, # Override published docs base URL
)->None:

Print or write generated llms.txt (and companion files with --out) for a project.