i18n-ja-release-8.5: fix aliases in JA docs#22467
i18n-ja-release-8.5: fix aliases in JA docs#22467qiancai merged 2 commits intopingcap:i18n-ja-release-8.5from
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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @qiancai, 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 focuses on enhancing the consistency and maintainability of Japanese documentation aliases. It systematically removes outdated or non-standard alias paths and applies a '/ja' prefix to all valid 'tidb/stable' and 'tidbcloud' aliases, ensuring that Japanese-specific documentation links are correctly structured and easily identifiable. The changes were likely applied using the newly added Python script, streamlining future updates. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request updates the aliases in a large number of Japanese documentation files to ensure they are correctly prefixed for the Japanese version of the documentation, utilizing a Python script for automation. While the script's logic is sound, it introduces a minor information exposure due to a hardcoded absolute path containing a local username, which also limits its portability. Additionally, there are suggestions to improve the script's overall reusability and robustness.
I am having trouble creating individual review comments. Click here to see my feedback.
scripts/add-ja-to-aliases.py (92-108)
The script uses a hardcoded absolute path for TARGET_DOC_PATH at the top of the file, which limits its portability. It's better to make this configurable by accepting it as a command-line argument. Using Python's argparse module is a good way to handle this.
With the suggested change to the main function, you should also remove the global TARGET_DOC_PATH variable at the top of the file.
This change makes the script more reusable and easier for other developers to run on their own machines without modifying the source code.
def main():
import argparse
parser = argparse.ArgumentParser(
description="Update aliases in markdown files for Japanese documentation."
)
parser.add_argument(
"target_path", help="The root directory of the documentation to process."
)
args = parser.parse_args()
target_doc_path = args.target_path
modified_count = 0
scanned_count = 0
for root, _dirs, files in os.walk(target_doc_path):
for filename in files:
if not filename.endswith(".md"):
continue
filepath = os.path.join(root, filename)
scanned_count += 1
if process_file(filepath):
rel_path = os.path.relpath(filepath, target_doc_path)
print(f" Modified: {rel_path}")
modified_count += 1
print(f"\nDone. Scanned {scanned_count} files, modified {modified_count} files.")scripts/add-ja-to-aliases.py (16)
The script contains a hardcoded absolute path /Users/grcai/Documents/GitHub/docs. This is a security and operational issue for two reasons:
- Information Exposure: It discloses the local username (
grcai) and the directory structure of the developer's machine in the public repository. - Portability: The script will fail in any environment where this specific path does not exist, such as CI/CD pipelines or other developers' machines.
It is recommended to use a relative path or an environment variable to specify the target directory.
TARGET_DOC_PATH = os.getenv("TARGET_DOC_PATH", ".")
scripts/add-ja-to-aliases.py (25-66)
The current implementation uses regular expressions to parse and modify the aliases line. While this works for the current format, it can be fragile if the format of the frontmatter changes, for example, if aliases are split across multiple lines.
For better robustness, consider using a YAML parsing library (like PyYAML or ruamel.yaml) to parse the frontmatter, modify the aliases list, and then write the frontmatter back. This would handle different formatting styles and multi-line aliases gracefully.
However, for a one-off script, the current approach is acceptable.
|
@shhdgit: adding LGTM is restricted to approvers and reviewers in OWNERS files. DetailsIn response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
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?