raycast / extensions

Everything you need to extend Raycast.
https://developers.raycast.com
MIT License
5.23k stars 2.93k forks source link

[DevDocs]: Live search documentation #13695

Open manishrc opened 1 month ago

manishrc commented 1 month ago

Extension

https://www.raycast.com/djpowers/devdocs

Description

To search within DevDocs, you need to look for the keywords and press enter or command-enter.

Alfred + Dash integration had a nice feature where the Dash showed the documentation as you type within Alfred. Wondering if it's possible to do the same for DevDocs too.

CleanShot 2024-07-26 at 12  33 39@2x

Who will benefit from this feature?

No response

Anything else?

No response

raycastbot commented 1 month ago

Thank you for opening this issue!

🔔 @djpowers @pernielsentikaer you might want to have a look.

💡 Author and Contributors commands The author and contributors of `djpowers/devdocs` can trigger bot actions by commenting: - `@raycastbot close this issue` Closes the issue. - `@raycastbot rename this issue to "Awesome new title"` Renames the issue. - `@raycastbot reopen this issue` Reopens the issue. - `@raycastbot assign me` Assigns yourself to the issue. - `@raycastbot good first issue` Adds the "Good first issue" label to the issue. - `@raycastbot keep this issue open` Make sure the issue won't go stale and will be kept open by the bot.
djpowers commented 1 month ago

Interesting suggestion, it looks like there's more context on Alfred's Dash workflow here: https://www.alfredapp.com/blog/productivity/dash-quicker-api-documentation-search/

The DevDocs macOS app does have scripting support: https://github.com/dteoh/devdocs-macos?tab=readme-ov-file#protocol-handler-integration

Using Raycast's runApplescript function, I was able to add the following to the onSearchTextChange block in SearchEntries component, which opens a new window in the DevDocs app with the current search query (of note, DevDocs macOS appears to not expect the full slug: e.g., rails instead of rails~7.1):

 runAppleScript(`tell application "DevDocs" to open location "devdocs-macos://search?doc=${slug}&term=${text}"`);

However, this results in a new window on each keystroke. If you debounce the input you lose out on the instant results, and it still seems a bit jarring to open a new tab without an explicit user action.

Even if this could be done in the current active tab I'm still hesitant to overwrite its contents when someone may not be expecting that.

I'll leave this open for a bit in case there are other thoughts but as it stands this seems like it would be tricky to implement without potentially negatively impacting the user experience.