Better handling of Doc comment protection based on Doc settings

Fixes #405