Doc resource refactor

This is required to "rebase" #194.

Please make sure to get #306 in first, so we can see if this passes tests.
My preference would be ternary one-liners for `is_mongos`, `init_file_` and `mode`