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

Make functions in docs filterable #2514

Merged
merged 1 commit into from
Apr 29, 2016
Merged

Conversation

captbaritone
Copy link
Collaborator

@captbaritone captbaritone commented Apr 25, 2016

With a utility library like Underscore, it is very common to open the docs with the aim of locating the documentation for a specific function.

Currently I use my browser's search functionality, but since many functions reference other functions, I frequently have to cycle through multiple matches before I arrive at the actual function's description.

This patch aims to improve this common use case by offering a "filter" input above the list of functions. As a user types, the list of functions (and section titles) is reduced, leaving only the matching functions. If the user presses enter, they are jumped to the documentation for the first matching
function.

This functionality (and implementation) is greatly inspired by the implementation that is included in the Ramda docs.

You can read their source code here

To aid in review, you can find try out the functionality here: https://rawgit.com/captbaritone/underscore/search/index.html

Possible Improvements

  1. The look of the search input could be improved.
  2. The "autofocus" feature is not currently working on Firefox.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.867% when pulling 66da49f on captbaritone:search into ce591c8 on jashkenas:master.

@Florian-R
Copy link
Contributor

The input seems a bit out of place (at least on FF 45, on Chromium it's OK). Could be cool to add it a width: 80% or something like this.

Except this 👍 very nice work.

With a utility library like Underscore, it is very common to open the docs with
the aim of locating the documentation for a specific function.

Currently I use my browser's search functionality, but since many functions
reference other functions, I frequently have to cycle through multiple matches
before I arrive at the actual function's description.

This patch aims to improve this common use case by offering a "filter" input
above the list of functions. As a user types, the list of functions (and
section titles) is reduced, leaving only the matching functions. If the user
presses enter, they are jumped to the documentation for the first matching
function.

This functionality (and implementation) is greatly inspired by the
implementation that is included in the [Ramda docs](http://ramdajs.com/0.21.0/docs/).

You can read their source code [here](https://github.com/ramda/ramda.github.io/blob/master/main.js)
@captbaritone
Copy link
Collaborator Author

@Florian-R Good idea. Added.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.867% when pulling ef9ee4b on captbaritone:search into 1e68f06 on jashkenas:master.

@jridgewell
Copy link
Collaborator

👍. Someone else want to weigh in?

@captbaritone
Copy link
Collaborator Author

I'll merge this later today, unless somebody objects.

@captbaritone captbaritone merged commit 0111847 into jashkenas:master Apr 29, 2016
@captbaritone
Copy link
Collaborator Author

There are some merge conflicts between this PR and the gh-pages. I'll resolve those tomorrow or Saturday and push.

captbaritone added a commit to captbaritone/underscore that referenced this pull request Apr 29, 2016
Because the "Functions" section heading already uses `#functions` the
individual method uses an irregular id. I missed this in jashkenas#2514.
@captbaritone
Copy link
Collaborator Author

I've cherry-picked this over to gh-pages. The only conflict was that master includes docs for isSymbol which is not yet in the current release.

captbaritone added a commit that referenced this pull request Apr 29, 2016
Because the "Functions" section heading already uses `#functions` the
individual method uses an irregular id. I missed this in #2514.
@jridgewell
Copy link
Collaborator

This might be the best thing to ever happen to underscore.

@jashkenas
Copy link
Owner

This is super nice! @captbaritone — Would you be interested in adding the same functionality over on the Backbone docs?

@captbaritone
Copy link
Collaborator Author

@jashkenas Glad you like it! @msrose and I will take a look at porting it to Backbone.

@msrose
Copy link

msrose commented Sep 16, 2016

FYI: jashkenas/backbone#4075

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants