Automating Code Sample Updates with LLMs for Technical Documentation

wix · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Technical documentation maintenance

Wix needed to update thousands of Velo API reference code samples after a syntax change without stopping the technical writing team's normal work.

Constraints:

Architecture

Wix built a docs-as-code migration pipeline. A mapping step found source files for API reference samples. GPT-4 classified which samples needed rewriting, and GPT-3.5 Turbo converted affected samples to the new webMethod syntax. A TypeScript compiler-based validator checked whether converted samples used Velo APIs correctly. Writers reviewed validation errors, fixed edge cases, and a final script applied conversions back to source repositories and opened PRs.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  sample-mapping-script[Sample mapping script] --> classification-script[Classification script]
  classification-script --> conversion-script[Conversion script]
  conversion-script --> typescript-validator[TypeScript validator]
  typescript-validator --> writer-error-review[Writer error review]
  writer-error-review --> replacement-script[Replacement script]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Sample mapping script Maps API reference code samples to source files across repositories. Classification script
Classification script Uses GPT-4 to flag samples that need the new web-method syntax. Sample mapping script, Conversion script
Conversion script Uses GPT-3.5 Turbo and a conversion prompt to rewrite affected samples. Classification script, TypeScript validator
TypeScript validator Compiles converted samples against Velo API type definitions. Conversion script, Writer error review
Writer error review Reviews validation errors and fixes conversion or type-definition issues. TypeScript validator, Replacement script
Replacement script Applies accepted conversions to source repositories and produces PRs. Writer error review

Data flow

The workflow collects code samples and source mappings, classifies each sample with GPT-4, converts selected samples with GPT-3.5 Turbo, stores rewritten files beside originals for comparison, validates converted samples with TypeScript compilation and Velo type definitions, routes validation errors to writers, and applies accepted conversions back to source repositories.

4 supporting quotes
“The script also created a mapping file to correlate the location of the sample files in our repo and the source repo.”article, stated
“Classify: Another script used GPT to identify which code samples required rewriting for the new syntax. We used the prompt detailed above.”article, stated
“Convert and validate: Next, a script sent each file that required rewriting to GPT with our conversion prompt.”article, stated
“The script also used our validator to see if the new code would compile. We saved any validation errors in a log file together with original and converted code samples.”article, stated

Why this architecture

Wix split the job into classification, conversion, validation, and replacement because the affected samples could not be found with a simple script, and converted code could not be published without compilation checks. Using GPT-4 for classification and GPT-3.5 Turbo for conversion reflects task-specific model choice: classification needed robust semantic filtering, while conversion worked best with the cheaper/faster model they tested.

3 supporting quotes
“We decided to use an LLM to classify our code samples and figure out which ones we needed to convert. The probabilistic nature of LLMs meant that some percentage of the classifications would almost certainly be wrong.”article, stated
“After some experimentation we found that GPT-3.5 turbo produced the best results out of the models we had available at the time.”article, stated
“We couldn’t publish bad code in the reference. So in this case we needed to minimize the amount of errors from the LLM output”article, stated

Models used: GPT-4 · GPT-3.5 Turbo

Scale

Alternatives considered (roads not taken)

Manually update every affected sample

Rejected because: Manual work would have consumed large writing-team effort and halted normal velocity.

“Updating the reference manually would have required an enormous amount of tech writer work. Our team decided to try something new and automate this process using AI.”article, stated
“Manually locating, classifying, and rewriting each code sample would have taken a huge amount of work and brought our whole team’s general velocity to a halt.”article, stated

Script pattern detection without an LLM

Rejected because: Wix had no programmatic way to identify affected samples because formats and repositories varied.

“We had no programmatic way of knowing which specific samples we needed to change. * The style guide for writing Velo code samples evolved over several years.”article, stated
“The fact that the code samples were in different and unpredictable formats meant that we couldn’t easily script a way to convert the code from the old syntax to the new one.”article, stated

Publish converted samples without compiling

Rejected because: LLM output could be wrong, and bad code could not ship in reference docs.

“Converting the code samples with AI meant that a certain percentage of the conversions might be wrong. We couldn’t publish bad code in the reference.”article, stated
“By compiling each converted code sample, we could at least confirm that the new code was valid JavaScript and used the Velo APIs correctly.”article, stated

Patterns

model-routing (architecture)

Wix used GPT-4 for classification and GPT-3.5 Turbo for conversion after testing task fit.

“We chose the GPT-4 model and tested the prompt using a set of code samples.”article, stated
“GPT-3.5 turbo produced the best results out of the models we had available at the time.”article, stated

eval-driven-development (evaluation)

TypeScript compilation validated converted samples before publication.

“uses them to compile code samples using the TypeScript compiler.”article, stated

batch-offline-processing (operations)

Scripts classified, converted, validated, and replaced thousands of documentation samples in batch.

“To implement our plan, we created a new repo to host our scripts and the code sample files to collect and convert.”article, stated

human-in-the-loop-gate (workflow)

Writers reviewed validation errors before converted samples were merged back into source repositories.

“We divided the validation among a team of writers.”article, stated

prompt-versioning (prompting)

Wix used explicit system prompts and examples for both classification and conversion.

“We used this prompt as the system message. The user message was only the code sample to classify.”article, stated
“Then I will give you some examples of old code examples and how they look now.”article, stated

Tradeoffs

Use LLM classification despite probabilistic errors

Chose GPT-4 classifier tested on a sample set over manual discovery or brittle scripts.

Rationale: The team judged LLM classification acceptable because there was no easy deterministic identifier and the prompt failed only a small number of tests.

“The probabilistic nature of LLMs meant that some percentage of the classifications would almost certainly be wrong.”article, stated
“It failed only a small number of times.”article, stated

Validate converted code with TypeScript

Chose compiler-backed validation over trusting the conversion prompt.

Rationale: Compilation provided a deterministic check that converted samples remained valid JavaScript using Velo APIs correctly.

“By compiling each converted code sample, we could at least confirm that the new code was valid JavaScript and used the Velo APIs correctly.”article, stated

Use GPT-3.5 Turbo for conversion

Chose GPT-3.5 Turbo over other available models.

Rationale: Wix found it produced the best conversion results in their experiments.

“GPT-3.5 turbo produced the best results out of the models we had available at the time.”article, stated

Gotchas (what bit them)

The affected samples could not be identified by simple syntax search.

Root cause: Only some samples included web-method exports, formats varied, and source files were spread across repos.

Resolution: Wix used an LLM classifier to flag samples requiring conversion.

“The syntax change only affected code samples that demonstrated exporting and importing web methods.”article, stated
“We decided to use an LLM to classify our code samples and figure out which ones we needed to convert.”article, stated

LLM conversions could fail for non-semantic reasons.

Root cause: The model sometimes hit return-token limits, and type definitions could be out of sync.

Resolution: The pipeline logged validation errors for manual review.

“The only errors we encountered were cut-offs where the LLM hit the return token limit before completing the sample.”article, stated
“the samples failed to compile because the type definitions were out of sync with the underlying APIs.”article, stated

Converted documentation code must preserve unaffected code.

Root cause: The syntax change only required specific import/export transformations.

Resolution: The prompt explicitly instructed the model to change only the required elements.

“To convert a code example, only the above elements need to be changed. Everything else should be left exactly as it is.”article, stated

Evaluation

Wix evaluated classification prompt performance on a testing data set and validated converted code with TypeScript compilation plus manual review of validation errors.

Metrics: classification test failures · compile validation errors · manual validation workload · writer time saved

3 supporting quotes
“we could write a prompt that performed well on a testing data set.”article, stated
“The script also compiled a master list of all the converted samples that returned errors.”article, stated
“we never saw a single example of the LLM failing to convert the code properly.”article, stated

Outcomes

The migration covered a reference with more than 2,000 code samples and reduced manual effort to a small writer review pass.

3 supporting quotes
“we were able to limit team involvement to 6 writers who worked on the project for one morning.”article, stated
“After that, it was just a matter of merging PRs and publishing the docs.”article, stated
“saving many hours of tech writer work.”article, stated