Scenario 03: Documentation Generation

Scenario 03: Documentation Generation

Technical writer generating API documentation from code.

Quick Start

# Select Documentation Scenario
/select 03

Generating Function Documentation

> Generate documentation for heap_insert

╭─────────────── API Documentation ─────────────────────────╮
│                                                           │
│  ## heap_insert                                           │
│                                                           │
│  Inserts a tuple into a heap relation.                    │
│                                                           │
│  ### Signature                                            │
│                                                           │
│  ```c                                                     │
│  void heap_insert(Relation relation,                      │
│                   HeapTuple tup,                          │
│                   CommandId cid,                          │
│                   int options,                            │
│                   BulkInsertState bistate)                │
│  ```                                                      │
│                                                           │
│  ### Parameters                                           │
│                                                           │
│  | Parameter | Type | Description |                      │
│  |-----------|------|-------------|                      │
│  | relation | Relation | Target heap relation |          │
│  | tup | HeapTuple | Tuple to insert |                   │
│  | cid | CommandId | Command ID for MVCC |               │
│                                                           │
│  ### Example                                              │
│                                                           │
│  ```c                                                     │
│  HeapTuple tuple = heap_form_tuple(desc, values, nulls);  │
│  heap_insert(rel, tuple, GetCurrentCommandId(true),       │
│              0, NULL);                                    │
│  ```                                                      │
│                                                           │
│  ### See Also                                             │
│  - heap_update() - Update existing tuple                  │
│  - heap_delete() - Delete tuple                           │
│                                                           │
╰───────────────────────────────────────────────────────────╯

Module Architecture Documentation

> Explain the executor module architecture

╭─────────────── Architecture ──────────────────────────────╮
                                                           
  Executor Module Architecture                             
  ═══════════════════════════                              
                                                           
  Purpose: Execute query plans generated by the planner    
                                                           
  Directory: src/backend/executor/                         
                                                           
  Core Components:                                         
                                                           
  1. execMain.c - Main executor entry points               
     - ExecutorStart(): Initialize execution state         
     - ExecutorRun(): Main execution loop                  
     - ExecutorEnd(): Cleanup and shutdown                 
                                                           
  2. execProcnode.c - Node dispatcher                      
     - ExecProcNode(): Route to specific node types        
                                                           
  Data Flow:                                               
  Plan Tree  PlanState Tree  Tuple Output                
                                                           
╰───────────────────────────────────────────────────────────╯

Function Reference Lists

> List all public functions in executor module

╭─────────────── Function Reference ────────────────────────╮
│                                                           │
│  Executor Public Functions                                │
│                                                           │
│  Entry Points:                                            │
│  ExecutorStart()      Initialize execution                │
│  ExecutorRun()        Execute plan                        │
│  ExecutorFinish()     Post-execution processing           │
│  ExecutorEnd()        Cleanup                             │
│                                                           │
│  Node Operations:                                         │
│  ExecProcNode()       Execute single node                 │
│  ExecInitNode()       Initialize node                     │
│  ExecEndNode()        Cleanup node                        │
│                                                           │
│  Total: 156 public functions                              │
│                                                           │
╰───────────────────────────────────────────────────────────╯

Example Questions

  • “Generate documentation for [function_name]”
  • “Explain the [module_name] architecture”
  • “Document the SPI interface functions”
  • “List all public functions in [module]”
  • “What are the main components of [subsystem]?”