diff --git a/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala b/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala index ab2949112f..697745c4f1 100644 --- a/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala +++ b/zio-http/src/main/scala/zio/http/endpoint/Endpoint.scala @@ -29,6 +29,8 @@ import zio.http.Header.Accept.MediaTypeWithQFactor import zio.http._ import zio.http.codec.{HttpCodec, _} import zio.http.endpoint.Endpoint.{OutErrors, defaultMediaTypes} +import zio.http.endpoint.Endpoint.{EndpointDocs,_} + /** * An [[zio.http.endpoint.Endpoint]] represents an API endpoint for the HTTP diff --git a/zio-http/src/main/scala/zio/http/endpoint/EndpointDocs.scala b/zio-http/src/main/scala/zio/http/endpoint/EndpointDocs.scala new file mode 100644 index 0000000000..203daabce6 --- /dev/null +++ b/zio-http/src/main/scala/zio/http/endpoint/EndpointDocs.scala @@ -0,0 +1,20 @@ +// EndpointDocs.scala + +object EndpointDocs { + implicit class EndpointDocs(val sc: StringContext) extends AnyVal { + def doc(args: Any*): String = { + // Access the parts of the interpolated string + val parts = sc.parts.iterator + + // Combine the parts with the arguments to create the final documentation string + val result = new StringBuilder(parts.next()) + while (parts.hasNext) { + val arg = args(parts.nextIndex - 1).toString + result.append(arg).append(parts.next()) + } + + // Return the documentation string + result.toString() + } + } +}