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
Add protected and private visibility filters to scaladoc #8183
Conversation
Travis passed successfully, but checks on GitHub are not updated... Could someone rerun Travis or perform something to resolve checks? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're now adding scaladocs for all private members, the doc size and the time to run scaladoc might grow significanlty.
Could you compare the scaladocs (size, time to generate) for the library and compiler, so we have an idea about the impact?
@@ -1018,7 +1018,9 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { | |||
aSym.info.members.exists(s => localShouldDocument(s) && (!s.isConstructor || s.owner == aSym)) | |||
|
|||
def localShouldDocument(aSym: Symbol): Boolean = | |||
!aSym.isPrivate && (aSym.isProtected || aSym.privateWithin == NoSymbol) && !aSym.isSynthetic | |||
((aSym.isPrivate && !aSym.isTopLevel) || | |||
(!aSym.isPrivate && (aSym.isProtected || aSym.privateWithin == NoSymbol))) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what the privateWithin
check is for, can we remove it? As far as I know, privateWithin
can be set in private[x]
and protected[x]
. The line excludes any private, and includes any protected, so the privateWithin
seems useless, no? Maybe just try if all tests pass if you remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, removing aSym.privateWithin == NoSymbol
breaks the following tests.
(I have not investigated fully why broken)
[info] Elapsed time: 0.045 sec
[info] ! HtmlFactory.scala/bug#8144: Members' permalink - inner package: Falsified after 0 passed tests.
[info] Elapsed time: 0.000 sec
[info] ! HtmlFactory.scala/bug#8144: Members' permalink - companion object: Falsified after 0 passed tests.
[info] Elapsed time: 0.001 sec
[info] ! HtmlFactory.scala/bug#8144: Members' permalink - class: Falsified after 0 passed tests.
[info] Elapsed time: 0.000 sec
[info] ! HtmlFactory.scala/bug#9599 Multiple @todo formatted with comma on separate line: Falsified after 0 passed tests.
[info] Elapsed time: 0.063 sec
[info] ! HtmlFactory.scala/bug#10999 Private and Protected method should also be documented: Falsified after 0 passed tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I was not very clear.. I pushed a change that simplifies localShouldDocument
, hopefully that passes the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, here is my misunderstanding:
class C {
private def a
private[C] def b
protected def c
protected[C] def d
}
We get
isPrivate | isProtected | privateWithin | |
---|---|---|---|
a | true | false | NoSymbol |
b | false | false | C |
c | false | true | NoSymbol |
d | false | true | C |
Note that for b
, isPrivate
is false, but for d
, isProtected
is true.
This comment has been minimized.
This comment has been minimized.
Summary (see below comparison for detail)
Ofcourse these varies depending on how many Scala Librarymkdir docs
cd docs
time ../build/pack/bin/scaladoc ../src/library/**/*.scala
du -K scala/
Scala Compilermkdir docs
cd docs
time ../build/pack/bin/scaladoc ../src/compiler/**/*.scala
du -K scala/
|
Thank you for gathering these numbers. I think we should keep this PR open for discussion. Personally I don't see a good use case for listing private members in Scaladocs, so I'm not in favor. How about introducing a scaladoc option, e.g., |
is there a precedent, one way or the other, in Javadoc? |
Javadoc can specify members to be included via the switch
You can find switches via |
Some test (
|
I'll take a look |
@exoego a |
@exoego let us know if you still have time to work on this one! |
@lrytz Added |
d36204c
to
ccdb4dd
Compare
c523e16
to
cafd5b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @exoego!
Closes scala/bug#10999
This PR adds
Protected
andPrivate
visiblity filters.Private
filter is available only ifscaladoc -private
used, so user can omit private members to reduce scaladoc size.Existing
All
is removed since it is no longer required.