Skip to content

Commit

Permalink
Docs port for sitemap fix to 24.6 (#28234)
Browse files Browse the repository at this point in the history
### Details:
 - *item1*
 - *...*

### Tickets:
 - *ticket-id*
  • Loading branch information
akopytko authored Dec 30, 2024
1 parent 42b329a commit 5626caa
Showing 1 changed file with 13 additions and 10 deletions.
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())

0 comments on commit 5626caa

Please sign in to comment.