Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: mix hex.docs.search task #1076

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

Draft
zachdaniel wants to merge 1 commit into hexpm:main
base: main
Choose a base branch
Loading
from zachdaniel:hex.docs.search

Conversation

@zachdaniel
Copy link

@zachdaniel zachdaniel commented Jul 17, 2025

Hey folks! This is an initial foray into defininga mix task for searching hex docs. It does the bare minimum right now, but gives us a starting point for discussion. Things to discuss likely include:

  1. Should this be a thing at all?
  2. Should we present human readable output? If so, how do you want to go about handling JSON, as Jason isn't a part of Hex and not all Elixir versions support the new JSON module etc.
  3. how should we handle errors? Should we retry?

This task would be useful for agentic tools in addition to just human use, assuming that we format it as a human readable output. Right now it just dumps the raw JSON (which is fine for agents but bad for humans).

Open to thoughts/critiques, or happy to have this PR closed if this doesn't seem like something we want, or isn't in the place we want it.

Copy link
Author

@josevalim per our conversation.

Copy link
Author

I've fleshed this out very nicely in usage_rules, and I'm very happy to move some or all of that logic here ❤️

I wanted a good way to distribute and work on this in a way taht doesn't rely on users updating hex, and I wanted to be able to play w/ packages and formats etc.

CleanShot_2025年07月17日_at_15.12.21.mp4

Copy link
Member

ericmj commented Aug 5, 2025

Should we present human readable output? If so, how do you want to go about handling JSON, as Jason isn't a part of Hex and not all Elixir versions support the new JSON module etc.

We can add support for "application/vnd.hex+erlang", to hexdocs, that uses erlang binary term format https://github.com/hexpm/hex/blob/main/lib/hex/api.ex#L6.

If we have elixir expose it's terminal markdown renderer (IO.ANSI.Docs) as public API we can even pretty print it.

how should we handle errors? Should we retry?

I think the caller should handle errors.

@@ -0,0 +1,130 @@
defmodule Mix.Tasks.Hex.Docs.Search do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this task fit better under the existing mix hex.seach task? Less pollution of the task namespace.

Copy link
Member

@zachdaniel we now have the new mix hex.search: #1094 My suggestion is to add something like mix hex.search --docs "foo" and by default it searches within the given project. It should print to the terminal. We can add --format json later.

ericmj and Ch4s3 reacted with thumbs up emoji

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

Reviewers

@ericmj ericmj ericmj left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /