Description
Now that we added package search to Hexdocs, we can start exposing it in ExDoc.
This will be done as two distinct features, latest search and related packages search.
We are also adding search feature to Hexdocs landing page and you should familiarize
yourself with the new screens there before moving forward.
Overall description
We will add new features to ExDoc that allows you to perform both search and
autocompletion on the latest or related versions of a package. We will use the
existing docs_config.js
to enable this functionality. Once enabled, a dropdown
arrow will appear embedded at the end of the search allowing you to choose the
type of search you want to perform, similar to this:

The text in the search bar will indicate which mode is active:
related
- Type / to search this and related packageslatest
- Type / to search the latest versioncurrent
- Type / to search this version
You can click the dropdown to choose the mode, these options will show up as:
:related
- Search the latest version of this package and related packages:latest
- Search the latest version of this package- `:current - Search the current version of this package (works offline)
To enable these modes, a searchNodes
variable must be injected into docs_config.js
.
This variable is an array of {name: "package-name", version: "package-version"}
entries,
and it must have at least one entry, which is the current package itself and its latest
version. The modes should be available in this order and according to these conditions:
:related
- If searchNodes is available and it contains more than one entry:latest
- If searchNodes is available and it contains more than zero entries:current
- Always
Furthermore, we also want to improve the search results page to be closer to the one in
HexDocs and provide a more consistent experience overall. This means support for toggling
previews too.
Implementation
-
Update the current search results to leverage previews and stay closer to HexDocs mockups
-
Change HexDocs to include the
searchNodes
in all public packages today.
We should also simplify theversionNodes
one, there is no need to include "latest" on every entry
(cc @wojtekmach) -
Add support for
searchNodes
in ExDoc's autocompletion and search,
with the dropdown for configuration, using the new TypeSense API. We can use Elixir itself to test
this feature, as its docs_config.js is generated by hand rather than Hex.pm -
Change Hex.pm to allow storing related deps and update HexDocs to emit
searchNodes
based on related deps (cc @wojtekmach)