fern-docs-generation

A guide to automatically generating connector documentation from Python source code. It reads the code's structure using AST, a way to examine code as a tree, and produces MDX documentation files.

In plain words
What is it for?
Use it to discover connector files, read their names, authentication settings, and categories, and generate documentation for them.
Why use it?
It keeps documentation tied to connector definitions and reduces the need to write and update each page by hand.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/airweave-ai/airweave/fern-docs-generation
Clone the repo
git clone --depth 1 https://github.com/airweave-ai/airweave

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 971 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00971
Opus 5 $0.00000 $0.00485
Sonnet 5 $0.00000 $0.00194
Haiku 4.5 $0.00000 $0.00097

Measured yesterday against content hash 724aaa970ffb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

fern-docs-generation scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/fern-docs-generation.mdc · 128 lines

How it starts

The opening of the file, as written. The whole thing — 128 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Fern Documentation Generation System - Internal Guide

Overview

The custom internal Fern documentation generator automatically creates MDX documentation for Airweave connectors by introspecting Python source code using AST (Abstract Syntax Tree) parsing.

Architecture Flow

1. Discovery Phase

Entry: update_connector_docs/__main__.py:main()

  • Scans backend/airweave/platform/sources/ directory
  • Identifies all .py files as potential connectors
  • Example: asana.py, slack.py, google_drive.py

2. Parsing Phase

Source Parser (source_parser.py)

Extracts metadata from @source decorator:

@source(
    name="Asana",                    # Display name
    short_name="asana",              # File/URL identifier
    auth_methods=[...],              # Auth methods list
    oauth_type=OAuthType.WITH_REFRESH,  # OAuth type enum
    auth_config_class="AsanaConfig", # String reference to config
    config_class="AsanaConfig",      # Source-specific config
    labels=["Project Management"]    # Categories
)

AST Extraction Process:

  1. Parse decorator arguments positionally and by keyword
  2. Fall back to class attributes (_auth_type, _config_class)
  3. Last resort: regex pattern matching in raw source
Entity Parser (entity_parser.py)
  • Scans platform/entities/{connector_name}.py
  • Extracts entity classes and their field definitions
  • Builds entity hierarchy for documentation
Auth/Config Parsers
  • auth_parser.py: Maps auth config class names to their field definitions
  • config_parser.py: Maps source config classes to their field requirements

3. Generation Phase

MDX Generator (mdx_generator.py)

Creates structured MDX with:

  • Header: Icon + connector name
  • Configuration: Source docstring description
  • Authentication:
    • OAuth flows (managed vs BYOC)
    • Direct auth field requirements
  • Source Config: Additional configuration fields
  • Entity Schema: Data structure documentation

Read the full file on GitHub · 128 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 128 lines · 971 tokens per session scan A 724aaa970ffb

Subscribe to this mod's changes

fern-docs-generation is a cursor rule published in the GitHub repository airweave-ai/airweave (6,567 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 971 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.