metal-kompanion/resources/kde-dev-tools.md

2.7 KiB
Raw Blame History

KDE Developer Tools

KDE provides a collection of scripts and tools to help developers enforce coding standards, find problems and prepare code for translation. Below is a summary of the most commonly used tools and what they are for.

Code Formatting and Beautification

  • astyle-kdelibs: A wrapper around Artistic Style that reformats C++ code to match KDEs style. It enforces four-space indentation and K&R brace placement.
  • kde_clang_format: Uses a .clang-format file distributed with KDE frameworks to format code automatically; projects can add a kde_clang_format target and use a pre-commit hook to apply clang-format.
  • uncrustify-kf5: An Uncrustify configuration tuned for KDE Frameworks 5. Uncrustify is a configurable source-code beautifier that can add or remove spaces and newlines, align code and add braces. Use this to reformat existing codebases consistently.

Static Analysis and Style Checking

  • krazy2: A static analysis tool that scans KDE source code and reports issues related to coding policy, best practices and optimization. It works through modular checker programs to examine different aspects of the code.
  • krazy-licensecheck: Runs the Krazy2 license checker on a list of source files. It requires Krazy2 to be installed and checks that files have correct license headers.
  • cmakelint.pl: A Perl script that examines CMakeLists.txt files and reports problems such as missing endif() statements, deprecated macros or stylistic issues.
  • kde-spellcheck.pl: Checks source files for common misspellings and can optionally correct them; useful for catching typos before they reach translators.

Translation and Build Helpers

  • extractrc: Extracts user-visible text (labels, tooltips, whats this) from Qt Designer .ui files, XML GUI .rc files and .kcfg configuration files so that these strings can be translated.
  • includemocs: Scans C++ sources and adds missing #include "moc_*.cpp" lines for classes that use the Q_OBJECT macro, ensuring that the Meta-Object Compiler output is linked.
  • fixuifiles: Processes Qt/KDE .ui files to fix common issues: lowers the required Qt version, removes untranslatable Alt+Letter accelerators and eliminates class-name captions.
  • preparetips: Collects tips-of-the-day and other tip strings for translation; typically called from a Messages.sh script.
  • xgettext (with KDE flags): The gettext extraction tool used to extract translatable strings from C++ and QML sources. It is invoked through the build system with appropriate options to recognize KDEs i18n macros.

These tools can be installed from the kde-dev-scripts package or the corresponding KDE SDK. Use them regularly to keep your project consistent with KDE and Qt guidelines.