Skip to content

Commit

Permalink
[DOCS] Sitemap fix (#28233)
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 a214bb6 commit 3ce61d6
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,33 +126,36 @@ 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'
Expand Down

0 comments on commit 3ce61d6

Please sign in to comment.