From 62f11aa02acd0894ebf3b58d0fd4730378829f90 Mon Sep 17 00:00:00 2001 From: gitcommitshow <56937085+gitcommitshow@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:12:32 +0530 Subject: [PATCH] feat: structure for the needed docs pipeline functions --- README.md | 4 ++ src/docs-action.js | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 src/docs-action.js diff --git a/README.md b/README.md index 95c6888..5bd2bbb 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ A Node.js server for GitHub app to assist external contributors and save maintai - [ ] On `integrations-config` PR merge, psot a comment to join Slack's product-releases channel to get notified when that integration goes live - [ ] On `integrations-config` PR merge, post a comment to raise PR in `rudder-docs` - [x] List of open PRs by external contributors +- [ ] Automated docs/code improvement pipeline + - [ ] Configuration page or a labelled gh issue - directory/filename, no. of tiny PRs per week, no. of big PRs every month, changes per file + - [ ] Review files based on configurations, prioritize, and create issues with instructions for the change + - [ ] On issue approval (label change), execute the task (the code change), and raise PR ## Requirements diff --git a/src/docs-action.js b/src/docs-action.js new file mode 100644 index 0000000..539392a --- /dev/null +++ b/src/docs-action.js @@ -0,0 +1,97 @@ +/** + * Automated action to improve docs + */ + +/** + * Scan files under a directory in a repo to find files that need to be improved + * Returns the list of files that need to be improved + * A recurring task that initiates the docs improvement pipeline + * Triggered by: Schedule (every week) + * @param {string} owner + * @param {string} repo + * @returns {Promise} list of files + */ +async function scan(owner, repo) { + console.log("Scanning configuration for improvement scope and opportunities"); + // Get the list of files that need improvement as per master configuration +} + +/** + * Creates an actionable issue for the improvement of particular docs page + * Triggered by: Scan + * @param {string} owner + * @param {string} repo + * @param {string[]} files - The list of files to improve + */ +async function reviewAndPrioritize(owner, repo, files) { + console.log("Reviewing and prioritizing the docs pages for improvement in "+ files.join(", ")); + // Get the file content + // Call the ai review + prioritize endpoint + // Create a new issue with the results +} + +/** + * Get the list of active docs improvement tasks + * @param {string} owner + * @param {string} repo + * @returns {Promise} list of issues + */ +async function getActiveDocsImprovementTasks(owner, repo) { + // Get the list of issues that are related to the improvement of a docs page + // Make sure we have their labels and status +} + +/** + * Create a new issue in Github + * @param {string} owner + * @param {string} repo + * @param {string} path + * @param {string} title + * @param {string} body + */ +async function createIssue(owner, repo, path, title, body) { + +} + +/** + * + * @param {string} owner + * @param {string} repo + * @param {string} issue + */ +async function onIssueLabelChange(owner, repo, issue) { + // Verify that the issue is related to the improvement of a docs page + // Verify that the issue is approved to be processed + // Extract the filepath and the instructions from the issue title and body and comment on the issue with the results + // Trigger file edit + // Update the issue status to "In Progress" +} + + +/** + * Edit a file in the repo + * Triggered by: Issue label change + * @param {string} owner + * @param {string} repo + * @param {string} filepath + * @param {string} content + */ +async function editFile(owner, repo, filepath, content, issue) { + // Call the ai edit endpoint + // Create a new branch + // Commit the changes in the file + // Create a PR + // Link the PR to the issue +} + +/** + * Find issues related to the improvement of a particular file + * @param {string} owner + * @param {string} repo + * @param {string} filepath + * @returns {Promise} list of issues + */ +async function findRelatedIssues(owner, repo, filepath) { + // Get the list of issues that are related to the improvement of the file + // Make sure we have their labels and status +} \ No newline at end of file