Add comprehensive AI-friendly EventHandlers documentation #169
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
EventHandlers lacked structured reference documentation. AI assistants and developers needed clear guidance on the 28 event handlers across Load/Browse/Crawl phases, their execution order, signatures, and practical usage patterns.
Changes
Documentation Files
Source Code KDoc Enhancements
Key Event Handlers
onDocumentSteady- Primary for browser automation:browseEventHandlers.onDocumentSteady.addLast { page, driver -> // Page is stable - ideal for custom actions if (driver.exists("#cookie-consent")) { driver.click("#cookie-consent .accept") } while (driver.exists(".load-more")) { driver.click(".load-more") delay(2000) } }onHTMLDocumentParsed- Primary for data extraction:loadEventHandlers.onHTMLDocumentParsed.addLast { page, document -> val products = document.select(".product").map { Product( name = it.selectFirst(".name")?.text(), price = it.selectFirst(".price")?.text() ) } }Event Execution Order
crawl.onWillLoad→ 2.load.onNormalize→ 3.load.onWillLoad→ 4.load.onWillFetch→ 5-19. Browse phase (if using browser) → 20-25. Load phase parsing → 26.crawl.onLoadedCoverage
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.