Skip to content

Commit fc97aaa

Browse files
authored
Docs Add Category to Coveo search engine (#26932)
### Details: - *item1* - *...* ### Tickets: - *ticket-id*
1 parent 0aa76e7 commit fc97aaa

File tree

2 files changed

+32
-13
lines changed
  • docs
    • openvino_custom_sphinx_sitemap/openvino_custom_sphinx_sitemap
    • sphinx_setup

2 files changed

+32
-13
lines changed

docs/openvino_custom_sphinx_sitemap/openvino_custom_sphinx_sitemap/__init__.py

+30-11
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def create_sitemap(app, exception):
3939
urlset = app.builder.config.ov_sitemap_urlset
4040
meta = app.builder.config.ov_sitemap_meta
4141

42-
site_url = app.builder.config.site_url or app.builder.config.html_baseurl
42+
site_url = app.builder.config.site_url
43+
4344
if site_url:
4445
site_url.rstrip("/") + "/"
4546
else:
@@ -71,29 +72,28 @@ def create_sitemap(app, exception):
7172
else:
7273
version = ""
7374

75+
url = ET.SubElement(root, "url")
76+
scheme = app.config.sitemap_url_scheme
77+
unique_links = set()
7478
while True:
7579
try:
7680
link = app.env.app.sitemap_links.get_nowait() # type: ignore
81+
if link in unique_links:
82+
continue
83+
unique_links.add(link)
7784
except queue.Empty:
7885
break
7986

80-
url = ET.SubElement(root, "url")
81-
scheme = app.config.sitemap_url_scheme
8287
if app.builder.config.language:
8388
lang = app.builder.config.language + "/"
8489
else:
8590
lang = ""
86-
91+
8792
ET.SubElement(url, "loc").text = site_url + scheme.format(
8893
lang=lang, version=version, link=link
8994
)
9095

91-
if meta:
92-
for entry in meta:
93-
namespace, values = entry
94-
namespace_element = ET.SubElement(url, namespace)
95-
for tag_name, tag_value in values.items():
96-
ET.SubElement(namespace_element, tag_name).text = tag_value
96+
process_coveo_meta(meta, url, link)
9797

9898
for lang in locales:
9999
lang = lang + "/"
@@ -111,4 +111,23 @@ def create_sitemap(app, exception):
111111
encoding='utf-8',
112112
method="xml")
113113
print("%s was generated for URL %s in %s" % (app.config.sitemap_filename,
114-
site_url, filename))
114+
site_url, filename))
115+
116+
def process_coveo_meta(meta, url, link):
117+
if not meta:
118+
return
119+
120+
for namespace, values in meta:
121+
namespace_element = ET.SubElement(url, namespace)
122+
123+
for tag_name, tag_value in values.items():
124+
if tag_name == 'ovcategory':
125+
processed_link = process_link(link)
126+
ET.SubElement(namespace_element, tag_name).text = processed_link
127+
else:
128+
ET.SubElement(namespace_element, tag_name).text = tag_value
129+
130+
def process_link(link):
131+
if '/' in link:
132+
return link.split('/')[0]
133+
return link.split('.html')[0]

docs/sphinx_setup/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
'.md': 'markdown',
5656
}
5757

58-
html_baseurl = 'https://docs.openvino.ai/canonical/'
58+
# html_baseurl = 'https://docs.openvino.ai/canonical/'
5959

6060
# -- Sitemap configuration ---------------------------------------------------
6161

@@ -72,10 +72,10 @@
7272
ov_sitemap_meta = [
7373
('coveo:metadata', {
7474
'ovversion': version_name,
75+
'ovcategory': 'null'
7576
})
7677
]
7778

78-
7979
# ----------------------------------------------------
8080

8181
html_favicon = '_static/favicon.ico'

0 commit comments

Comments
 (0)