Skip to content

Commit

Permalink
BUG: Don't build Lunr search index when not --html
Browse files Browse the repository at this point in the history
Refs: #339
  • Loading branch information
kernc committed May 6, 2021
1 parent 1c7f454 commit 251d61a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pdoc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,11 @@ def docfilter(obj, _filters=args.filter.strip().split(',')):
# Two blank lines between two modules' texts
sys.stdout.write(os.linesep * (1 + 2 * int(module != modules[-1])))

lunr_config = pdoc._get_config(**template_config).get('lunr_search')
if lunr_config is not None:
_generate_lunr_search(
modules, lunr_config.get("index_docstrings", True), template_config)
if args.html:
lunr_config = pdoc._get_config(**template_config).get('lunr_search')
if lunr_config is not None:
_generate_lunr_search(
modules, lunr_config.get("index_docstrings", True), template_config)


_PANDOC_COMMAND = '''\
Expand Down
4 changes: 4 additions & 0 deletions pdoc/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ def test_lunr_search(self):
file_pattern='example_pkg/module.html')
self._check_files(include_patterns=["'../../doc-search.html#'"],
file_pattern='example_pkg/subpkg/index.html')
# Only build lunr search when --html
with redirect_streams() as (_, stderr):
run(EXAMPLE_MODULE, config='lunr_search={"fuzziness": 1}')
self.assertFalse(stderr.read())

def test_force(self):
with run_html(EXAMPLE_MODULE):
Expand Down

0 comments on commit 251d61a

Please sign in to comment.