-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
set-alias-page.py
generates misleading pages
#12747
Comments
We could add a warning in the script to make people aware of this issue. Only mentioning here that the script should not be used, is too less visible for others |
I see that It already has a warning at the top of the script:
|
I just wrote a script with the help of ChatGPT to filter out potentially affected pages: Expand to see the codeimport os
import re
def filter_files(directory):
# List to store names of files that meet the criteria
matching_files = []
# Iterate through all files in the given directory
for filename in os.listdir(directory):
file_path = os.path.join(directory, filename)
# Check if it's a file (and not a directory)
if os.path.isfile(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
contains_tldr = False
contains_alias = False
for line in lines:
if re.search(r"^`tldr ", line):
contains_tldr = True
if "This command is an alias of" in line:
contains_alias = True
if contains_tldr and not contains_alias:
matching_files.append(filename)
# Print the names of the matching files
if len(matching_files) > 0:
print(directory)
for file in matching_files:
print(file)
print()
# Replace 'your_directory_path' with the actual directory path you want to process
repo_path = '/home/lin/Desktop/github/tldr'
filter_files(repo_path + '/pages/osx')
filter_files(repo_path + '/pages/sunos')
filter_files(repo_path + '/pages/openbsd')
filter_files(repo_path + '/pages/android')
filter_files(repo_path + '/pages/freebsd')
filter_files(repo_path + '/pages/windows')
filter_files(repo_path + '/pages/linux')
filter_files(repo_path + '/pages/netbsd')
filter_files(repo_path + '/pages/common') /home/lin/Desktop/github/tldr/pages/osx
/home/lin/Desktop/github/tldr/pages/openbsd
/home/lin/Desktop/github/tldr/pages/windows
/home/lin/Desktop/github/tldr/pages/linux
/home/lin/Desktop/github/tldr/pages/common
|
I was too careless writing the |
I suggest updating the get_alias_page function with a better regex to help accurately identify valid alias pages and manage titles with spaces. Please let me know if i can work in this with that idea? |
Feel free to give it a shot! We are always open for ideas and suggestions. |
Yeah, I think updating the script as @Epik-Whale463 suggests is a good plan. |
The
get_alias_page
function doesn't do its job properly. This script then works on non-alias pages, and subsequently makes a huge mess by generating misleading pages. It also has some issues with page titles that contain spaces.Examples: #11365.
Previous runs of this script:
not reverted, some pages are affected, partially reverted (for languages without a CODEOWNER, see Proposal: partially revert #9672 because of misleading translations #12757 for details)set-alias-page.py
should not be used until this is fixed.The text was updated successfully, but these errors were encountered: