smayzes / eve

A Slack Bot
18 stars 7 forks source link

Add a 'link me <namespace>' command #24

Open Riari opened 7 years ago

Riari commented 7 years ago

Aim

A way for Eve to provide links to API docs and/or files on GitHub based on a given namespace.

Syntax

Example fetching an Illuminate class:

@eve link me Illuminate\Log\Writer

Eve would respond to a link to one of the following:

Depending on what exactly we want Eve to respond with, this can either be driven by the Packagist API or a defined set of documentation sites where URLs to specific classes can be constructed easily. Both have their benefits and caveats:

Packagist API πŸ‘ Can find any package where the name can be matched πŸ‘Ž Matching package names using the namespace is tricky and won't always work, so that may warrant having two args: <package> <namespace> πŸ‘Ž May require reading any given package's composer.json to determine the PSR standard used and the root directory for its namespace

API docs πŸ‘ Easy construction of URLs for hosted API docs that follow the namespace convention for their URLs πŸ‘Ž Requires defining sites πŸ‘Ž Potentially requires handling small differences in URL structure such as version numbering

Nice To Have

matheus1lva commented 7 years ago

I have implemented just the basics of a possible pr for this.

a

Is this sufficient? I forgot on the screenshot, it was me asking for Illuminate\Log\Writer.

mdavis1982 commented 7 years ago

It might be nice to respond with the laravel.com/api URL rather than the link on GitHub because it makes it easier to navigate around the class. You haven't submitted the PR so I can't check the code though πŸ˜„

Riari commented 7 years ago

Suggested either, but I think it would be nice if it worked with GitHub URLs primarily so that it can be used for projects other than Laravel (Lumen, Illuminate itself, Symfony, etc). Perhaps Eve could respond with multiple URLs where applicable?

matheus1lva commented 7 years ago

@mdavis1982 indeed i haven't, i'm just checking before i submit it :). If i would specify what it should answer, wouldn't create a lot of switch cases?

@Riari yes, i think it should answer github primarly. I will see what i can do, could you give me an example where it could return more than 1 URL?

Riari commented 7 years ago

@PlayMa256 just realised I never responded to this, sorry :D basically I was thinking of something like this:

@eve link me Illuminate\Log Eve says: On GitHub: https://github.com/illuminate/log On Laravel API Docs: https://laravel.com/api/5.3/Illuminate/Log.html On Packagist: https://packagist.org/packages/illuminate/log

So I guess it would require multiple responders/response types to be configured.