Template System for KDevelop
Miha Čančula
Short description: A template system for code creation in KDevelop. Such a system currently exists for starting a new project, but I would add similar functionality for individual files, most notably for classes. I would also add an interface for creating and editing these templates. Additionally, users will be able to download and/or share these templates via GHNS.
Proposal Title: Template System for KDevelop
Motivation for Proposal / Goal:
I'm a regular user of KDevelop and I use it to start projects or generate classes quite often. Unfortunately, the current system is not very flexible, so I still have to write some boilerplate code, especially for QObject and QWidget subclasses. The introduction of user templates would allow me and others to reduce the time spent repeating myself.
The goal is to have a framework for creating, sharing and downloading templates for both entire projects (starting points) and individual files (classes, unit tests, common functionality)
Implementation Details:
I have some experience with GHNS, as I have used it to download themes for the chess program Knights. Downloading and the templates themselves would be the easier part.
Currently, KAppTemplate performs variable substitution using a KMacroExpander. While this has a convenient and well-known syntax, it lacks features such as loops. For example, a typical class template should allow the user to declare methods and members, and automatically create definitions and accessor methods. Therefore I propose to use the Grantlee template library. I have used both Grantlee and the Django template system which inspired it, although I have no public completed projects to demonstrate it.
I would keep the division between app templates (KAppTemplate) and file templates (Grantlee), however they would both be shared and hosted at GHNS. Application templates would require very few changes, since they are already distributed as compressed tarballs, and the sharing would be integrated into KAppTemplate. I also would not provide a special editor for app templates, since they span multiple files, making such an editor impractital.
The file templates would be further divided into categories, although they would be stored, shared and edited together. Categories would only affect when they are used and which variables are passed to them. The categories I now have in mind are for classes and unit test cases, although more could be added if needed. Considering at least C++ often has more than one file per class, these templates will also be stored and distributed as tarballs.
Finally, I would also create some such templates. I intend to focus on Qt/C++ programming first since I have the most experience there: Normal classes, classes with d-pointers, classes with signals and slots, classes with user interface files. To make sure the framework is applicable for other languages as well, I would add templates for varous Python classes (those that I know: PyQt, Django). Using templates should also greatly simplify unit test generation, so I will add templates for those as well (at least QtTest, preferably also PHPUnit and PyUnit).
The file-template functionality would be implemented in a KDevelop plugin, with a dialog for defining the template parameters (name, variables, functions for classes, cases for unit tests).
Tentative Timeline (in weekly intervals until 2 weeks after the end of GSoC):
Before start: Communicate with the team, figure out any other prospective template categories. Also contacting the kde-files maintainer to create the two appropriate categories.
Week 1 [May 21 - 27]: Implement downloading from GHNS in KAppTemplate (KAT).
Week 2-3 [May 28 - June 10]: Enable loading custom templates in KAT and sharing them. Also make sure both of these work in the KDevelop integration. Note that I will still have school at this time, so I reserved a longer time frame.
Week 4 [June 11 - 17]: Define the interface (list of variables) that each category if file templates will require.
Week 5-6 [June 18 - July 1]: Create a basic template for each of the categories (likely for C++), then start writing the user interface for using them.
Week 7 [July 2 - July 8]: Mid-term evaluation. At this point the app templates should be fully sharable. File templates can be instantiated (used) to create basic C++ classes.
Week 8-9 [July 9 - 22]: Implement sharing for file templates as well, in a KDevelop plugin.This means an editor for the templates, the possibility to import them from local files of GHNS, and uploading them to the server.
Week 10-11 [July 23 - August 5]: Add more templates. Qt- and KDE-oriented C++ class templates, Python and PHP classes, unit tests. Finalize the interface at this point, adding any more required variables to the template renderer. Integrate the new code generation with the project manager (like adding new source files to CMake targets). Also a good time to write unit tests for the new functionality.
Week 12 [August 6 - 12]: Finish the project, polish the user interface and write documentation. If something earlier doesn't go according to plan, or if new ideas come up, complete it at this time.
After suggested pen down date: Everything should work at this point. If so, complete test cases, documentation, and user interface. Otherwise, last minute fixes and adjustments.
After the deadline: My school year only starts in October, so considering the exam period just before that I will have nearly a month left of free time then. First I will need some rest from the summer work, but I will be able to fix anything that comes up, as well as ensure the code is properly merged into the master branch. If allows, I will extend KDevelop with some other plugins. My current long-term plans are integrating unit testing (most already done), static code analysis (Krazy, clang) and something more playful (like The Daily WTF submitter).
After the summer: KDevelop is and still will be my favorite code editor. I may not have much time free from school right now (I hope next year will be better), but I try to spend as much of it as possible on KDE. So even though I am not as active as I wish, I will surely continue contributing after the project is completed, at least by maintaining my own code.
Other obligations
I have school until June 10th, so I will only be partially available (~20hrs/week) until then. After that, I'll be free to work more than 40 hours per week on this. Thanks to our school obligations consisting mostly of homework during the semester, I will only have two exams to complete after that time, both of which can be put off until September. I also don't plan to have any seaside vacation this year.
About Me (let us know who you are!):
I'm a fourth-year (22 years old) Computational Physics student from LjubljanLjubljana, Slovenia, central Europea, Slovenia. My main interests besides Physics include computer programming, free software, and many forms of science fiction. Especially in the last year, the schoolwork and a girlfriend have taken time away from most of my hobbies, so I have to listen to books while cycling to school and only code on rare occasions.
I've always been interested in Mathematics and Physics, and I've participated and won medals in both international Mathematcial and Physical Olympiads. I attended programming competitions since elementary school, but I never got to any international competitions.
My free software projects so far are Knights, a chess board for KDE4, and Opeke, a simple 3D graphics program using KDE/Qt, QtOpenGL and OGRE. In 2010, I successfully participated in Season of KDE, when I wrote the Octave backend for Cantor (SoK report, screencast). Last year I worked for Orange as part of Google Summer of Code, where I added a module for visualizations using Qt's graphics classes.
My schoolwork also includes a lot of programming, some of which overlaps with this project. Most of the programs and corresponding reports are published online at GitHub. Apart from the linked programs, I attended many classes on numerical methods and digital signal processing.
