Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Argument hints for WordPress functions missing? #2

Open
tliebig opened this Issue Dec 30, 2011 · 17 comments

Comments

Projects
None yet
6 participants

tliebig commented Dec 30, 2011

Dear purplefish,

I was delighted to see a wordpress bundle for sublime text. For some reason, although it autocompletes the function names (get_po... > get_post), but does not hint what arguments are accepted (http://codex.wordpress.org/Template_Tags/get_posts).

I was hoping I could spare me a couple of visits to the codex by having that information right within sublime text. Any idea what I might be doing wrong (installed the package through the package manager, so I figured that shouldn't a cause of error :o/)

Yours,
Torsten

Owner

purplefish32 commented Jan 2, 2012

Hi there, sounds like a good idea, I saw a couple of screenshots somewhere but I have no idea of how to implement that, If you have anny ideas or examples of working code, I would be more than happy add hinting to the bundle

tliebig commented Jan 2, 2012

Not me, but Jon (the developer of the editor) would surely know how to do it. I'll shoot him a mail in a second, maybe he finds the time to help you out (I'll include this thread, so he can post the answer right here).

Thanks!

.sublime-completions files can include snippets, and function parameters as fields in the snippets. This is done for the PHP completions that are shipped out of the box, take a look at Packages/PHP/PHP.sublime-completions for an example.

Owner

purplefish32 commented Jan 25, 2012

I just added auto generated wordpress functions in the new version, ( I built a little script that scans the base wordpress install and turns all functions into sublime completions ), but for the moment i'm only getting the default arguments.
get_posts => get_posts(args = null), which is not a lot of help.

Owner

purplefish32 commented Jan 25, 2012

@tliebig : just for you I added an experimental replacement method :

try : "get_posts_default"
Should give you get_posts with all the default arguments,

Can you tell me If you like this method, and if you do can you give me a list of other functions that have argument lists that you vant me to implement ?

@purplefish32 purplefish32 reopened this Jan 25, 2012

tliebig commented Jan 25, 2012

Hey Jon, hey purplefish32,

I appreciate you both taking the time to go forward on the issue. As I've said before, I consider SublimeText with the developing WordPress snippets to be a killer tool for WP development :)

@purplefish32: get_posts_default works perfectly. But to be honest: I assume we're doing developers a disservice by training the to work with fake function names. If there's any chance, I'd try to work with the real WP function names in order to train people to work with the real thing.

As for what functions should be implemented (loose collection, made from checking what functions I use most regularly when developing themes):
the_content
the_excerpt
wp_enqueue_script
wp_enqueue_style
get_post_meta
wp_nav_menu
add_image_size
get_option (with list of available options)
add_action (with list of available action hooks)
add_filter (with list of available filter hooks)
get_children
wp_list_pages
$wp_admin_bar->methods()

Contributor

ericandrewlewis commented Apr 3, 2012

As this project borrows a lot from the TextMate implementation, perhaps parsing through that to add the proper argument hinting in the autocomplete.

Any situations where an argument needs more detail can be edited properly, as you have done with the get_posts example.

I'd really like to move forward with this issue (professional WP dev using Sublime exclusively) and would be willing to write patches.

Owner

purplefish32 commented Apr 3, 2012

@ericandrewlewis Not 100% sure I understand what you meen, feel free to send pull requests / patches

Owner

purplefish32 commented Apr 6, 2012

Function names have been updated (ie : not "_default"), most have been updated, I still want to work on the following as soon as possible :

the_excerpt
wp_nav_menu
get_option
add_action
add_filter
get_children

Contributor

ericandrewlewis commented Apr 6, 2012

add_action, add_filter, get_option, and the_excerpt look good to me. The others definitely yes.

Also, we'll have to look through other auto-complete files for duplication of auto-completes imported from this.

Owner

purplefish32 commented Apr 6, 2012

Yeah I just deleted most of the other files, I have a few tiny changes to make to the scraper so that its gold, reexport the functions then ill update the missing args.
(Do you mind if I set up a separate git repo for the scraper ?)
Ill have to take a second look at add_action, add_filter, get_option, and the_excerpt then :)

Contributor

ericandrewlewis commented Apr 6, 2012

sounds good to me.

I have a good chunk of the completions for template tags cleaned up. Mainly template tags. Will try to put together a patch snice I've changed some file names and things.

Though if you're fine with changing away from Auto-generated to FunctionCompletions and a few other changes I can just pull request the whole thing. I have started doing snippets for the more involved functions as well.

Owner

purplefish32 commented Apr 30, 2012

Todo : get_children

This is a really awesome feature, but I would like to point out one thing

The helpers use tabs to align everything. The alignment is great, and falls in line with the WordPress PHP Coding Standards, but those same standards also specify that tabs should only be used at the beginning of a line. We should switch this to use spaces and not tabs after the key.

Screen Shot 2013-04-17 at 12 24 58 PM

Also, trailing commas for the last element in an array are suggested

  • update, used a picture so we can see whitespace.
Owner

purplefish32 commented Apr 22, 2013

I am OK with this, but for the moment dont really have time, feel free to pull request, and I will promptly merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment