mirror of
https://github.com/enso-org/enso.git
synced 2024-11-23 08:08:34 +03:00
Create documentation generator websocket wrapper (#1017)
This commit is contained in:
parent
30d136a141
commit
157582b81e
@ -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")
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -313,6 +313,9 @@ li
|
||||
margin: 2px 0 0 auto
|
||||
padding: 0
|
||||
|
||||
.DefNoDoc
|
||||
padding-bottom: 10px
|
||||
|
||||
.DefTitle
|
||||
display: inline-flex
|
||||
font-size: x-large
|
||||
|
Loading…
Reference in New Issue
Block a user