Many languages support documentation comments to allow a generator (like javadoc or doxygen) to generate code documentation by parsing that sam
javadoc
If you're only using Swift then Jazzy is worth looking at.
https://github.com/realm/jazzy