Skip to content

Using filter_modules doesn't produce warning referencing hidden or private docs #1744

Closed
@WojciechBarczynski

Description

@WojciechBarczynski

Using filter_modules in the mix.exs doesn't produce warnings indicating undocumented code reference.

Using @moduledoc false:

  1. Code:
defmodule Foo do
  @moduledoc false
  # "Private" module

  @type foo :: integer()
end


defmodule Bar do
  @moduledoc """
  "Public" module
  """
  alias Foo

  @spec bar(Foo.foo()) :: nil
  def bar(num) do
    IO.inspect(num)
    nil
  end
end
  1. Generates warring while trying to generate docs to notify users, that they are using type reference unavailable in the documentation:
$ mix docs
Generating docs...
warning: documentation references type "Foo.foo()" but it is hidden or private
  lib/membrane_template.ex:16: Bar.bar/1

View "html" docs at "doc/index.html"

Using filter_modules:

  1. mix.exs
defmodule Mixfile do
  use Mix.Project

  def project do
    [
...
      # docs
      name: "Example",
      source_url: @github_url,
      docs: docs()
    ]
  end

...

  defp docs do
    [
      main: "readme",
      extras: ["README.md", "LICENSE"],
      formatters: ["html"],
      source_ref: "v#{@version}",
      filter_modules: ~r/Bar/,
    ]
  end
end
  1. Code
defmodule Foo do
  @moduledoc """
  "Private" module excluded with `filter_modules`
  """

  @type foo :: integer()
end


defmodule Bar do
  @moduledoc """
  "Public" module
  """
  alias Foo

  @spec bar(Foo.foo()) :: nil
  def bar(num) do
    IO.inspect(num)
    nil
  end
end
  1. Doesn't generate any warring, despite Foo.foo() being unavailable in docs
$ mix docs       
Generating docs...
View "html" docs at "doc/index.html"
  1. Generated docs with Foo.foo() reference:
Screenshot 2023-07-27 at 11 49 43

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions