Create documentation generator websocket wrapper (#1017)

This commit is contained in:
Maciej Mikołajek 2020-07-20 15:05:27 +02:00 committed by GitHub
parent 30d136a141
commit 157582b81e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 4 deletions

View File

@ -4,9 +4,13 @@ import io.circe.Json
import org.enso.flexer.Reader
import org.enso.parserservice.Protocol
import org.enso.parserservice.Server
import org.enso.syntax.text.AST
import org.enso.syntax.text.SourceFile
import org.enso.syntax.text.Parser
import org.enso.syntax.text.{
AST,
DocParserHTMLGenerator,
DocParserRunner,
Parser,
SourceFile
}
import scala.util.Try
@ -45,6 +49,13 @@ case class ParserService() extends Server with Protocol {
case ParseRequestWithMetadata(content) =>
val module = new Parser().runWithMetadata(content)
Protocol.Success(module)
case DocParserGenerateHtmlSource(program) =>
val parser = new Parser()
val module = parser.run(program)
val dropMeta = parser.dropMacroMeta(module)
val doc = DocParserRunner.createDocs(dropMeta)
val code = DocParserHTMLGenerator.generateHTMLForEveryDocumented(doc)
Protocol.SuccessDoc(code)
case _ =>
throw new Exception(f"unimplemented request: $request")
}

View File

@ -14,11 +14,13 @@ object Protocol {
sealed trait Request
final case class ParseRequest(program: String, ids: Parser.IDMap)
extends Request
final case class ParseRequestWithMetadata(content: String) extends Request
final case class ParseRequestWithMetadata(content: String) extends Request
final case class DocParserGenerateHtmlSource(program: String) extends Request
sealed trait Response
final case class Success(module: SourceFile) extends Response
final case class Error(message: String) extends Response
final case class SuccessDoc(code: String) extends Response
}
/** Helper for implementing protocol over text-based transport.

View File

@ -313,6 +313,9 @@ li
margin: 2px 0 0 auto
padding: 0
.DefNoDoc
padding-bottom: 10px
.DefTitle
display: inline-flex
font-size: x-large