Skip to content

Commit

Permalink
fixup! Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Apr 30, 2023
1 parent f97c9c8 commit 5c5d031
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions mkdocs/contrib/search/search_index.py
Expand Up @@ -59,7 +59,7 @@ def add_entry_from_context(self, page: Page) -> None:
the page itself and then one for each of its' heading
tags.
"""
title_parts = [page.title]
title_parts = [page.title] if page.title else []
if self.config['full_path_in_title']:
for ancestor in page.ancestors:
title_parts.insert(0, ancestor.title)
Expand All @@ -79,11 +79,7 @@ def add_entry_from_context(self, page: Page) -> None:
# Create an entry for the full page.
text = parser.stripped_html.rstrip('\n') if self.config['indexing'] == 'full' else ''

self._add_entry(
title=page_title,
text=text,
loc=url
)
self._add_entry(title=page_title, text=text, loc=url)

if self.config['indexing'] in ['full', 'sections']:
for i, section in enumerate(parser.data):
Expand All @@ -94,7 +90,11 @@ def add_entry_from_context(self, page: Page) -> None:
self.create_entry_for_section(section, page.toc, url, section_title)

def create_entry_for_section(
self, section: ContentSection, toc: TableOfContents, abs_url: str, title: Optional[str] = None
self,
section: ContentSection,
toc: TableOfContents,
abs_url: str,
title: Optional[str] = None,
) -> None:
"""
Given a section on the page, the table of contents and
Expand Down
4 changes: 2 additions & 2 deletions mkdocs/tests/search_tests.py
Expand Up @@ -82,7 +82,7 @@ def test_plugin_config_defaults(self):
'min_search_length': 3,
'prebuild_index': False,
'indexing': 'full',
'full_path_in_title': False
'full_path_in_title': False,
}
plugin = search.SearchPlugin()
errors, warnings = plugin.load_config({})
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_plugin_config_full_path_in_title(self):
'min_search_length': 3,
'prebuild_index': False,
'full_path_in_title': True,
'indexing': 'full'
'indexing': 'full',
}
plugin = search.SearchPlugin()
errors, warnings = plugin.load_config({'full_path_in_title': True})
Expand Down

0 comments on commit 5c5d031

Please sign in to comment.