8000 Online docs: make index search always available. · Issue #60075 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Online docs: make index search always available. #60075

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

Open
terryjreedy opened this issue Sep 6, 2012 · 15 comments
Open

Online docs: make index search always available. #60075

terryjreedy opened this issue Sep 6, 2012 · 15 comments
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement

Comments

@terryjreedy
Copy link
Member
BPO 15871
Nosy @birkenfeld, @terryjreedy, @ezio-melotti, @merwok, @bitdancer, @asvetlov

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2012-09-06.17:14:26.261>
labels = ['type-feature', 'docs']
title = 'Online docs: make index search always available.'
updated_at = <Date 2014-05-13.21:36:43.518>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2014-05-13.21:36:43.518>
actor = 'skrah'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2012-09-06.17:14:26.261>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 15871
keywords = []
message_count = 11.0
messages = ['169930', '169931', '169933', '169935', '169937', '169963', '170048', '211506', '211522', '211528', '211553']
nosy_count = 8.0
nosy_names = ['georg.brandl', 'terry.reedy', 'ezio.melotti', 'eric.araujo', 'r.david.murray', 'asvetlov', 'docs@python', 'Ramchandra Apte']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue15871'
versions = ['Python 2.7', 'Python 3.3', 'Python 3.4', 'Python 3.5']

@terryjreedy
Copy link
Member Author

For the Windows Help version of the docs, the left side box has 4 tabs: Contents, Index, Search, Favorites. I now mostly use the Index tab. That means that I can enter an indexed keyword, topic, or object name and jump from place to place in the docs.

The left margin of the online docs only has a text search box equivalent to the Windows search tab (which I essentially never use). The index is only available on the front page, possibly not even visible without scrolling. Consequently, people, especially beginners, tend to use the text search box when they should be using the index. The result is often useless.

The issue came up on python-list about a beginner entering 'print' and getting nothing useful. With the Windows doc, 'print' in the index search immediately brings up print (builtin function) (twice, I did not look into why). The same thing in the search lists 153 pages, with the builtin functions page at 75. Not too surprising, as it is a long page with only 3 occurrences of 'print'. Also not useful.

So I think the online docs should also have an always available index search box in addition to the text search box (which should be properly labeled as such). 'Enter a module, class, for function name.' should be applied to index search, not text search.

An alternative is for the one box to give both index search results and text search results, but doing the latter when one only wants the former is a waste of both server and reader resources.

@terryjreedy terryjreedy added docs Documentation in the Doc dir type-feature A feature request or enhancement labels Sep 6, 2012
@bitdancer
Copy link
Member

The index is available on every page via the link in the upper right corner. An index-specific search might be interesting, though I usually just click the 'index on one page' link and do a text search. But that is a two step process and doesn't give a nice list of hits.

I don't think I ever use the text search box, either. I just use google.

@ezio-melotti
Copy link
Member

I find the current search quite useless.
I think index search with a fallback on text search when there are no results would be better.

@terryjreedy
Copy link
Member Author

I am not the only person who finds the 4 lines of

Quick search
[ ] [go]
Enter search terms or a module,
class or function name.

more eye-catching than the more useful
modules | index

in the corner. It is not even obvious what those are about. They are in black 'I am not a link' text until the mouse goes over them. So lets make them more prominent.

Second, no one finds the current, eye-catching Quick search very useful. For naive beginners, it seems to be off-putting.
The python-list thread is "python docs search for 'print'". So lets change it.

Combining these ideas, my revised suggestion is: Move the upper right entries to the sidebar above Quick search and expand and capitalize them so the sidebar would then look like

Module index
General index
Quick search
[ ]...

where the quick search is actually initially quick by first searching only the general index (Ezio's variation). (I am assuming that all modules are in the general index also). If something is found, it reports "Index entries found:" and only offers "Click here to do a full text search". If nothing is in the index, report "No index entries found, doing a full text search ..."

(This would still not be as good as the Windows doc, where the index tab starts with the entire index list and responds as each character is entered. That catches typos as mistyped. This would best be done by client-side javascript after loading the entire index list.)

@skrah
Copy link
Mannequin
skrah mannequin commented Sep 6, 2012

I like the quick search: It works very well for function names.
For the use cases mentioned here I use Google.

I never use the index, so for me personally the positioning of
the quick search box is perfect.

@terryjreedy
Copy link
Member Author

'print' *is* a function name ;-)
which also happens to be a common word.

If the current search box gives you the page where the function is defined, searching the index first should give you the same page.

@ezio-melotti
Copy link
Member

If I search for "random", at the top of the result lists I want to see at least the "random" module and the "random.random" function.

Currently the "random" module is the 4th result, and "random.random" is buried down in the list (17th place) among all the other random.* functions.

The results are generated by the query() function in searchtools.js, and AFAIU it generates 3 lists, importantResults, objectResults, unimportantResults, that get then sorted independently in alphabetic order by the object fullname, and concatenated.

I experimented a bit and one way to get exact matches to the top is to add before the switch at line 370 something like 
if (fullname == object) {
    importantResults.push(result);
    continue;
}

This will include "random", but not "random.random".
Other possible variations are 
  if ((fullname == object) || (fullname.split('.').pop() == object)) {
or
  if ((fullname == object) || $.inArray(object, fullname.split('.')) > -1)

Here fullname is e.g. "random.random", "$.inArray(object, fullname.split('.')) > -1" is the jquery equivalent of Python's "object in fullname.split('.')".

Another way to address the problem is to change the sorting algorithm to move near the top results like "random" and "random.random".

@ezio-melotti
Copy link
Member

This seems to have been fixed/improved already.
A search for "random" now returns the random module as first result and random.random as second.
Searching for "print" returns the pprint module first, and then the print function.
With "str" or "list" the results are a bit worse, with the builtin function in 6th and 4th position respectively.
Searching for keywords (e.g. "with") still doesn't give useful results.

The code now uses something similar to what I suggested in the previous message (if ((fullname == object) || (fullname.split('.').pop() == object)) {...}) and a scoring system. It might still need some tweaking to get better results with "str" and "list" and for keywords, but it's already much better.

Terry, given these improvements, do you still think that using the index is better? Are there still searches that don't return the desired results?

@terryjreedy
Copy link
Member Author

We have collectively spent much time creating reasonably good module and term indexes and more improvements can and will be made. I strongly feel that they should be made as easily searchable and usable as the full text searches that are generally less useful to useless and are always more resource consuming.

You already answered your first question. While 'print' is listed second (but should be first)-- after a delay that would not be needed if the index were used -- it is followed by 62 lines of noise. What a waste. If the index were used, the response to 'with' would start with 'with: statement'.

As for other searches: 'if' returns hits for 'snIFf', 'dIFference', 'hexlIFy', etc, but not the 'if' statement, which would be first if the index were used; **' return no hits, whereas an index search would return the current entries for '**'. Ditto for '%' and '&'. Google and other search engines do not search for symbols. It is a shame that the search box on the docs does not either. A few years ago I collected to data needed to vastly improve the symbol index, but doing so will not do the current doc search box any good if the index is not used.

@birkenfeld
Copy link
Member

What a waste indeed. After all, when I want to search I only ever want one single match to be displayed.

@terryjreedy
Copy link
Member Author

I believe I somewhere proposed that there be an option to get more *if one wanted more*. The real waste is not using the available index resources.

@CAM-Gerlach
Copy link
Member

See also #87780 and #89541

It looks like there have at least been some improvements in this regard, especially recently—builtin functions do show up now as of the 3.11 docs (if we can backport a later sphinx version to 3.10, that might pick up the fix if its upstream, along with several others we want), index entries show up before text matches, glossary entries show up above everything else, and we can add our own glossary entries for common search queries (kwargs, etc) as discussed on #87780 .

It seems the main remaining immediately actionable ask here, as also discussed on python/docs-community#39 and python/docs-community#44 , is seeing if we can modify the upstream Sphinx searchtools.js to prioritize exact matches (print) over partial matches (pprint)? @AA-Turner what do you think about that?

Also, the other missing item is a way to index keywords—right now, they don't show up in search. I'm not sure what to do about that, though, since AFAIK there isn't a specific role for them and we'd want them to jump to their relevant section in the Python language reference rather than filling up the glossary with them, at least I'd think so?

@AA-Turner
Copy link
Member

Also, the other missing item is a way to index keywords—right now, they don't show up in search. I'm not sure what to do about that, though, since AFAIK there isn't a specific role for them and we'd want them to jump to their relevant section in the Python language reference rather than filling up the glossary with them, at least I'd think so?

The keyword role currently just looks for link targets. Are there any :keyword: role usages that don't have a corresponding .. index:: directive? For example the for statement has an index directive for it.

A

@CAM-Gerlach
Copy link
Member

From the ones I looked at, they all have index directives. Assuming you make the index searchable, that should solve this too. then.

@AA-Turner
Copy link
Member

See sphinx-doc/sphinx#10819 -- testing appreciated!

A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

6 participants
0