yard
yard copied to clipboard
Indication to identify protected and private methods
--protected and --private of yard doc show protected and private methods on the documentation.
But once you have enabled them, you have public, protected and privates methods all mixed without a way to know which is what.
It would be nice to have a little badge next to protected and private methods to allow to identify them.
Expected result
Something like that


It doesn't seem like your methods are correctly being detected as private/protected, YARD should already be showing these tags. This is the output for the following minimal repro:
class A
protected
def a; end
def b; end
private
def c; end
def d; end
end

Yes I can see the CSS public class set on each <li>. I also see that without --protected or --private my method still appears in yard.
I didn't use the following syntax:
class A
protected
def a; end
def b; end
private
def c; end
def d; end
end
but instead this one:
class A
def a; end
def b; end
def c; end
def d; end
protected :a, :b
private :c, :d
end
Which is valid ruby and totally works as expected

Also I don't know if it matters but I'm in class << self because class << self + private is similar to private_class_method and I saw there #1162 yard had issues with inline private_class_method but you said as a workaround that private_class_method was working with yard if used in a separate line. this may be different and #1162 is from 2018 but I mention it as it may lead somewhere.
So I have
class A
class << self
def a; end
def b; end
def c; end
def d; end
protected :a, :b
private :c, :d
end
end
I just tried
class A
class << self
def a; end
def b; end
protected
def c; end
def d; end
end
end
Only a & b are show (which confirms that the alternative syntax shown earlier is not supported by yard) but even using the "classic" syntax seems to be bugged inside class methods but adding --protected never show the methods c & d.
It seems that whatever the syntax is potected_class_method or class << self + "section" protected or class << self + protected c:, d: yard has an issue with class methods that doesn't appears with instance methods.
Now if I tried to add the visibility and scope tags as a workaround, it hides the method even when --protected is provided to yard doc.
# @!scope class
# @!visibility protected
I'm digging some old maybe related issues #847, #760, #551 (I stopped after because it was getting too old)
I'll me my repository public soon so you can see the real code.
Source: https://github.com/sec-it/pass-station Yard doc: https://sec-it.github.io/pass-station/yard/PassStation.html
@lsegal I can confirms that protected badge is displayed only for instance methods and not for class methods.