Remove Phoenix functions from ExDoc View pages?

ExDoc adds documentation for several Phoenix functions to each of my View pages:

  • __phoenix_recompile__?()
  • __resource__()
  • __templates__()
  • render(template, assigns \\ %{})
  • template_not_found(template, assigns)

These entries (and their index entries) are basically noise, from my point of view. I suspect that they are being brought in via a use statement; is there a way to remove them?

Phoenix would probably accept a PR that added @doc false above them. Without that I don’t know of a way to remove them.

1 Like

The template.ex and view.ex files already contain @doc entries for these functions. Because they are located inside macros, they get brought in by use statements. However, the code is beyond my pay grade to modify:

defmodule Phoenix.Template do
  ...
  @doc false
  defmacro __before_compile__(env) do
    ...
    quote do
      ...
      @doc """
      Returns the template root alongside all templates.
      """
      def __templates__ do
        {@phoenix_root, @phoenix_pattern, unquote(names)}
      end
    ...
    end

It’s also possible that someone wants these functions to be documented in every View. So, before I even post an issue, I’d like to get a bit more feedback. (ducks)

1 Like

Try to add an empty head before the use, eg:

@doc false
def __phenix_recompile__?()
use Phoenix.Template

I have not tested it but might work.

I’m afraid I don’t understand how to implement this suggestion. It sounds like I would need to put five sets of @doc false and def foo() statements before the use PhxHttpWeb, :view line in each of my View files.

Even if this worked, it would not be pretty, though I suppose I could create a file that encapsulated all of the fugliness and invoke it with another use statement. Did you have something like this in mind?

You could put those in the view function of PhxHttpWeb as well. Assuming that technique works at all…

Anyway, personally I consider those entries a bug. At least the underscored ones look like implementation details…

I personally like everything being documented that is publicly accessible and called. ^.^
Even if it’s first line is “INTERNAL USE ONLY”, it should still be documented as to what it takes and does and all.

1 Like
3 Likes