Skip to content

Fix documentation retrieval for callbacks#60

Open
icostan wants to merge 2 commits intoash-project:mainfrom
icostan:fix-docs-callback-detection
Open

Fix documentation retrieval for callbacks#60
icostan wants to merge 2 commits intoash-project:mainfrom
icostan:fix-docs-callback-detection

Conversation

@icostan
Copy link

@icostan icostan commented Mar 14, 2026

Current mix usage_rules.docs does not return doc for callback, it only works for module/function using the IEx.Helpers.h/1 function.

usage_rules % mix usage_rules.docs GenServer.handle_call                                             [0]
Compiling 1 file (.ex)
Generated usage_rules app
Searching local docs for 

    GenServer.handle_call

Use `mix usage_rules.search_docs` to search online documentation for more results.


No documentation for function GenServer.handle_call was found, but there is a callback with the same name.
You can view callback documentation with the b/1 helper.

This PR:

  • Improve callback detection in usage_rules.docs task using robust regex
  • Add comprehensive tests for the docs task covering modules, functions, and callbacks
usage_rules % mix usage_rules.docs GenServer.handle_call                                             [3]
Searching local docs for 

    GenServer.handle_call

Use `mix usage_rules.search_docs` to search online documentation for more results.


@callback handle_call(request :: term(), from(), state :: term()) ::
            {:reply, reply, new_state}
            | {:reply, reply, new_state,
               timeout() | :hibernate | {:continue, continue_arg :: term()}}
            | {:noreply, new_state}
            | {:noreply, new_state,
               timeout() | :hibernate | {:continue, continue_arg :: term()}}
            | {:stop, reason, reply, new_state}
            | {:stop, reason, new_state}
          when reply: term(), new_state: term(), reason: term()

Invoked to handle synchronous call/3 messages. call/3 will block until a reply
is received (unless the call times out or nodes are disconnected).

request is the request message sent by a call/3, from is a 2-tuple containing
the caller's PID and a term that uniquely identifies the call, and state is the
current state of the GenServer.
...

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

The usage_rules.docs task failed to retrieve documentation for Elixir
callbacks. This fix adds a mechanism to detect callback hints from IEx
and use the b/1 helper for retrieval.

- Improve callback detection using a specific regex that includes the input name
- Add comprehensive tests for the docs task covering modules, functions, and callbacks
@icostan icostan force-pushed the fix-docs-callback-detection branch from b18429f to ed4f241 Compare March 15, 2026 09:38
@zachdaniel
Copy link
Contributor

Looks like tests failing/format failing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants