code is a reStructuredText directive. code-block is a Sphinx directive.
code-block has a different set of parameters for the code directive. For instance. :emphasize-lines:
Since you are using Sphinx, I would recommend using the code-block directive.
When using code-block I always get the correct selection. When using code I sometimes get colors, and sometimes just alphabetic code blocks. I have yet to figure out which combinations of settings in conf.py that predictably generate color output.
The code directive has the advantage that the document can be used both in the Sphinx document tree and in the stand-alone reStructuredText document.
source share