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 isn't indexing the index page of nested pages in htmldir builder #5368

Closed
stsewd opened this issue Feb 27, 2019 · 12 comments · Fixed by #5370
Closed

Search isn't indexing the index page of nested pages in htmldir builder #5368

stsewd opened this issue Feb 27, 2019 · 12 comments · Fixed by #5370
Labels
Bug A bug

Comments

@stsewd
Copy link
Member

stsewd commented Feb 27, 2019

You can test with this project

https://anymail.readthedocs.io/en/latest/search/?q=Sending+email&check_keywords=yes&area=default

There aren't results from this page https://anymail.readthedocs.io/en/latest/sending/

This is kind of related to the doctype that we want to remove #4638 and kind of the same as #5254

In a more minimal example this is more visible, our search returns 0 results and fallback to sphinx.

The explanation is that we try to index the file sending.fjson but that file doesn't exists, what we want is to index sending/index.fjson

@stsewd stsewd added the Bug A bug label Feb 27, 2019
@stsewd
Copy link
Member Author

stsewd commented Feb 27, 2019

We shouldn't use doctype anymore :).

I think basename is sending (not sending/index or index), that's why.

@ericholscher
Copy link
Member

How do you figure out if you should check for an HTMLDir path without doctype? I guess we could just try both, but that feels like it would lead to other bugs.

@stsewd
Copy link
Member Author

stsewd commented Feb 27, 2019

That's what I want I figure out now. If there isn't a clean way, we have the doctype from the config module in the database (old projects don't have this, but we could create a migration).

@ericholscher
Copy link
Member

Seems like this should work?

In [6]: for p in HTMLFile.objects.filter(project__slug='anymail', version__slug='latest', path='sending/index.html'):
   ...:     print(p.json_file_path)
   ...:
readthedocs.projects.models:1154[6212]: INFO Adjusted json file path: sending/index -> sending
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending.fjson

@ericholscher
Copy link
Member

Oh, the filename is /home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending/index.fjson -- that's the issue.

@ericholscher
Copy link
Member

Seems like the logic is broken, and without it it would work 😢

@ericholscher
Copy link
Member

Seems like this logic works for everything except the index file... There's some weird edge case here:

In [1]:
   ...: import os
   ...: for p in HTMLFile.objects.filter(project__slug='anymail', version__slug='latest', path__startswith='sending'):
   ...:     print(p.json_file_path)
   ...:     print(os.path.exists(p.json_file_path))
   ...:
   ...:
readthedocs.projects.models:1154[9789]: INFO Adjusted json file path: sending/templates/index -> sending/templates
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending/templates.fjson
True
readthedocs.projects.models:1154[9789]: INFO Adjusted json file path: sending/tracking/index -> sending/tracking
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending/tracking.fjson
True
readthedocs.projects.models:1154[9789]: INFO Adjusted json file path: sending/django_email/index -> sending/django_email
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending/django_email.fjson
True
readthedocs.projects.models:1154[9789]: INFO Adjusted json file path: sending/signals/index -> sending/signals
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending/signals.fjson
True
readthedocs.projects.models:1154[9789]: INFO Adjusted json file path: sending/exceptions/index -> sending/exceptions
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending/exceptions.fjson
True
readthedocs.projects.models:1154[9789]: INFO Adjusted json file path: sending/anymail_additions/index -> sending/anymail_additions
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending/anymail_additions.fjson
True
readthedocs.projects.models:1154[9789]: INFO Adjusted json file path: sending/index -> sending
/home/docs/checkouts/readthedocs.org/media/json/anymail/latest/sending.fjson
False

@stsewd
Copy link
Member Author

stsewd commented Feb 27, 2019

Yeah, index is the only one affected.

@ericholscher
Copy link
Member

It's because sending.rst or sending/index.rst both lead to the same file :/

@stsewd
Copy link
Member Author

stsewd commented Feb 27, 2019

There isn't a sending.rst file, just sending/index.rst https://github.com/anymail/django-anymail/blob/master/docs/sending/index.rst

@ericholscher
Copy link
Member

Right, but both files could lead to the same output file, so there's no way to know which it came from :/

ericholscher added a commit that referenced this issue Feb 27, 2019
This is because HTMLDir can generate a file from two different places:

* foo.rst
* foo/index.rst

Both lead to `foo/index.html`

refs #5368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants