-
Notifications
You must be signed in to change notification settings - Fork 701
refactor: consolidate TOC file handling in cloud document scripts #21511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @shhdgit, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request implements a refactoring effort to consolidate and standardize the handling of Table of Contents (TOC) files specifically for cloud documentation. The core change involves centralizing the definition of relevant cloud TOC files and updating various JavaScript scripts to consistently process and filter documents based on this consolidated list. This significantly improves the maintainability and robustness of the documentation build process.
Highlights
- Consolidated TOC File List Definition: A new
CLOUD_TOC_LIST
constant has been introduced acrossscripts/filterCloudDoc.js
,scripts/filterCloudInitFiles.js
, andscripts/filterNonCloudDoc.js
. This centralizes the definition of all relevant cloud Table of Contents (TOC) markdown files, improving consistency and maintainability. - Refactored Cloud Document Filtering Logic: The
main
function inscripts/filterCloudDoc.js
was updated to iterate through the newly definedCLOUD_TOC_LIST
. It now collects all markdown links from each specified TOC file usinggetAllMdList
, flattens the aggregated lists, and deduplicates the entries to ensure comprehensive processing of all cloud-related documents. - Streamlined Cloud Initialization File Processing: In
scripts/filterCloudInitFiles.js
, the previous manual reading and regex-based extraction of links from a single TOC file have been replaced. The script now efficiently gathers and deduplicates all relevant file paths from multiple cloud TOCs by leveraging thegetAllMdList
utility function and theCLOUD_TOC_LIST
. - Enhanced Non-Cloud Document Exclusion: The
extractFilefromList
function withinscripts/filterNonCloudDoc.js
has been modified. Instead of checking for a single specific TOC file (TOC-tidb-cloud.md
), the filtering logic now correctly identifies and skips all files present in theCLOUD_TOC_LIST
, ensuring accurate exclusion of all designated cloud TOCs.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively refactors the scripts to handle multiple cloud documentation TOC files, which is a great improvement. My main feedback focuses on further improving maintainability by centralizing the new CLOUD_TOC_LIST
constant. Currently, it's duplicated across three files. Moving it to a single shared location like utils.js
will make future updates much simpler and less error-prone. I've also included a couple of minor suggestions to remove redundant code comments.
scripts/filterCloudDoc.js
Outdated
const CLOUD_TOC_LIST = [ | ||
"TOC-tidb-cloud.md", | ||
"TOC-tidb-cloud-essential.md", | ||
"TOC-tidb-cloud-starter.md", | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's great to consolidate the TOC file list, this CLOUD_TOC_LIST
constant is now duplicated in filterCloudInitFiles.js
and filterNonCloudDoc.js
as well.
To avoid duplication and improve maintainability, this constant should be defined once in a shared file (e.g., scripts/utils.js
) and then imported where needed. This follows the Don't Repeat Yourself (DRY) principle.
You would need to add the constant definition and export it from scripts/utils.js
:
// In scripts/utils.js
export const CLOUD_TOC_LIST = [
"TOC-tidb-cloud.md",
"TOC-tidb-cloud-essential.md",
"TOC-tidb-cloud-starter.md",
];
Then, you can import it here.
import { CLOUD_TOC_LIST } from "./utils.js";
scripts/filterCloudInitFiles.js
Outdated
const CLOUD_TOC_LIST = [ | ||
"TOC-tidb-cloud.md", | ||
"TOC-tidb-cloud-essential.md", | ||
"TOC-tidb-cloud-starter.md", | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CLOUD_TOC_LIST
constant is duplicated across multiple scripts. To improve maintainability, it should be defined once in scripts/utils.js
and imported.
Please remove this constant definition and instead modify the import on line 3 to:
import { getAllMdList, CLOUD_TOC_LIST } from "./utils.js";
You will also need to add the constant definition to scripts/utils.js
and export it.
scripts/filterNonCloudDoc.js
Outdated
const CLOUD_TOC_LIST = [ | ||
"TOC-tidb-cloud.md", | ||
"TOC-tidb-cloud-essential.md", | ||
"TOC-tidb-cloud-starter.md", | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This CLOUD_TOC_LIST
constant is duplicated across multiple scripts. To improve maintainability, it should be defined once in scripts/utils.js
and imported.
Please remove this constant definition and instead add the following import at the top of the file with the other imports:
import { CLOUD_TOC_LIST } from "./utils.js";
You will also need to add the constant definition to scripts/utils.js
and export it.
scripts/filterCloudDoc.js
Outdated
getAllMdList(tocFile) | ||
); | ||
const flattenedList = allFilteredLinkLists.flat(); | ||
const filteredLinkList = [...new Set(flattenedList)]; // Deduplicate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scripts/filterCloudInitFiles.js
Outdated
getAllMdList(tocFile) | ||
); | ||
const flattenedList = allFilteredLinkLists.flat(); | ||
const allFilePaths = [...new Set(flattenedList)]; // Deduplicate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… cloud document scripts
…tency in cloud document scripts
…ud document scripts
…onCloudDoc script
First-time contributors' checklist
What is changed, added or deleted? (Required)
Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
For details, see tips for choosing the affected versions.
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?