DOC: remove usage of code-block directive in docstrings + fix some warnings

Some docs things:

- remove remaining use of `code-block`, closes #3430 (@y-p, I think that were the last ones, so now it can be really closed)
- fix some headers to avoid useless warnings during doc build (if the line under the header is not as long as the header itself, sphinx complains about it although it renders fine)