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
Fix broken Scaladoc external Java references #8647
Conversation
The problem was that PlainNioFile.underlyingSource was expanding "/modules/java.base" into a full path, where as the lookup in findExternalLink was using relative paths ("/modules/java.base.jmod")
Is this a fix for scala/bug#11839? |
This change breaks the example REPL session Jason posted in #7782. I'm on Mac OSX and using Java 11.0.2.
|
OK, I can take a look. Do we have integration tests? That would help immensely |
Yes, sorry. I couldn't find instructions for linking |
Edited the PR description - have a look.
Does this need an "integration test"? I think it's just a smoke test on part of the API using a known given like |
I'm a newbie and don't know how you do things. In standard testing ideology, underlyingSource would need to be mocked in a unit test. We need to test how underlyingSource interacts with the code in findExternalLink. I can certainly just bang it into a unit test if that is OK. |
Ideally, there would have been a test added in #7782. Unfortunately, there isn't any infrastructure for JDK11 tests, yet. It would be nice if there was a JDK11 section of the |
Ah, right. No, I guess I meant a "functional test" (so, without any mocking, sometimes some setting overrides, and without integrating with anything external and without any mocking). So within https://github.com/scala/scala/tree/2.13.x/test/junit/scala/tools/nsc somewhere, I would think. |
We're getting off-topic. Reviewing this fix requires someone who is an expert with both Java 11 module support and with Scaladoc. |
Given that behaviour should be true on all versions, I was thinking just with JUnit, and I think we must have the tests running on JDK 11 somewhere, right? |
It isn't. For Java 8, it's |
In either case |
Yes, but I only tested on Java 11, and I don't know a lot about #7782 or the check Jason wrote. |
In order to fix this problem, I will have to go back to using absolute paths, which causes problems elsewhere. I can hack findExternalLink to use absolute paths everywhere, but I suspect something else will break, and we have insufficient tests. I need that Java11 / Scaladoc expert to chime in here... |
👋 Thanks for contributing a fix here. I'll see if I can help reconcile different uses of First of all, I was curious how Javadoc users deal with external links into Java SDK API docs. Looks like the Maven Javadoc plugin has is clever enough to automatically configure the base URL of the SDK docs and also ships with config files (example) that map packages (e.g. Okay, as to testing, we do have functional tests that exercise external links in Scaladoc, such as https://github.com/scala/scala/blob/2.13.x/test/scaladoc/run/t191.scala. That seems focused on linking to the Scala SDK docs. But it could be extended or duplicated to test linking to Java SDK docs. Our CI builds currently do not run on a multiple versions of Java. We'll add Java 11 to the mix soon. Tests that are Java version dependent (ie, should only run on Java 9+, or have assert different things on different Java versions) can be usually be expressed by adding logic to the test. You can then at least run the test manually on Java 11 on your workstation, even though CI won't exercise those paths.
But I didn't consider that this path would need to be exposed to Scaladoc users trying valiantly to configure external URL mappings. The prior answer of "/modules/java.base" was a bit nicer still somewhat confusing to Scaladoc users IMO as it looks like an on-disk path that doesn't actually exist. How about we add a new Scaladoc option
It could then detect the JPMS module of the symbol (I can help with the details of this) and construct the correct URL from the base. WDYT? |
You are the expert, it sounds reasonable, but I'm fuzzy on all the details. Thanks for pointing out the test, I overlooked that somehow when poking around in the tests dir. |
A few nitpicks; the existing scaladoc options seem to use single dash, rather than double. So should the option be: The java API doc URL could theoretically be hardcoded; however the pattern above only works with Java version 11 and up:
For earlier Java versions, this seems to be correct:
|
The current proposal by Jason for |
new PR is #8663 and is ready for review |
The problem was that PlainNioFile.underlyingSource was expanding "/modules/java.base" into a full path, where as the lookup in findExternalLink was using relative paths ("/modules/java.base.jmod")
Fixes scala/bug#11839
Supersedes #8647