Howto to script document comparison?


I’m looking for a way to automatically compute a document comparison, ie a document including changes from one document to another. Manually, such operation can be done from Edit->Compare Document… But I wish to create a script in order to do this action automatically, from two documents.

How can I achieve that?