Skip to content
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

Docs port for sitemap fix to 24.6 #28234

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,35 +126,38 @@ def process_coveo_meta(meta, url, link):
if tag_name == 'ovdoctype':
ET.SubElement(namespace_element, tag_name).text = process_link(link)
elif tag_name == 'ovcategory' and loc_element is not None:
ET.SubElement(namespace_element, tag_name).text = extract_hierarchy(loc_element.text)
ET.SubElement(namespace_element, tag_name).text = extract_categories(loc_element.text)
elif tag_name == 'ovversion':
ET.SubElement(namespace_element, tag_name).text = tag_value

def process_link(link):
if '/' in link:
return link.split('/')[0].replace("-", " ")
return link.split('.html')[0].replace("-", " ")
return format_segment(link.split('/')[0].replace("-", " "))
return format_segment(link.split('.html')[0].replace("-", " "))

def extract_hierarchy(link):
def extract_categories(link):
path = link.split("://")[-1]
segments = path.split('/')[1:]
if segments and segments[-1].endswith('.html'):
segments = segments[:-1]

if segments:
segments = segments[1:]

if segments and '.' in segments[0]:
year, *rest = segments[0].split('.')
if year.isdigit() and len(year) == 4:
segments[0] = year

segments = [format_segment(segment) for segment in segments]

hierarchy = []
for i in range(1, len(segments) + 1):
hierarchy.append('|'.join(segments[:i]))

return ';'.join(hierarchy)
if segments:
hierarchy = ['|'.join(segments[:i]) for i in range(1, len(segments) + 1)]
return ';'.join(hierarchy)
return "No category"

def format_segment(segment):
if segment == 'c_cpp_api': segment = 'c/c++_api'
if segment == 'c_cpp_api': segment = 'C/C++_api'

return ' '.join(word.capitalize() for word in segment.replace('-', ' ').replace('_', ' ').split())
Loading