Skip to content

Commit 251d61a

Browse files
committed
BUG: Don't build Lunr search index when not --html
Refs: #339
1 parent 1c7f454 commit 251d61a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pdoc/cli.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,11 @@ def docfilter(obj, _filters=args.filter.strip().split(',')):
581581
# Two blank lines between two modules' texts
582582
sys.stdout.write(os.linesep * (1 + 2 * int(module != modules[-1])))
583583

584-
lunr_config = pdoc._get_config(**template_config).get('lunr_search')
585-
if lunr_config is not None:
586-
_generate_lunr_search(
587-
modules, lunr_config.get("index_docstrings", True), template_config)
584+
if args.html:
585+
lunr_config = pdoc._get_config(**template_config).get('lunr_search')
586+
if lunr_config is not None:
587+
_generate_lunr_search(
588+
modules, lunr_config.get("index_docstrings", True), template_config)
588589

589590

590591
_PANDOC_COMMAND = '''\

pdoc/test/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ def test_lunr_search(self):
274274
file_pattern='example_pkg/module.html')
275275
self._check_files(include_patterns=["'../../doc-search.html#'"],
276276
file_pattern='example_pkg/subpkg/index.html')
277+
# Only build lunr search when --html
278+
with redirect_streams() as (_, stderr):
279+
run(EXAMPLE_MODULE, config='lunr_search={"fuzziness": 1}')
280+
self.assertFalse(stderr.read())
277281

278282
def test_force(self):
279283
with run_html(EXAMPLE_MODULE):

0 commit comments

Comments
 (0)