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

search always gives no results #328

Open thesadru opened 3 years ago

thesadru commented 3 years ago

Expected Behavior

The search should return a list of results.

Actual Behavior

The search always returns No results.

Steps to Reproduce

  1. Generate docs with a config.mako in this style:
    <%!
    git_link_template = 'https://github.com/thesadru/genshinstats/blob/{commit}/{path}#L{start_line}-L{end_line}'
    google_search_query = '''
        inurl:github.com/thesadru/genshinstats
        site:thesadru.github.io
    '''
    %>
  2. Try to search anything

    alternatively just search on the Github pages I'm trying to use

    https://thesadru.github.io/pdoc/genshinstats/

Additional info

I'm so sorry if this is some obvious bug, but I just can't figure out why.

screenshot: image

kernc commented 3 years ago

This is the same as the configuration we are using, so it should work.

I notice Google only returns a single result for (site:thesadru.github.io OR inurl:github.com/thesadru/genshinstats) wrapper. If fairly new, perhaps you need to wait a few more days for the sites, particularly the subdomain one, to get more properly indexed.

As an alternative, you can use JS-based index/search: https://github.com/pdoc3/pdoc/blob/c2c13200a630f97e5a7b2cba292b0dc9deb58b53/pdoc/templates/config.mako#L51-L56

thesadru commented 3 years ago

I don't have much experience with lunr.js, so I didn't want to use it at first, but I'll use that then. I'll just hope it's only because it wasn't indexed yet. Thanks for the tip.

thesadru commented 3 years ago

Google still hasn't indexed the site so I'm just gonna close this issue.

kernc commented 3 years ago

It sometimes takes days up to a few weeks. Let's keep this open, so it reminds me to check again later. I'd like to confirm.

patnr commented 2 years ago

Also experiencing this issue. My config.mako:

<%!
    # Use `{commit}` instead of `master` to insert current commit hash
    git_link_template = 'https://github.com/nansencenter/DAPPER/blob/master/{path}#L{start_line}-L{end_line}'

    sort_identifiers = False
    # show_type_annotations = True
    # show_source_code = False
    latex_math = True
    google_search_query = 'site:nansencenter.github.io/DAPPER'
%>

Googling site:nansencenter.github.io/DAPPER stats produces many results

But only 1 hit when going through the local search box: Screenshot 2022-05-23 at 15 06 20

kernc commented 2 years ago

@patnr I have no explanation for it, but this is indeed what the custom search engine returns for this query.

Is the website fairly new? Maybe wait a while longer.

There's another search method using Lunr.js search: https://github.com/pdoc3/pdoc/blob/c2c13200a630f97e5a7b2cba292b0dc9deb58b53/pdoc/templates/config.mako#L51-L56 Does that work for you?

patnr commented 2 years ago

Thank you for the swift reply!

The website is >1 years old, and as you can see Google already very much indexes it. I'm not very experienced with web development, but do you have any pointers as to how I might track down the issue?

I will give lunr.js a try as well.

patnr commented 2 years ago

I tried creating my own search engine at https://cse.google.com/ . This works great.

So maybe the problem is with the cx token used by pdoc? https://github.com/pdoc3/pdoc/blob/c2c13200a630f97e5a7b2cba292b0dc9deb58b53/pdoc/templates/html.mako#L403 Could we allow for it to be a key in config.mako ? I'd be happy to make a PR