Does deleting a ContentDocument delete associated ContentDocumentLinks?
Yes, deleting a ContentDocument will also delete any related ContentDocumentLink entities. I tested this out in my org:
ContentDocument d = [SELECT Id FROM ContentDocument LIMIT 1]; ContentDocumentLink l = [SELECT Id FROM ContentDocumentLink WHERE ContentDocumentId = :d.Id]; System.debug(l.size()); System.assert(l.size() > 0); delete d; l = [SELECT Id FROM ContentDocumentLink WHERE ContentDocumentId = :d.Id]; System.debug(l.size()); System.assert(l.size() == 0); System.assert(false, 'Yes, they were deleted.');
The final assertion was set so that the transaction would roll back (i.e. the document would not actually be deleted). This script proves that deleting a ContentDocument causes a cascade deletion of any links.
Note that in the Classic UI, only the link is deleted, but the ContentDocument itself survives. When you delete the ContentDocument directly (e.g. via the API or Apex), regardless of platform, it will remove any associated links.
I haven't tried it out myself, but looking at ContentDocument and ContentDocumentLink trigger behavior in Classic and Lightning knowledge article, it seems the behavior is different depending on the Experience - Classic vs. Lightning.
In Classic, ContentDocument triggers do not fire, as Salesforce only deletes the associated ContentDocumentLink record, not the ContentDocument record.
In Lightning Experience, both the ContentDocument and related ContentDocumentLink records are deleted, and by design Salesforce only fires the trigger on ContentDocument, not the trigger on ContentDocumentLink.
There's a detailed explanation and example on the link.