azawawi / farabi6

Experimental in-browser Perl 6 Editor
Artistic License 2.0
14 stars 12 forks source link

[Module Search] Insert Snippet support #39

Open azawawi opened 9 years ago

azawawi commented 9 years ago

This has been discussed in http://irclog.perlgeek.de/perl6/2014-10-13#i_9503397

Basically created a feature to add snippets if the module has been installed

By default we pull from the module's github repository:

example/snippets/task1.pl example/snippets/task2.pl example/snippets/task3.pl

    21:52 azawawi     take a look at http://pbrd.co/1w2zEvz plz
    21:53 bbkr        azawawi: nice thinking!
    21:53 azawawi     when the user clicks on the module on the right, we insert the snippets for the module selected
    21:54 bbkr        unfortunately SYNOPSIS is not easily exportable and is in various places (Readme.md, library POD) across different modules
    21:54 azawawi     now how can farabi6 determine that... i guess snippet.pl in root directory or something
    21:54 azawawi     and SYNOPSIS requires more parsing
    21:54 azawawi     which is prone to error
    21:55 azawawi     think of about, why did i panda install Module::XYZ....
    21:55 azawawi     1. to use...
    21:55 azawawi     it :)
    21:56 azawawi     i will add an initial feature to pull the snippet.pl from the root directory or eg/snippet.pl
    21:57 azawawi     if it is there, that snippet is directly inserted into the farabi6 storyboard
    21:58 azawawi     why is javascript so popular?... the number of steps/tools to create a working example is minimal
    21:58 pmurias     it's so popular because it's in the browser
    21:59 bbkr        does p5 specify example/snippets directory name?
    21:59 azawawi     nope
    21:59 tadzik      azawawi: oh, I see. That's cool :)
    22:00 azawawi     bbkr: example/snippets/task1.pl example/snippets/task2.pl example/snippets/task3.pl   # interesting
    22:01 azawawi     pmurias: true but the number of tools needed to make something work is a A) browser already there and B) an editor... easily obtained
    22:04 bbkr        azawawi: thought so :( and i don't think p6 does that either. directories like lib/ or t/ are just customary. I think the best bet is to look for common names such as example/ or snippets/ and offer to paste content from files there. however small number of p6 modules has those
bbkr commented 9 years ago

The informal (not in p6 spec) module directory structure is described here: http://doc.perl6.org/language/modules

I think examples directory may be added there as informal standard - just like "logotype/". I found "examples/" to be most common:

https://github.com/retupmoca/P6-Net-AMQP/tree/master/examples https://github.com/mrhdias/perl6-Imlib2/tree/master/examples https://github.com/moritz/Math-Model/tree/master/examples https://github.com/moritz/svg-plot/tree/master/examples

Directory "eg/" also appears, but it is less common: https://github.com/tadzik/Template-Mojo/tree/master/eg