Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search function #446

Closed
AnthonyZJiang opened this issue Jun 24, 2024 · 3 comments
Closed

Search function #446

AnthonyZJiang opened this issue Jun 24, 2024 · 3 comments
Labels
question Not a bug, but a FAQ entry

Comments

@AnthonyZJiang
Copy link

How do I add a search function?

I noticed it was implemented but there is no documentation on it. How do I use it?

@kernc
Copy link
Member

kernc commented Jun 24, 2024

In your config.mako, you enable either of the two search methods following the provided template/example:

# If set, insert Google Custom Search search bar widget above the sidebar index.
# The whitespace-separated tokens represent arbitrary extra queries (at least one
# must match) passed to regular Google search. Example:
#google_search_query = 'inurl:github.com/USER/PROJECT site:PROJECT.github.io site:PROJECT.website'
google_search_query = ''
# Enable offline search using Lunr.js. For explanation of 'fuzziness' parameter, which is
# added to every query word, see: https://lunrjs.com/guides/searching.html#fuzzy-matches
# If 'index_docstrings' is False, a shorter index is built, indexing only
# the full object reference names.
#lunr_search = {'fuzziness': 1, 'index_docstrings': True}
lunr_search = None

That's been supported for a while.

@kernc kernc added the question Not a bug, but a FAQ entry label Jun 24, 2024
@AnthonyZJiang
Copy link
Author

In your config.mako, you enable either of the two search methods following the provided template/example:

# If set, insert Google Custom Search search bar widget above the sidebar index.
# The whitespace-separated tokens represent arbitrary extra queries (at least one
# must match) passed to regular Google search. Example:
#google_search_query = 'inurl:github.com/USER/PROJECT site:PROJECT.github.io site:PROJECT.website'
google_search_query = ''
# Enable offline search using Lunr.js. For explanation of 'fuzziness' parameter, which is
# added to every query word, see: https://lunrjs.com/guides/searching.html#fuzzy-matches
# If 'index_docstrings' is False, a shorter index is built, indexing only
# the full object reference names.
#lunr_search = {'fuzziness': 1, 'index_docstrings': True}
lunr_search = None

That's been supported for a while.

Thanks. I have tried to enable lunr_search, but it causes an error at the end of the doc generation. The search box appears in the HTML but not working.

The terminal prompt:

% pdoc --html --output-dir docs/ --force python_lib/isotope/isotope --template-dir docs/templates/
docs/isotope/index.html
/Users/user/Documents/isotope_sdk/venv/lib/python3.12/site-packages/pdoc/html_helpers.py:532: ReferenceWarning: Code reference `isotope.port.PowerOutput` in module "isotope.isotope" does not match any documented object.
  linked = re.sub(r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?:\(\))?', handle_refname, code_span)
/Users/user/Documents/isotope_sdk/venv/lib/python3.12/site-packages/pdoc/html_helpers.py:532: ReferenceWarning: Code reference `isotope.port.Motor` in module "isotope.isotope" does not match any documented object.
  linked = re.sub(r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?:\(\))?', handle_refname, code_span)
/Users/user/Documents/isotope_sdk/venv/lib/python3.12/site-packages/pdoc/html_helpers.py:532: ReferenceWarning: Code reference `isotope.port.ADCInput` in module "isotope.isotope" does not match any documented object.
  linked = re.sub(r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?:\(\))?', handle_refname, code_span)
/Users/user/Documents/isotope_sdk/venv/lib/python3.12/site-packages/pdoc/html_helpers.py:532: ReferenceWarning: Code reference `isotope.port.PWMOutput` in module "isotope.isotope" does not match any documented object.
  linked = re.sub(r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?:\(\))?', handle_refname, code_span)
/Users/user/Documents/isotope_sdk/venv/lib/python3.12/site-packages/pdoc/html_helpers.py:532: ReferenceWarning: Code reference `isotope.port.TempInput` in module "isotope.isotope" does not match any documented object.
  linked = re.sub(r'[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*(?:\(\))?', handle_refname, code_span)
docs/isotope/isotope.html
docs/isotope/isotope_comms_lib.html
docs/isotope/port/index.html
docs/isotope/port/adc_input.html
docs/isotope/port/isotope_port.html
docs/isotope/port/motor.html
docs/isotope/port/power_output.html
docs/isotope/port/pwm_output.html
docs/isotope/port/temp_input.html
docs/isotope/utils/index.html
docs/isotope/utils/logging.html
Traceback (most recent call last):
  File "/Users/user/Documents/isotope_sdk/venv/bin/pdoc", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/user/Documents/isotope_sdk/venv/lib/python3.12/site-packages/pdoc/cli.py", line 606, in main
    _generate_lunr_search(
  File "/Users/user/Documents/software/isotope_sdk/venv/lib/python3.12/site-packages/pdoc/cli.py", line 422, in _generate_lunr_search
    proc = subprocess.Popen(cmd, text=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/homebrew/Cellar/python@3.12/3.12.3/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'node'

In my config.mako file:

  <%!
      hljs_style = 'atom-one-light'
      lunr_search = {'fuzziness': 1, 'index_docstrings': True}
  %>

@AnthonyZJiang
Copy link
Author

In case it helps, here is the repository I am using pdoc3 to generate documentation for

https://github.com/ICE9-Robotics/isotope_sdk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Not a bug, but a FAQ entry
Development

No branches or pull requests

2 participants