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.12k stars 145 forks source link

Lunr search doesn't work for generated docs #349

Closed Diveafall closed 3 years ago

Diveafall commented 3 years ago

Expected Behavior

I have successfully generated documentation and I want to add offline search to it. After adding lunr_search = {'fuzziness': 1, 'index_docstrings': True} to my config.mako it works fine when opened using index.html inside the module subdirectory. However, when I serve the documentation on Netlify or even locally using serve the iframe for the search results point to a file inside a parent directory resulting in a 404 page.

Actual Behavior

Search should work for documentation out of the box.

Steps to Reproduce

  1. Generate documentation for the module: pdoc --html --output-dir api_docs --template-dir pdoc/templates hub
  2. Serve generated documentation from inside api_docs/hub
  3. Search for anything

Additional info

The problem here is obviously that doc-search.html resides above the served site. How can this problem be solved?

jwcarr commented 3 years ago

I'm also having this issue, which seems to have been introduced in version 0.9.2. Prior to that, the search resources were placed in the module subdirectory, but now they are placed in the docs/ directory. This is a problem if you a serving the website from docs/module/ because higher-level resources will not be publicly accessible.

Not sure what the appropriate behavior should be — I presume there was a good reason why the search resources were moved up one level. Seems to be related to #250 and https://github.com/pdoc3/pdoc/commit/2e08bd8c3768031e59a8a662a2cf39f4a0e202ad

kernc commented 3 years ago

The recommended workaround is to instead:

  1. Serve generated documentation from inside api_docs

and put up a doorway page such as https://github.com/pdoc3/pdoc/issues/55#issuecomment-614247015.

Also related to https://github.com/pdoc3/pdoc/issues/101, https://github.com/pdoc3/pdoc/issues/233.