You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by md...@apache.org on 2022/11/18 07:30:36 UTC

[incubator-pekko-http] 04/04: Fix paradox issues caused by scalafmt

This is an automated email from the ASF dual-hosted git repository.

mdedetrich pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-http.git

commit 664f044d77b3f96204a8a7ec4e96a4a272ca1752
Author: Matthew de Detrich <ma...@aiven.io>
AuthorDate: Mon Nov 14 11:49:20 2022 +0100

    Fix paradox issues caused by scalafmt
---
 project/ParadoxSupport.scala | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/project/ParadoxSupport.scala b/project/ParadoxSupport.scala
index d114d9432..639425668 100644
--- a/project/ParadoxSupport.scala
+++ b/project/ParadoxSupport.scala
@@ -31,15 +31,28 @@ object ParadoxSupport {
           case _                                   => sys.error("Source references are not supported")
         }
         val file = SourceDirective.resolveFile("signature", source, page.file, variables)
-        val Signature = """\s*((def|val|type) (\w+)(?=[:(\[]).*)(\s+\=.*)""".r // stupid approximation to match a signature
+
+        // The following are stupid approximation's to match a signature/s
+        val TypeSignature = """\s*(type (\w+)(?=[:(\[]).*)(\s+\=.*)""".r
         // println(s"Looking for signature regex '$Signature'")
-        val text =
-          Source.fromFile(file)(Codec.UTF8).getLines.collect {
-            case line @ Signature(signature, kind, l, definition) if labels contains l.toLowerCase() =>
-              // println(s"Found label '$l' with sig '$full' in line $line")
-              if (kind == "type") signature + definition
-              else signature
-          }.mkString("\n")
+        val lines = Source.fromFile(file)(Codec.UTF8).getLines.toList
+
+        val types = lines.collect {
+          case line @ TypeSignature(signature, l, definition) if labels contains l.toLowerCase() =>
+            // println(s"Found label '$l' with sig '$full' in line $line")
+            signature + definition
+        }
+
+        val Signature = """.*((def|val) (\w+)(?=[:(\[]).*)""".r
+
+        val other = lines.mkString.split("=").collect {
+          case line @ Signature(signature, kind, l) if labels contains l.toLowerCase() =>
+            // println(s"Found label '$l' with sig '$full' in line $line")
+            signature
+              .replaceAll("""\s{2,}""", " ") // Due to formatting with new lines its possible to have excessive whitespace
+        }
+
+        val text = (types ++ other).mkString("\n")
 
         if (text.trim.isEmpty) {
           ctx.error(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org