Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scaladoc: javascript #21637

Open
Quafadas opened this issue Sep 24, 2024 · 1 comment
Open

scaladoc: javascript #21637

Quafadas opened this issue Sep 24, 2024 · 1 comment

Comments

@Quafadas
Copy link

Quafadas commented Sep 24, 2024

Compiler version

3.3.3

Minimized code

filename : js.md

<h1>Hello JS</h1>

<script type="text/javascript">
  console.log("boo")
</script>

In the "_docs" directory, of a static site, which will be part of a scaladoc static site.

Output

If you generate the site, serve it locally and navigate to the URL inhabited by this file (e.g. localhost:3000/docs/js.html), you'll see that the browser console has "boo" printed.

If you navigate to a different page on the sidebar (e.g. localhost:3000/docs/notjs.html), then navigate to localhost:3000/docs/js.html via the sidebar, no message will be printed. In other words, javascript doesn't fire if you arrive via the internal # routing.

This breaks my expectations, and I think it is awkward, because it works "the first time", but not subsequently, which is an awkward user / developer experience.

Expectation

I would expect javascript to run when navigating to the page. It is possible, that this is a legitimate design choice, but it feels odd, because it does work as expected, the first time.

I will note that I think there are legitimate uses for being able to run js on documentation pages. The examples which I'm interested in are;

  • plots (for example benchmarking)
  • documenting scalaJS projects

And I'm sure there are more. I'm reporting this as a bug, perhaps in ignorance - it could be intended behaviour.

Culprit

A discord discussion led us to believe the culprit is this;
https://discord.com/channels/632150470000902164/632150470000902166/1288100519029641289

image

@Quafadas Quafadas added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 24, 2024
@Quafadas
Copy link
Author

Thinking about this, if it is a bug, I think it's actually kind of a nasty one because the behaviour isn't obvious and it sucks a lot of time figuring out where the problem really lay.

I think this is the second hour or three spent checking my own stuff before starting to question scaladoc itself, and I ended up lucky to get some heavyweight help finding that loadPageState function.

@KacperFKorban KacperFKorban added area:doctool and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants