|
| 1 | +# Weave Reference Generation Script Fixes |
| 2 | + |
| 3 | +This document summarizes the fixes applied to the Weave reference documentation generation scripts based on PR #1888 feedback. |
| 4 | + |
| 5 | +## Issues Fixed |
| 6 | + |
| 7 | +### 1. Models Reference Files Being Renamed (CRITICAL BUG) |
| 8 | +**Problem**: `fix_casing.py` was incorrectly targeting `models/ref/python/public-api` files instead of Weave reference docs. |
| 9 | + |
| 10 | +**Fix**: Updated `fix_casing.py` to only target `weave/reference/python-sdk` files. |
| 11 | +- Changed path from `models/ref/python/public-api` to `weave/reference/python-sdk` |
| 12 | +- Removed the logic that was renaming Models API files (ArtifactCollection, etc.) |
| 13 | +- Added clear comments indicating this should NEVER touch Models reference docs |
| 14 | + |
| 15 | +**Files Modified**: |
| 16 | +- `scripts/reference-generation/weave/fix_casing.py` |
| 17 | + |
| 18 | +### 2. TypeScript SDK Using PascalCase Filenames |
| 19 | +**Problem**: TypeScript SDK files were being generated with PascalCase filenames (e.g., `Dataset.mdx`, `WeaveClient.mdx`), which causes Git case-sensitivity issues. |
| 20 | + |
| 21 | +**Fix**: Updated generation scripts to use lowercase filenames throughout. |
| 22 | +- Modified `generate_typescript_sdk_docs.py` to convert filenames to lowercase when creating `.mdx` files |
| 23 | +- Updated function and type-alias extraction to use lowercase filenames |
| 24 | +- Updated internal links to use lowercase paths |
| 25 | + |
| 26 | +**Files Modified**: |
| 27 | +- `scripts/reference-generation/weave/generate_typescript_sdk_docs.py` (lines 259, 319-320, 369-370, 379) |
| 28 | +- `scripts/reference-generation/weave/fix_casing.py` (simplified to just convert to lowercase) |
| 29 | + |
| 30 | +### 3. H1 in service-api/index.mdx |
| 31 | +**Problem**: The generated `service-api/index.mdx` had both a frontmatter title and an H1, which is redundant in Mintlify. |
| 32 | + |
| 33 | +**Fix**: Removed the H1 heading since Mintlify uses the frontmatter title. |
| 34 | + |
| 35 | +**Files Modified**: |
| 36 | +- `scripts/reference-generation/weave/generate_service_api_spec.py` (line 31) |
| 37 | + |
| 38 | +### 4. Duplicate H3 Headings in service-api.mdx |
| 39 | +**Problem**: The `service-api.mdx` file had duplicate category sections (e.g., "### Calls" appeared on both line 23 and line 158), listing the same endpoints twice. |
| 40 | + |
| 41 | +**Fix**: Added deduplication logic to prevent duplicate categories and duplicate endpoints. |
| 42 | +- Track which categories have been written to prevent duplicate H3 headings |
| 43 | +- Deduplicate endpoints within each category by (method, path) tuple |
| 44 | +- This prevents the same endpoint from being listed multiple times if it appears in the OpenAPI spec with duplicate tags |
| 45 | + |
| 46 | +**Files Modified**: |
| 47 | +- `scripts/reference-generation/weave/update_service_api_landing.py` (lines 99-118) |
| 48 | + |
| 49 | +### 5. Markdown Table Formatting Errors (------ lines) |
| 50 | +**Problem**: Python SDK docs contained standalone lines with just dashes (`------`) which break markdown parsing. |
| 51 | + |
| 52 | +**Example**: In `trace_server_interface.mdx`, lines like 22, 30, 39, etc. had `------` that created invalid table structures. |
| 53 | + |
| 54 | +**Fix**: Added regex pattern to remove these malformed table separators. |
| 55 | +- Pattern: `\n\s*------+\s*\n` → `\n\n` |
| 56 | +- This removes lines that are just dashes with optional whitespace |
| 57 | + |
| 58 | +**Files Modified**: |
| 59 | +- `scripts/reference-generation/weave/generate_python_sdk_docs.py` (lines 258-260) |
| 60 | + |
| 61 | +## Testing Recommendation |
| 62 | + |
| 63 | +Before merging, test the fixes by running the reference generation locally: |
| 64 | + |
| 65 | +```bash |
| 66 | +# From the docs repository root |
| 67 | +cd scripts/reference-generation/weave |
| 68 | +python generate_weave_reference.py |
| 69 | +``` |
| 70 | + |
| 71 | +Then verify: |
| 72 | +1. No files in `models/ref/python/public-api` were modified |
| 73 | +2. All TypeScript SDK files in `weave/reference/typescript-sdk/` have lowercase filenames |
| 74 | +3. `weave/reference/service-api/index.mdx` has no H1 heading |
| 75 | +4. `weave/reference/service-api.mdx` has no duplicate H3 category headings |
| 76 | +5. No `------` lines in `weave/reference/python-sdk/trace_server/trace_server_interface.mdx` |
| 77 | +6. In `docs.json`, modules under `weave/reference/python-sdk/trace/` are grouped as "Core" (not "Other") |
| 78 | +7. In `docs.json`, the Service API `openapi` configuration uses the local spec (not a GitHub URL) if sync_openapi_spec.py was run with `--use-local` |
| 79 | + |
| 80 | +### 6. Incorrect Section Grouping ("Core" → "Other") |
| 81 | +**Problem**: Python SDK modules in the `trace/` directory were being incorrectly grouped as "Other" instead of "Core" in docs.json navigation. |
| 82 | + |
| 83 | +**Root Cause**: The path checking logic in `update_weave_toc.py` was checking `if parts[0] == "weave"`, but paths are relative to `python-sdk/`, so `parts[0]` is actually the module subdirectory (`trace`, `trace_server`, etc.), not `weave`. |
| 84 | + |
| 85 | +**Fix**: Corrected the path checking logic to check the actual first path component. |
| 86 | +- Changed from checking `parts[0] == "weave"` then `parts[1] == "trace"` |
| 87 | +- To directly checking `parts[0] == "trace"`, `parts[0] == "trace_server"`, etc. |
| 88 | + |
| 89 | +**Files Modified**: |
| 90 | +- `scripts/reference-generation/weave/update_weave_toc.py` (lines 33-45) |
| 91 | + |
| 92 | +### 7. OpenAPI Configuration Being Overwritten |
| 93 | +**Problem**: `update_weave_toc.py` was unconditionally overwriting the OpenAPI spec configuration in docs.json to use a remote URL, ignoring the local spec that `sync_openapi_spec.py` downloads and configures. |
| 94 | + |
| 95 | +**Impact**: Even though `sync_openapi_spec.py` downloads the OpenAPI spec locally and can configure docs.json to use it, `update_weave_toc.py` would immediately overwrite it with a remote GitHub URL, defeating the purpose of the local spec. |
| 96 | + |
| 97 | +**Fix**: Removed the Service API OpenAPI configuration code from `update_weave_toc.py`. This script should only manage Python/TypeScript SDK navigation, not the OpenAPI spec source. |
| 98 | +- Deleted lines 209-224 that were setting `page["openapi"]` to remote URLs |
| 99 | +- Added comment noting that OpenAPI configuration is managed by `sync_openapi_spec.py` |
| 100 | + |
| 101 | +**Files Modified**: |
| 102 | +- `scripts/reference-generation/weave/update_weave_toc.py` (lines 206-207) |
| 103 | + |
| 104 | +### 8. Missing Root Module Documentation (CRITICAL - WEAVE PACKAGE REGRESSION) |
| 105 | +**Problem**: The generated `python-sdk.mdx` file is only 8 lines (just frontmatter), completely missing all the important API documentation for functions like `init()`, `publish()`, `ref()`, `get()`, etc. |
| 106 | + |
| 107 | +**Expected**: The current version (Weave 0.52.10) has 2074 lines documenting all the core Weave functions and classes. |
| 108 | + |
| 109 | +**Root Cause**: **This is a WEAVE PACKAGE REGRESSION, not a script bug.** |
| 110 | + |
| 111 | +Something changed in Weave between versions **0.52.10** (current docs) and **0.52.16** (PR version) that broke documentation generation for the root `weave` module. The generation scripts haven't changed, and lazydocs hasn't changed - so this is an upstream issue in the Weave package itself. |
| 112 | + |
| 113 | +Possible causes: |
| 114 | +1. Changes to `weave/__init__.py` that affect how the module exports its public API |
| 115 | +2. Module structure refactoring that lazydocs can't handle |
| 116 | +3. New import patterns or lazy loading that breaks introspection |
| 117 | + |
| 118 | +**Status**: **CRITICAL UPSTREAM BUG** - This makes the Python SDK documentation completely unusable for version 0.52.16. |
| 119 | + |
| 120 | +**Action Required**: Report this to the Weave team immediately: |
| 121 | +1. File an issue: https://github.com/wandb/weave/issues |
| 122 | +2. Include: "Documentation generation broken in 0.52.16 - root module exports not discoverable by lazydocs" |
| 123 | +3. Mention: "Works fine in 0.52.10, broken in 0.52.16" |
| 124 | +4. Tag: @dbrian57 or relevant Weave maintainers |
| 125 | + |
| 126 | +**Recommendation**: |
| 127 | +- **DO NOT MERGE PR #1888** - it will break Python SDK documentation |
| 128 | +- Either: Fix the Weave package and regenerate docs |
| 129 | +- Or: Stay on 0.52.10 documentation until the Weave package is fixed |
| 130 | + |
| 131 | +**Files to Investigate** (in Weave repo): |
| 132 | +- `weave/__init__.py` between versions 0.52.10 and 0.52.16 |
| 133 | +- Any structural changes to the weave package in that version range |
| 134 | + |
| 135 | +### 9. OpenAPI Spec Validation (New Feature) |
| 136 | +**Enhancement**: Added validation to detect issues in the OpenAPI spec itself, which can help identify upstream problems. |
| 137 | + |
| 138 | +**Features**: |
| 139 | +- Detects duplicate endpoint definitions (same method+path defined multiple times) |
| 140 | +- Identifies endpoints appearing in multiple categories/tags |
| 141 | +- Warns when critical issues like duplicate endpoints are found |
| 142 | +- Suggests reporting issues to the Weave team when spec problems are detected |
| 143 | + |
| 144 | +**Files Modified**: |
| 145 | +- `scripts/reference-generation/weave/sync_openapi_spec.py` (added `validate_spec()` function and integration in `main()`) |
| 146 | + |
| 147 | +This will help identify if duplicate H3s or other issues originate from the OpenAPI spec rather than our generation scripts. |
| 148 | + |
| 149 | +## Files Modified Summary |
| 150 | + |
| 151 | +1. `scripts/reference-generation/weave/fix_casing.py` |
| 152 | +2. `scripts/reference-generation/weave/generate_typescript_sdk_docs.py` |
| 153 | +3. `scripts/reference-generation/weave/generate_service_api_spec.py` |
| 154 | +4. `scripts/reference-generation/weave/update_service_api_landing.py` |
| 155 | +5. `scripts/reference-generation/weave/generate_python_sdk_docs.py` |
| 156 | +6. `scripts/reference-generation/weave/update_weave_toc.py` |
| 157 | +7. `scripts/reference-generation/weave/sync_openapi_spec.py` (new validation feature) |
| 158 | + |
| 159 | +All fixes are backward compatible and will take effect on the next reference documentation generation run. |
0 commit comments