Open OndrejSpanel opened 3 months ago
What is the definition of Main
?
Added. Getting docstring of Main
works fine from main
sources, not from test
.
Complete project is linked in the issue, as well as the workflow output demonstrating the failure.
It seems that we are not loading the docstrings from TASTy. This can be enabled with -Yread-docs
, but users should not use that. The ContextDocstrings
should be able to load documentation on demand.
Glad to hear you are making progress on this.
What is the difference between loading main and test docstrings from test? Because main from main works, as well as test from test. Are they read from other place than TASTy in such case?
What is the difference between loading main and test docstrings from test? Because main from main works, as well as test from test. Are they read from other place than TASTy in such case?
In that case, they come directly from the parsed source file. You may also be missing the documentation if there is an incremental compilation and part of the files are related from TASTy from the previous compilation.
The same issue happens when reading ScalaDoc from other modules, which given the issue cause is understandable. The workaround in this case is to use scalacOptions += "-Yread-docs"
in the module reading the docs.
Using Symbol.docstring from tests to inspect types defined in main always returns
None
.Compiler version
3.3.3 3.4.1
Minimized code
https://github.com/OndrejSpanel/Scala3-DocStringInTest
main:
test:
Use
Test/run
to run the code.Output
Workflow output:
Note: while test can access values of
docstring
defined in test. it cannot access anydocstring
defined in main, it always getsNone
.Expectation
The
docstring
values of symbols defined in the main should be available from tests.