-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
scripts/set-alias-page.py: fix status message for existing files #15389
base: main
Are you sure you want to change the base?
Conversation
Hello! I've noticed something unusual when checking this PR:
Is this intended? If so, just ignore this comment. Otherwise, please double-check the commits. |
The build for this PR failed with the following error(s):
Please fix the error(s) and push again. |
Could you remove the Korean changes? I think you have committed them by accident when testing |
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.
After removing the Korean changes (or moving them to a separate PR), this LGTM!
Let's separate the Korean alias page into a different PR |
scripts/set-alias-page.py
Outdated
root / "pages" / command, | ||
r"^> This command is an alias of `(.+)`\.$", | ||
r"^> This command is an alias of(?: \w+)? `([^`]+)`(?:,.*)?", |
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 regex is not completely working correctly anymore:
CHECKING tldr-pages/tldr/pages/osx/gsum.md using the regex: ^> This command is an alias of(?: \w+)? `([^`]+)`(?:,.*)?...
RESULT tldr-pages/tldr/pages/osx/gsum.md using the regex: ^> This command is an alias of(?: \w+)? `([^`]+)`(?:,.*)?: COMMAND_NAME= sum
I expected it to be -p linux sum
.
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.
It seems that the command in the description and the tldr command might differ. I’ll try modifying the get_alias_command_in_page()
function.
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.
I tested the changes by creating and running an arbitrary test function, and the updated logic works as expected for most files.
❯ python scripts/set-alias-page.py --test pages/osx/gsum.md
Testing file: pages/osx/gsum.md
Content: # gsum
> This command is an alias of GNU `sum`.
- View documentation for the original command:
`tldr -p linux sum`
Original command: sum
Documentation command: -p linux sum
❯ python scripts/set-alias-page.py --test pages.nl/osx/gsum.md
Testing file: pages.nl/osx/gsum.md
Content: # gsum
> Dit commando is een alias van `-p linux sum`.
- Bekijk de documentatie van het originele commando:
`tldr -p linux sum`
Original command: -p linux sum
Documentation command: -p linux sum
❯ python scripts/set-alias-page.py --test pages/osx/g\[.md
Testing file: pages/osx/g[.md
Content: # g[
> This command is an alias of GNU `[`.
- View documentation for the original command:
`tldr -p linux [`
Original command: [
Documentation command: -p linux [
❯ python scripts/set-alias-page.py --test pages.nl/osx/g\[.md
Testing file: pages.nl/osx/g[.md
Content: # g[
> Dit commando is een alias van `-p linux [`.
- Bekijk de documentatie van het originele commando:
`tldr -p linux [`
Original command: -p linux [
Documentation command: -p linux [
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.
When testing with the latest version, it is still "broken". --test
does not exist anymore. I use python scripts/set-alias-page.py -Snl nl
which still results in the long list with the osx/g*.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.
It was just for output, but now added a function for testing.
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.
The function to test isn't needed. It was just not working as expected.
- Seperate original command and documentation command - Update variable names
@@ -241,9 +317,23 @@ def main(): | |||
parser = create_argument_parser( | |||
"Sets the alias page for all translations of a page" | |||
) | |||
parser.add_argument("command", type=str, nargs="?", default="") | |||
parser.add_argument( | |||
"original_command", |
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.
Please update the usage at the beginning of the file to rename "command" to "original command" and add "documentation command".
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.
I added documentation examples for 'ORIGINAL_CMD' and 'DOC_CMD.' While testing, I found that commands like python3 scripts/set-alias-page.py -P osx/gsum sum '-p linux sum'
failed due to the -p argument being incorrect. To fix this, I changed the page argument from -p to -P.
- Extract locale alias pattern logic into a separate function for better readability - Change -p to -P to avoid collision with tldr's -p flag in documentation command (e.g., "-p linux sum" in "python3 scripts/set-alias-page.py -P osx/gsum sum '-p linux sum'") - Update documentation to use consistent command argument names (ORIGINAL_CMD, DOC_CMD) - Change bullet points to asterisks in examples for better visibility
Fixes: #14929
This PR addresses an issue in the
set-alias-page.py
script where it incorrectly shows “page would be added” for files that already exist and improves handling for diverse alias patterns.Changes
set_alias_page()
function to check file existence before determining status.original_command
to checkingpath.exists()
.get_alias_command_in_page()
with pre-parsed alias patterns specific to each language(e.g., "This command is an alias of" for English, "이 명령은" for Korean, "このコマンドは" for Japanese).
Before
GNU
or trailing descriptions.After