Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to write document for defp function?

when adding document to private function by @doc, in vscode compiler gives the warning message.

I can’t find @docp for @doc.

defp check_subscript!/3 is private, @doc attribute is always discarded for private functions/macros/typesElixir

function is as follows:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

@doc """
  check subscript decreasing or increasing
  """
  defp check_subscript!(x, x1, x2)
       when x > x1 and x1 > x2 and
              is_integer(x) and is_integer(x1) and is_integer(x2) do
    :ok
  end

>Solution :

Here is the excerpt from Writing Documentation

Because private functions cannot be accessed externally, will warn if a private function has a @doc attribute and will discard its content. However, you can add code comments to private functions, as with any other piece of code, and we recommend developers to do so whenever they believe it will add relevant information to the readers and maintainers of such code.


That said, the comment for the private function would look like below.

  # check subscript decreasing or increasing
  defp check_subscript!(x, x1, x2) do
    :ok
  end
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading