GeneratorContext#stop should emit event
If an extension calls GeneratorContext#stop
to stop the generator, it's possible other extensions have promises that are still pending. To remedy this situation, this method should raise an event that provides those extensions an opportunity to clean up any promises (and close resources) before Antora is stopped. It also communicates to other listeners that the generator has been halted.
The name I propose for this event is contextStopped
. This event is mutually exclusive with sitePublished
. We may want to consider raising a contextClosed
event too, which runs regardless of whether the generator runs to completion.
The stop method on GeneratorContext should be replaced with a noop function before raising this event so listeners of the event cannot call it again. Listeners are expected to catch their own errors so that they do not prevent other listeners from finalizing.