Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhong5297 committed Mar 26, 2023
1 parent fb67b3f commit 3d143cd
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ module.exports = {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
},
// "overrides": [
// {
Expand Down
27 changes: 21 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"license": "MIT",
"dependencies": {
"@dqbd/tiktoken": "^1.0.2",
"@types/istextorbinary": "^2.3.1",
"chalk": "^5.2.0",
"cli-progress": "^3.12.0",
"commander": "^10.0.0",
Expand Down
26 changes: 16 additions & 10 deletions src/cli/commands/index/processRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ export const processRepository = async (
ignore,
filePrompt,
folderPrompt,
chatPrompt,
contentType,
targetAudience
targetAudience,
}: AutodocRepoConfig,
dryRun?: boolean,
) => {
Expand All @@ -65,7 +64,7 @@ export const processRepository = async (
projectName,
contentType,
filePrompt,
targetAudience
targetAudience,
}): Promise<void> => {
const content = await fs.readFile(filePath, 'utf-8');
const markdownFilePath = path.join(outputRoot, filePath);
Expand All @@ -75,14 +74,14 @@ export const processRepository = async (
projectName,
content,
contentType,
filePrompt
filePrompt,
);
const questionsPrompt = createCodeQuestions(
projectName,
projectName,
content,
contentType,
targetAudience
targetAudience,
);
const summaryLength = encoding.encode(summaryPrompt).length;
const questionLength = encoding.encode(questionsPrompt).length;
Expand Down Expand Up @@ -237,7 +236,14 @@ export const processRepository = async (
);

const summary = await callLLM(
folderSummaryPrompt(folderPath, projectName, files, folders, contentType, folderPrompt),
folderSummaryPrompt(
folderPath,
projectName,
files,
folders,
contentType,
folderPrompt,
),
models[LLMModels.GPT4].llm,
);

Expand Down Expand Up @@ -288,7 +294,7 @@ export const processRepository = async (
filePrompt,
folderPrompt,
contentType,
targetAudience
targetAudience,
}),
traverseFileSystem({
inputPath: inputRoot,
Expand All @@ -301,7 +307,7 @@ export const processRepository = async (
filePrompt,
folderPrompt,
contentType,
targetAudience
targetAudience,
}),
]);

Expand All @@ -326,7 +332,7 @@ export const processRepository = async (
filePrompt,
folderPrompt,
contentType,
targetAudience
targetAudience,
});
spinnerSuccess(`Processing ${files} files...`);

Expand All @@ -342,7 +348,7 @@ export const processRepository = async (
filePrompt,
folderPrompt,
contentType,
targetAudience
targetAudience,
});
spinnerSuccess(`Processing ${folders} folders... `);
stopSpinner();
Expand Down
6 changes: 3 additions & 3 deletions src/cli/commands/index/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const createCodeFileSummary = (
projectName: string,
fileContents: string,
contentType: string,
filePrompt: string
filePrompt: string,
): string => {
return `
You are acting as a ${contentType} documentation expert for a project called ${projectName}.
Expand All @@ -26,7 +26,7 @@ export const createCodeQuestions = (
projectName: string,
fileContents: string,
contentType: string,
targetAudience: string
targetAudience: string,
): string => {
return `
You are acting as a ${contentType} documentation expert for a project called ${projectName}.
Expand All @@ -48,7 +48,7 @@ export const folderSummaryPrompt = (
files: FileSummary[],
folders: FolderSummary[],
contentType: string,
folderPrompt: string
folderPrompt: string,
): string => {
return `
You are acting as a ${contentType} documentation expert for a project called ${projectName}.
Expand Down
32 changes: 17 additions & 15 deletions src/cli/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ export const makeConfigTemplate = (
'*.toml',
'*autodoc*',
],
filePrompt: "Write a detailed technical explanation of what this code does. \
Focus on the high-level purpose of the code and how it may be used in the larger project.\
Include code examples where appropriate. Keep you response between 100 and 300 words. \
DO NOT RETURN MORE THAN 300 WORDS.\
Output should be in markdown format.\
Do not just list the methods and classes in this file.",
folderPrompt: "Write a technical explanation of what the code in this file does\
and how it might fit into the larger project or work with other parts of the project.\
Give examples of how this code might be used. Include code examples where appropriate.\
Be concise. Include any information that may be relevant to a developer who is curious about this code.\
Keep you response under 400 words. Output should be in markdown format.\
Do not just list the files and folders in this folder.",
chatPrompt: "",
contentType: "code",
targetAudience: "smart developer",
filePrompt:
'Write a detailed technical explanation of what this code does. \
Focus on the high-level purpose of the code and how it may be used in the larger project.\
Include code examples where appropriate. Keep you response between 100 and 300 words. \
DO NOT RETURN MORE THAN 300 WORDS.\
Output should be in markdown format.\
Do not just list the methods and classes in this file.',
folderPrompt:
'Write a technical explanation of what the code in this file does\
and how it might fit into the larger project or work with other parts of the project.\
Give examples of how this code might be used. Include code examples where appropriate.\
Be concise. Include any information that may be relevant to a developer who is curious about this code.\
Keep you response under 400 words. Output should be in markdown format.\
Do not just list the files and folders in this folder.',
chatPrompt: '',
contentType: 'code',
targetAudience: 'smart developer',
};
};

Expand Down
8 changes: 4 additions & 4 deletions src/cli/utils/traverseFileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const traverseFileSystem = async (
params: TraverseFileSystemParams,
): Promise<void> => {
try {
const { inputPath, projectName, processFile, processFolder, ignore, filePrompt, folderPrompt, contentType, targetAudience } =
params;
// eslint-disable-next-line prettier/prettier
const { inputPath, projectName, processFile, processFolder, ignore, filePrompt, folderPrompt, contentType, targetAudience } = params;

try {
await fs.access(inputPath);
Expand Down Expand Up @@ -42,7 +42,7 @@ export const traverseFileSystem = async (
shouldIgnore,
folderPrompt,
contentType,
targetAudience
targetAudience,
});
}
}),
Expand All @@ -60,7 +60,7 @@ export const traverseFileSystem = async (
projectName,
filePrompt,
contentType,
targetAudience
targetAudience,
});
}
}),
Expand Down

0 comments on commit 3d143cd

Please sign in to comment.