[GSoC] Class and Test Templates in KDevelop

 

I have generalized the “Create Class” dialog, so that it starts with a template selection page that is similar to what you see when starting a new project. It offers you a selection of templates of different types (currently only Class and Test) and programming languages. Selecting a templates leads to further assistant pages, which are chosen dynamically depending on the selected template’s type.

The first page of the “Create from Template” dialog

I have added wrapper classes for template rendering with Grantlee (KDevelop::TemplateRenderer) and template archives (KDevelop::SourceFileTemplate), so the assistant only deals with those to keep the code clean and readable. Both class and tests use the same format of template archives (described here), only with a some different variables.

As you can see from the screenshot, there’s already quite a few available templates to choose from. Considering a template only has to be written once, every project could have one or more preferred templates for new code. Existing ones can always be re-used, or maybe just tweaked slightly, so a little work can improve coding style and consistency.

 

 

Advertisements

3 responses to this post.

  1. A couple of doubts:
    What will the user see in “Create class” when working with a C++ project – will C and Python also be listed? And what is the meaning of having ‘C’ for Class?

    Reply

    • Posted by noughmad on 7. August 2012 at 16:09

      I’m not sure about the first one, the current language will definitely be preselected. I’ll see if adding a checkbox to hide other is worth it.

      About the second one, I have created some templates for GObject subclasses, becasue of the large amount of boilerplate code required.

      Reply

      • Oh.. the first one is more important in my opinion. It’s quite pointless and unpolished to see the option to create a Pyhton class (and add to project) when working with a C++ project. You may not need a check-box, but hiding the irrelevant ones is a good idea.

        Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: