# ReDoT: Week 2
> with your hosts Connor, Sefi & Jason
---
## <!-- Connor --> A Quick Tour of ReDoT
---
### Example code to generate docs

---
### Docs auto-generated to code

---
### Docs auto-generated for README.md

---
## <!-- Connor --> Workflow to trigger action
```yml=
name: Documentation Update
on:
pull_request: # runs automatically on any PR
types: [opened, synchronize, reopened]
jobs:
update-docs:
runs-on: ubuntu-latest
permissions:
contents: write # so your action can push commits if needed
steps:
- uses: actions/checkout@v4
- name: Run ReDoT Action
uses: fac-31/ReDoT@v1.0.3
with:
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull: ${{ github.event.pull_request.number }}
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
```
---
## <!-- Connor --> action.yml to accept the trigger
```yml=
name: "ReDoT"
description: "Auto-generate and update documentation using AI (Claude) for pull requests"
author: "Sefi Potashnik, Connor Rowland, Jason Warren"
branding:
icon: "book-open"
color: "blue"
inputs:
owner:
description: "Owner of the repository"
required: true
repo:
description: "Repository name"
required: true
pull:
description: "Pull request number"
required: true
anthropic_api_key:
description: "Anthropic API key for Claude AI"
required: true
github_token:
description: "GitHub token (defaults to github.token if not provided)"
required: false
default: ${{ github.token }}
runs:
using: "node20"
main: "dist/index.js"
```
---
## <!-- Connor --> Running the code with inputs
```ts
import * as core from '@actions/core';
async function run() {
try {
// Get inputs from action.yml
const input_owner = core.getInput("owner", { required: true });
const input_repo = core.getInput("repo", { required: true });
const input_pull = core.getInput("pull", { required: true });
const anthropic_api_key = core.getInput("anthropic_api_key", { required: true });
if (!anthropic_api_key) {
core.setFailed("Anthropic API key not provided.");
process.exit(1);
}
// Get GitHub token from input or fall back to the default GITHUB_TOKEN
const github_token: string = core.getInput('github_token') || process.env.GITHUB_TOKEN || '';
if (!github_token) {
core.setFailed("GitHub token not provided. Please pass github_token input or ensure GITHUB_TOKEN is available.");
process.exit(1);
}
...
```
---
## <!-- Sefi --> Logic!
---
### LogikC!!!
![CleanShot 2025-10-06 [Monday] at 5 .02.58 Dia@2x](https://hackmd.io/_uploads/ByxOFv-6xe.jpg)
---
### lOgIc!!!!
![CleanShot 2025-10-06 [Monday] at 5 .02.58 Dia@2x copy](https://hackmd.io/_uploads/Hye_tD-pxg.jpg)
---
## <!-- Sefi --> A Function
> sorry sefi i didn't know what to write for the header
strcuture to capture the document updates: function change
```js
interface FunctionChange {
filename: string;
functionName: string;
startLine: number;
endLine: number;
changes: string[];
existingDoc?: string;
functionCode: string;
}
```
---
## <!-- Jason --> Learning a Different Ecosystem
> or "i was wrong and sefi was right"
`Putting LangChain in a GitHub Action is Not a Good Use of Your Time`
sometimes the hard complicated code is easier than the easy well-known code because
---
## <!-- Jason --> Christopher Nolan's Codeception
> ~~All nouns are arbitrary concepts created by humans in a vain attempt to exert some form of control over the uncaring void~~
Handling overlapping concepts when building a meta-project is conceptually difficult.
`Repo? Tool? Action? None of them? All of them! Sometimes.`
---
WE WILL NOT BE TAKING QUESTIONS AT THIS TIME

> The repo stores the github action but it is not the github action it is the repo that we use to test the github action even though it contains the github action
---
## <!-- Jason --> RITFIN CLABO
> ~~fine jaz you were right~~
XML is an Ideal Way to Structure Complex Prompts

---
## <!-- Jason --> Custom Commands
> aka Doing a Massive Amount of Work So You Can Avoid Doing a Small Amount of Work

---

---

---

---
## THE END
> Don't know where to put this but I feel compelled to say that Connor smiled at me earlier and said "your branch protection rules don't work" as he merrily force-pushed to `main`
---
## Notes
---
### Diagram
```mermaid
sequenceDiagram
participant reDoT
participant GitHub
participant AnthropicAPI
reDoT->>GitHub: Fetch PR details (GET)
GitHub-->>reDoT: prData (headBranch, baseBranch, headRepo, headOwner)
reDoT->>GitHub: Fetch PR file changes (GET)
GitHub-->>reDoT: file names
loop For each file in file names
reDoT->>GitHub: Get file content from head branch
GitHub-->>reDoT: file contents
reDoT->>reDoT: Identify changed functions
loop For each affected function
reDoT->>AnthropicAPI: Prompt for results
AnthropicAPI-->>reDoT: Update: functionName, line, inline documentation, existingDoc
end
loop For each affected file
reDoT->>GitHub: Get affected file
GitHub-->>reDoT: File contents
reDoT->>reDoT: Apply changes to file
reDoT->>GitHub: Create new commit
GitHub-->>reDoT: OK/Error
end
reDoT->>AnthropicAPI: Prompt for common DOC.MD based on PR
AnthropicAPI-->>reDoT: updated DOC.MD
end
```
---
{"description":"Week 2","lang":"en-GB","title":"ReDoT: Week 2","contributors":"[{\"id\":\"3f5ac808-e090-4569-ac67-11e31c33d669\",\"add\":4058,\"del\":2051,\"latestUpdatedAt\":1759768529928},{\"id\":\"a9bd50ce-e697-4890-a360-d477f8721ea2\",\"add\":3403,\"del\":2061,\"latestUpdatedAt\":1759766405631},{\"id\":\"f5b88385-f6be-44bb-82b6-f1702529645d\",\"add\":3895,\"del\":1017,\"latestUpdatedAt\":1759766155286}]"}