pdoc3 / pdoc

:snake: :arrow_right: :scroll: Auto-generate API documentation for Python projects
https://pdoc3.github.io/pdoc/
GNU Affero General Public License v3.0
1.14k stars 146 forks source link

lunr_search not working for --html #382

Closed JanPalasek closed 2 years ago

JanPalasek commented 2 years ago

Actual Behavior

  File "venv/bin/pdoc3", line 8, in <module>
    sys.exit(main())
  File "venv/lib/python3.8/site-packages/pdoc/cli.py", line 588, in main
    modules, lunr_config.get("index_docstrings", True), template_config)
AttributeError: 'bool' object has no attribute 'get'

Expected Behavior

Correctly Exported.

Steps to Reproduce

  1. Activate the environment
  2. Run command pdoc3 --html -c lunr_search=True --output-dir=out/ src/

Additional info

Solution

I was able the search bar working by modifying templates/config.mako lunr_search line to the following:

lunr_search = {'fuzziness': 1, 'index_docstrings': True}

The following command then produced a working html:

pdoc3 --html --output-dir=out/ src/python

I believe that command lunr_config.get("index_docstrings", True) doesn't take into account that the lunr_search might not be a dictionary.

JanPalasek commented 2 years ago

I'd like to add that I don't know how to specify the dictionary instead of the simple value for lunr_search in the command-line. It would be very nice to have it in docs.

kernc commented 2 years ago

doesn't take into account that the lunr_search might not be a dictionary.

Apparently, only a dictionary value is supported.

To specify a dictionary value on the command line, I believe something like this should work:

--config "lunr_search={}"

This would then use the defaults.

We don't check config variable types for correctness. The user might run into all sorts of similar issues if they pass invalid types. I guess that's a separate issue, and you're welcome to open a new enhancement proposal for it, hopefully accompanied by a PR.

lunr_search= with --html actually works.

JanPalasek commented 2 years ago

Thanks, it works.