Code Browser with KDE or Qt Projects
In my previous post I talked about the Woboq Code Browser.
While the instructions for compilation and usage are quite good, in this post I will try to summarize them for a specific use case: the generation of HTML files for a KDE/Qt application using the
CMake build system, on the Linux platform. These instructions should also works for a generic
CMake project using plain C++.
This post assumes that you are a Qt/KDE developer on a Linux system. This means that you should already have all the needed stuff (
cmake, etc.). Just make sure to have
llvm-config) installed under
/usr/bin. This makes the process easier.
First of all, you need to compile the codebrowser.
Clone the codebrowser source files:
Now you have the two codebrowser components:
clang expects to find the system libraries in
../lib relative to the executable, you have two choices:
Option 1: install the codebrowser components.
In this way you can use the codebrowser everywhere:
Option 2: link the system libraries to the
I don’t like the latter because you need to type the extended path when using the codebrowser; but it’s up to you.
In either cases, you need to copy the
data/ directory to the directory that will contain the generated HTML files. The output directory in this example will be
Now you are ready to generate the HTML for your KDE or Qt
foo project. Just make sure that you have a
git local repository for
compile_commands.json. This will tell to the codebrowser which source files has to process:
Then generate the source code HTML pages. The output directory in this example will be
If you are interested,
codebrowser_generator -help will explain the meaning of the used options.
Last step: generate the HTML index:
Done. Simply open in your preferred browser
~/public_html/foo/index.html and enjoy it!
By default, for (e.g.) a KDE project the codebrowser generates not only the code for the project itself, but also for all the included libraries. This translates in (at least) the whole KDE, the whole Qt and many C++ standard headers. If you want to upload the generated HTML on your webserver, this might be a problem if you have storage concerns, for example if you are on a shared server.
Fortunately, the codebrowser gives you the option to link external generated libraries. Just use the
-e option like in this way: