doc: fix inconsistencies in code examples
This is essentially the same as my other pull request with a few more additions. Sorry about opening multiple, I somehow really messed it with the rebasing there so I closed it.
Checklist
-
documentation is changed or added -
commit message follows commit guidelines
Affected core subsystem(s)
doc
Description of change
Added missing semicolons, braces, and fixed indentation.