Update documentation for custom target dependencies.
Closes #7613.
The old documentation was wrong, and hasn't worked for some time. It needs to be the file stem (see issue for discussion).
I also added a test, since I couldn't find any. It was remarkably awkward to add the test without build-std, so I just added it to a build-std test.