Documenting code for thesis
As Nate Eldredge has already mentioned, you should check your university's thesis guide if there is anything specific about code. If not, contact your thesis/dissertation office to see if they can help out.

I'll now speak from my own experience working at my university. I suggest to students that code be placed in the appendix material. Why? So it doesn't clutter the body.

If you're writing in LaTeX, be sure to read the documentation of any package you use to import your code. If you wish to leave it as a link, be sure to follow your university's instructions on that.