Building the documentation of risklib and some refactoring

This is propedeutic to the course "how to build risk calculators with commonlib". The tests are green: https://ci.openquake.org/job/zdevel_oq-risklib/51/
Please add a docstring