DocBook has its nice environment for Python/C/whateverlanguage code chunks.
Code chunks, like float figures must have a caption and must be referenced in the text.