diff --git a/doc/changelog.d/586.miscellaneous.md b/doc/changelog.d/586.miscellaneous.md new file mode 100644 index 000000000..881fbb9f8 --- /dev/null +++ b/doc/changelog.d/586.miscellaneous.md @@ -0,0 +1 @@ +fix: section ids with search \ No newline at end of file diff --git a/src/ansys_sphinx_theme/search/fuse_search.py b/src/ansys_sphinx_theme/search/fuse_search.py index a008fad42..baff49651 100644 --- a/src/ansys_sphinx_theme/search/fuse_search.py +++ b/src/ansys_sphinx_theme/search/fuse_search.py @@ -101,9 +101,15 @@ def _process_desc_element(self, node, title): for element_child in element.children: if element_child.tagname != "desc_signature": continue - section_anchor_id = element_child.attributes["ids"][0] + if element_child.attributes.get("ids"): + section_anchor_id = element_child.attributes["ids"][0] section_text = element.astext() - section_title = _desc_anchor_to_title(title, section_anchor_id) + if isinstance(section_anchor_id, list) and len(section_anchor_id) > 0: + section_anchor_id = section_anchor_id[0] + if section_anchor_id: + section_title = _desc_anchor_to_title(title, section_anchor_id) + else: + section_title = title self.sections.append( { "title": section_title,