There have been a couple of tools that have attempted to automate this. A quick google for "automatic PSD to HTML" will turn up many. But almost all of them produce markup that is tightly dependent on the organization of the layers in the source document. Also the elements are usually absolutely positioned and the code in general needs a ton of work to get to a good shape.
There is no reason for this to be so. This can be automated - a developer should be able to convert a design into well-written HTML and properly factored CSS (using SASS mixins) in under an hour. This should make much faster and cheaper iteration on the front-end possible.
We're building a tool to do this for Sketch - https://protoship.io. It is early days, but we've been dog-fooding it to do conversion projects ourselves and I can't imagine going back to manual HTML/CSS coding again.