Replace docs with mdoc#766
Conversation
|
Running |
|
We now have our first runnable demo! Things to do
|
|
So the current websocket demo that's commented out, makes mdoc crash with the following: info: Compiling 1 file to /home/rishi/dev/scala/scala-js-dom/mdocs/target/mdoc
error:
Could not generate function for JS function: Found a non-private field value input$3 in final <synthetic> class anonfun$echoWebSocket$1$2 extends scala.scalajs.js.Function with scala.scalajs.js.Function1 {
final def apply(arg1: org.scalajs.dom.Event): Unit = anonfun$echoWebSocket$1$2.this.input$3.onkeyup_=({
(new <$anon: scala.scalajs.js.Function with scala.scalajs.js.Function1>(anonfun$echoWebSocket$1$2.this): scala.scalajs.js.Function1)
});
final <bridge> <artifact> def apply(arg1: Object): Object = {
anonfun$echoWebSocket$1$2.this.apply(arg1.$asInstanceOf[org.scalajs.dom.Event]());
scala.runtime.BoxedUnit.UNIT
};
<synthetic> <paramaccessor> val input$3: org.scalajs.dom.HTMLInputElement = _;
<synthetic> <paramaccessor> val socket$1: org.scalajs.dom.WebSocket = _;
def <init>(input$3: org.scalajs.dom.HTMLInputElement, socket$1: org.scalajs.dom.WebSocket): <$anon: scala.scalajs.js.Function with scala.scalajs.js.Function1> = {
anonfun$echoWebSocket$1$2.this.input$3 = input$3;
anonfun$echoWebSocket$1$2.this.socket$1 = socket$1;
anonfun$echoWebSocket$1$2.super.<init>(scala.collection.immutable.Nil);
()
}
}
while compiling: readme.md
during phase: jscode
library version: version 2.13.6
compiler version: version 2.13.6
reconstructed args: -deprecation -feature -unchecked -Wconf:cat=feature:w -Wconf:cat=deprecation:w -Wconf:cat=unchecked:w -Wconf:cat=deprecation:w -Wconf:cat=deprecation:ws -Wconf:cat=feature:ws -Wconf:cat=optimizer:ws -Wunused:imports -Wunused:patvars -Wunused:locals -Wunused:implicits -classpath /home/rishi/dev/scala/scala-js-dom/mdocs-js/target/scala-2.13/classes:/home/rishi/dev/scala/scala-js-dom/dom/target/scala-2.13/classes:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.6/scala-library-2.13.6.jar:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.13/1.7.1/scalajs-library_2.13-1.7.1.jar -Xmaxerrs -1 -Xmaxwarns -1 -Xplugin:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-compiler_2.13.6/1.7.1/scalajs-compiler_2.13.6-1.7.1.jar -Xplugin:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scalameta/semanticdb-scalac_2.13.6/4.6.0/semanticdb-scalac_2.13.6-4.6.0.jar -Yrangepos -Ydelambdafy:inline -P:semanticdb:targetroot:/home/rishi/dev/scala/scala-js-dom/mdocs-js/target/scala-2.13/meta
last tree to typer: TypeTree(class Event)
tree position: line 140 of readme.md
tree tpe: org.scalajs.dom.Event
symbol: class Event in package dom
symbol definition: class Event extends Object (a ClassSymbol)
symbol package: org.scalajs.dom
symbol owners: class Event
call site: <$anon: scala.scalajs.js.Function with scala.scalajs.js.Function1> in package <empty>
== Source file context for tree position ==
137 }
138 @_root_.scala.scalajs.js.annotation.JSExportTopLevel("mdoc_js_run13")
139 def run13(node: _root_.org.scalajs.dom.html.Element): Unit = {
140 document.getElementById("demo7-btn").addEventListener("click", (ev: Event) => {
141 changeColor(document.getElementById("demo7-text").asInstanceOf[html.Div])
142 })
143 }
error: Error while emitting readme.md
Could not generate function for JS function: Found a non-private field value input$3 in final <synthetic> class anonfun$echoWebSocket$1$2 extends scala.scalajs.js.Function with scala.scalajs.js.Function1 {
final def apply(arg1: org.scalajs.dom.Event): Unit = anonfun$echoWebSocket$1$2.this.input$3.onkeyup_=({
(new <$anon: scala.scalajs.js.Function with scala.scalajs.js.Function1>(anonfun$echoWebSocket$1$2.this): scala.scalajs.js.Function1)
});
final <bridge> <artifact> def apply(arg1: Object): Object = {
anonfun$echoWebSocket$1$2.this.apply(arg1.$asInstanceOf[org.scalajs.dom.Event]());
scala.runtime.BoxedUnit.UNIT
};
<synthetic> <paramaccessor> val input$3: org.scalajs.dom.HTMLInputElement = _;
<synthetic> <paramaccessor> val socket$1: org.scalajs.dom.WebSocket = _;
def <init>(input$3: org.scalajs.dom.HTMLInputElement, socket$1: org.scalajs.dom.WebSocket): <$anon: scala.scalajs.js.Function with scala.scalajs.js.Function1> = {
anonfun$echoWebSocket$1$2.this.input$3 = input$3;
anonfun$echoWebSocket$1$2.this.socket$1 = socket$1;
anonfun$echoWebSocket$1$2.super.<init>(scala.collection.immutable.Nil);
()
}
}
while compiling: readme.md
during phase: jscode
library version: version 2.13.6
compiler version: version 2.13.6
reconstructed args: -deprecation -feature -unchecked -Wconf:cat=feature:w -Wconf:cat=deprecation:w -Wconf:cat=unchecked:w -Wconf:cat=deprecation:w -Wconf:cat=deprecation:ws -Wconf:cat=feature:ws -Wconf:cat=optimizer:ws -Wunused:imports -Wunused:patvars -Wunused:locals -Wunused:implicits -classpath /home/rishi/dev/scala/scala-js-dom/mdocs-js/target/scala-2.13/classes:/home/rishi/dev/scala/scala-js-dom/dom/target/scala-2.13/classes:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.6/scala-library-2.13.6.jar:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-library_2.13/1.7.1/scalajs-library_2.13-1.7.1.jar -Xmaxerrs -1 -Xmaxwarns -1 -Xplugin:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-js/scalajs-compiler_2.13.6/1.7.1/scalajs-compiler_2.13.6-1.7.1.jar -Xplugin:/home/rishi/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scalameta/semanticdb-scalac_2.13.6/4.6.0/semanticdb-scalac_2.13.6-4.6.0.jar -Yrangepos -Ydelambdafy:inline -P:semanticdb:targetroot:/home/rishi/dev/scala/scala-js-dom/mdocs-js/target/scala-2.13/meta
last tree to typer: TypeTree(class Event)
tree position: line 140 of readme.md
tree tpe: org.scalajs.dom.Event
symbol: class Event in package dom
symbol definition: class Event extends Object (a ClassSymbol)
symbol package: org.scalajs.dom
symbol owners: class Event
call site: <$anon: scala.scalajs.js.Function with scala.scalajs.js.Function1> in package <empty>
== Source file context for tree position ==
137 }
138 @_root_.scala.scalajs.js.annotation.JSExportTopLevel("mdoc_js_run13")
139 def run13(node: _root_.org.scalajs.dom.html.Element): Unit = {
140 document.getElementById("demo7-btn").addEventListener("click", (ev: Event) => {
141 changeColor(document.getElementById("demo7-text").asInstanceOf[html.Div])
142 })
143 }
warning: readme.md:198:1: local method echoWebSocket in method run11 is never used
def echoWebSocket(input: html.Input, pre: html.Pre) = { |
|
Is that reproducible outside of mdoc? |
I don't think so: I tried the following: //> using platform "scala-js"
//> using scala "3.2.2"
//> using dep "org.scala-js::scalajs-dom::2.4.0"
import org.scalajs.dom.*
@main def echo() =
val echo = "wss://echo.websocket.org"
val socket = new WebSocket(echo)
socket.onmessage = (e: MessageEvent) => println(e.data.toString)
socket.onopen = (e: Event) => println("Connected")
And it compiles fine |
|
It seems to be an mdoc thing: This works: def addInput(input: html.Input, socket: WebSocket) = {
input.onkeyup = (e: Event) => socket.send(input.value)
}
def echoWebSocket(input: html.Input, pre: html.Pre) = {
val echo = "wss://echo.websocket.org"
val socket = new WebSocket(echo)
socket.onmessage = {
(e: MessageEvent) =>
pre.textContent +=
e.data.toString
}
socket.onopen = (e: Event) => addInput(input, socket)
}But this doesn't work(notice that everything in def echoWebSocket(input: html.Input, pre: html.Pre) = {
val echo = "wss://echo.websocket.org"
val socket = new WebSocket(echo)
socket.onmessage = {
(e: MessageEvent) =>
pre.textContent +=
e.data.toString
}
socket.onopen = { (e: Event) =>
input.addEventListener("onkeyup", { (e: Event) =>
socket.send(input.value)
})
}
}EDIT: will try to report this to mdoc with an easier to follow example :P |
|
@armanbilge Things to do:
|
there's a new one from postman you can use, see https://http4s.github.io/http4s-dom/websocket.html I can look into CI deploy and styling :) Thanks for all your work on this!! |
Actually I found that one in my quest for example servers, but it didn't work for me, it gave back a 101 switching protocols. |
armanbilge
left a comment
There was a problem hiding this comment.
These look great! Thank you so much for porting them to mdoc :) only a few minor quips about if we need "run" buttons for some of the examples, I wonder if they could be active on page load.
Regarding deployment, here's what I'm thinking.
I think it would be nice if we could adopt the scala-js.org design/theme for the scala-js-dom website. That site is rendered with Jekyll so it will work well with our mdoc.js + GH pages setup. Instead of copying the theming, we can "fork" it as the gh-pages branch on this repo and customize to our needs. Then, if there are updates to the design/theme upstream, we can merge them into our branch.
One other idea I had along these lines, is that we can deploy the rendered markdown and JS to a branch on this repo. Then the scala-js-website repo could include that as git submodule, so it's deployed as part of the scala-js.org site. We can setup dependabot to automatically open PRs on scala-js-website when there are changes to the site here. Depends what @sjrd thinks of this, of course :)
Thoughts?
What is supposed to be the benefit of publishing inside |
Well, depends who you ask :) The only "infrastructure" I'm proposing is (1) a git submodule and (2) ~ 3 lines of dependabot YAML. The alternative is that we maintain all the "infrastructure" to configure and deploy a fully-styled site from this repository. In comparison it seems like a lot more work, at least to me! |
|
Yea I was also unsure about the run buttons, but since the current docs has them, I didn't even think about just removing them lol. As for the infrastructure, at first the git submodule sounded like a lot of things as well, because well, weaving in a git submodule into another repo sounds like a lot of work. But reading your explanation it does sound like less work? Handling all the infra here does seem like starting from scratch. |
Then we add a dependabot config like this: All this would be doing is placing the |
|
I opened a PR against scala-js-website showing how my proposal would work. |
That does look quite simple, nice! Let's see if sjrd agrees :P |
|
@sjrd polite bump? :) |
| - dom.css: CSS APIs | ||
| - dom: Miscellanious, unclassified APIs | ||
|
|
||
| Most names have been shortened from names of the raw browser APIs, since the namespacing avoids collisions. By convention these types are imported qualified: e.g. as `html.Canvas` instead of directly as `Canvas`. There is also the `dom.raw` namespace which contains everything with their full, un-shortened name. |
There was a problem hiding this comment.
This section is outdated now. We put everything back into dom and dom.raw was deprecated.
| Def.taskDyn { | ||
| if (scalaVersion.value.startsWith("2.12.")) | ||
| Def.task[Unit]((readme / Compile / compile).value) | ||
| // TODO should this really be docs / Compile? |
There was a problem hiding this comment.
I actually don't know if the current docs / Compile / compile is the right command to run during prePR.
@armanbilge does:
Def.task[Unit]((docs / Compile / compile).value)
work fine here?
There was a problem hiding this comment.
I need to take another look at this. I was hoping we could decide how we are deploying the site so we can figure out what to do with the build :)
Co-authored-by: Sébastien Doeraene <sjrdoeraene@gmail.com>
Co-authored-by: Sébastien Doeraene <sjrdoeraene@gmail.com>
|
I read this discussion, and felt sad that it stalled. I think I understand why. With only a surface understanding of the issues: could it be feasible to switch the direction of sub-moduleisation and have the scala-js site as a sub-module of a scala-js-dom ? That way you might still get the styling free. |
Improves and replaces #741