Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion packages/action/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204546,6 +204546,16 @@ async function applyCorrectionToRepo(cwd, graph, sectionId, correctedContent) {
}

// src/comment.ts
async function postStatusComment(octokit, ctx, message) {
await octokit.rest.issues.createComment({
owner: ctx.owner,
repo: ctx.repo,
issue_number: ctx.prNumber,
body: `## Doc Check Results

${message}`
});
}
async function postSummaryComment(octokit, ctx, summary2) {
const verifiedAccurate = summary2.verdicts.filter((verdict) => !verdict.stale).length;
const autoFixed = summary2.fixPr?.appliedSectionIds.length ?? 0;
Expand Down Expand Up @@ -204678,14 +204688,27 @@ function loadPrContext() {
}

// src/index.ts
var SUPPORTED_LANGUAGES = "TypeScript, TSX, JavaScript, and Python";
async function run2() {
const config = loadConfig();
const ctx = loadPrContext();
const cwd = process.cwd();
const octokit = getOctokit(config.githubToken);
const llm = new GeminiClient({ apiKey: config.apiKey });
info2("docmend: building code-to-docs link graph...");
info2("docmend: parsing codebase...");
const chunks = await parseCodebase(cwd);
if (chunks.length === 0) {
info2("docmend: no parseable code found in this repository.");
setOutput("stale-sections-found", 0);
setOutput("corrections-generated", 0);
await postStatusComment(
octokit,
ctx,
`No functions, classes, or methods were detected in this repository. docmend currently parses ${SUPPORTED_LANGUAGES}, but doesn't yet recognize every code pattern (e.g. arrow-function-only declarations) - this could mean an unsupported language, or supported code docmend doesn't fully cover yet. Nothing to check.`
);
return;
}
info2("docmend: building code-to-docs link graph...");
const sections = await parseDocs(cwd);
const graph = await buildLinkGraph(chunks, sections, {
llm,
Expand All @@ -204698,6 +204721,7 @@ async function run2() {
info2("docmend: no relevant changes in this PR.");
setOutput("stale-sections-found", 0);
setOutput("corrections-generated", 0);
await postStatusComment(octokit, ctx, "No relevant file changes in this PR. Nothing to check.");
return;
}
const fileChanges = await resolveFileChanges(
Expand All @@ -204711,6 +204735,8 @@ async function run2() {
if (staleVerdicts.length === 0) {
info2("docmend: docs look accurate for this PR.");
setOutput("corrections-generated", 0);
const message = suspects.length === 0 ? "None of the changed code in this PR is referenced by any documentation section (or is in a language/pattern docmend doesn't recognize yet). Nothing to check." : `${suspects.length} linked documentation section(s) checked - all still accurate, nothing to fix.`;
await postStatusComment(octokit, ctx, message);
return;
}
const repairResults = await repairStaleDocs(suspects, verdicts, llm, {
Expand Down
13 changes: 13 additions & 0 deletions packages/action/src/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ export interface CommentSummary {
fixPrError?: string;
}

export async function postStatusComment(
octokit: InstanceType<typeof GitHub>,
ctx: PrContext,
message: string,
): Promise<void> {
await octokit.rest.issues.createComment({
owner: ctx.owner,
repo: ctx.repo,
issue_number: ctx.prNumber,
body: `## Doc Check Results\n\n${message}`,
});
}

export async function postSummaryComment(
octokit: InstanceType<typeof GitHub>,
ctx: PrContext,
Expand Down
30 changes: 28 additions & 2 deletions packages/action/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import {
repairStaleDocs,
resolveFileChanges,
} from '@docmend/core';
import { postSummaryComment } from './comment.js';
import { postStatusComment, postSummaryComment } from './comment.js';
import { loadConfig } from './config.js';
import { createFixPr } from './fix-pr.js';
import { loadPrContext } from './pr-context.js';

const SUPPORTED_LANGUAGES = 'TypeScript, TSX, JavaScript, and Python';

async function run(): Promise<void> {
const config = loadConfig();
const ctx = loadPrContext();
Expand All @@ -27,8 +29,26 @@ async function run(): Promise<void> {
const octokit = getOctokit(config.githubToken);
const llm = new GeminiClient({ apiKey: config.apiKey });

core.info('docmend: building code-to-docs link graph...');
core.info('docmend: parsing codebase...');
const chunks = await parseCodebase(cwd);

if (chunks.length === 0) {
// Checked before parseDocs/buildLinkGraph specifically to avoid burning
// an embed() call per doc section (buildEmbeddingLinks still embeds
// every section even with zero chunks to link against) on a run that's
// about to report there's nothing to do anyway.
core.info('docmend: no parseable code found in this repository.');
core.setOutput('stale-sections-found', 0);
core.setOutput('corrections-generated', 0);
await postStatusComment(
octokit,
ctx,
`No functions, classes, or methods were detected in this repository. docmend currently parses ${SUPPORTED_LANGUAGES}, but doesn't yet recognize every code pattern (e.g. arrow-function-only declarations) - this could mean an unsupported language, or supported code docmend doesn't fully cover yet. Nothing to check.`,
);
return;
}

core.info('docmend: building code-to-docs link graph...');
const sections = await parseDocs(cwd);
const graph = await buildLinkGraph(chunks, sections, {
llm,
Expand All @@ -43,6 +63,7 @@ async function run(): Promise<void> {
core.info('docmend: no relevant changes in this PR.');
core.setOutput('stale-sections-found', 0);
core.setOutput('corrections-generated', 0);
await postStatusComment(octokit, ctx, 'No relevant file changes in this PR. Nothing to check.');
return;
}

Expand All @@ -60,6 +81,11 @@ async function run(): Promise<void> {
if (staleVerdicts.length === 0) {
core.info('docmend: docs look accurate for this PR.');
core.setOutput('corrections-generated', 0);
const message =
suspects.length === 0
? 'None of the changed code in this PR is referenced by any documentation section (or is in a language/pattern docmend doesn\'t recognize yet). Nothing to check.'
: `${suspects.length} linked documentation section(s) checked - all still accurate, nothing to fix.`;
await postStatusComment(octokit, ctx, message);
return;
}

Expand Down
Loading