 defmodule Tesla.Middleware.FormUrlencoded do
-  @doc """
+  @behaviour Tesla.Middleware
+
+  @moduledoc """
   Send request body as application/x-www-form-urlencoded
 
-  Example:
-      defmodule Myclient do
-        use Tesla
+  Longer description, including e.g. additional dependencies.
 
-        plug Tesla.Middleware.FormUrlencoded
-      end
 
-      Myclient.post("/url", %{key: :value})
+  ### Example usage
+  ```
+  defmodule Myclient do
+    use Tesla
+
+    plug Tesla.Middleware.FormUrlencoded
+  end
+
+  Myclient.post("/url", %{key: :value})
+  ```
   """
+
   def call(env, next, opts) do
     opts = opts || []
 

    |> Tesla.run(next)
  end

  def encode(env, opts) do
    if encodable?(env) do
      env
      |> Map.update!(:body, &encode_body(&1, opts))


  defp encode_body(body, _opts), do: do_process(body)

  defp encodable?(%{body: nil}),                 do: false
  defp encodable?(%{body: %Tesla.Multipart{}}),  do: false
  defp encodable?(_),                            do: true

  defp do_process(data) do
    URI.encode_query(data)
