• Stars
    star
    1,077
  • Rank 41,971 (Top 0.9 %)
  • Language
    C++
  • License
    Other
  • Created over 11 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Woboq CodeBrowser

This is the generator for code browser, formerly created and maintained by Woboq, KDAB wants to thank Woboq to have made available such a great tool to the community in the first place.

See https://code.woboq.org for an example.

To browse the source code of the generator using the code browser itself: https://code.woboq.org/userspace/codebrowser/

Main page: https://woboq.com/codebrowser.html

The announcement blog: https://woboq.com/blog/codebrowser-introduction.html

Build Status

Introduction and Design

There is a pre-processing step on your code that generates static html and reference database. The output of this phase is just a set of static files that can be uploaded on any web hoster. No software is required on the server other than the most basic web server that can serve files.

While generating the code, you will give to the generator an output directory. The files reference themselves using relative path. The layout in the output directory will look like this: (Assuming the output directory is ~/public_html/mycode)

$OUTPUTDIR/../data/ or ~/public_html/data/ is where all javascript and css files are located. Those are static files shipped with the code browser, they are not generated.

$OUTPUTDIR/projectname or ~/public_html/mycode/projectname contains the generated html files for your project

$OUTPUTDIR/refs or ~/public_html/mycode/refs contains the generated "database" used for the tooltips

$OUTPUTDIR/include or ~/public_html/mycode/include contains the generated html files for the files in /usr/include

The idea is that you can have several project sharing the same output directory. In that case they will also share references and use searches will work between them.

Install via RPM/DEB

Please look at https://woboq.com/codebrowser-download.html

Install via homebrew

Please look at https://woboq.com/codebrowser-download.html

Install via Arch User Repository (AUR)

Execute these commands in Arch Linux:

git clone https://aur.archlinux.org/woboq_codebrowser-git.git
cd woboq_codebrowser-git
makepkg -si

Compiling the generator on Linux

You need:

  • The clang libraries version 3.4 or later

You may want to sudo apt install llvm-7 clang-7 libclang-7-dev on Ubuntu if you ran into error like that clang says it cannot find "ClangConfig.cmake". More details in issues#74 .

Example:

cmake . -DCMAKE_BUILD_TYPE=Release
make

Compiling the generator on macOS

Install XCode and then the command line tools:

xcode-select --install

Install the clang libraries via homebrew ( http://brew.sh/ ):

brew install llvm --with-clang --rtti

Then compile the generator:

cmake . -DCMAKE_PREFIX_PATH=/usr/local/Cellar/llvm/<your_llvm_version> -DCMAKE_BUILD_TYPE=Release
make

Using the generator

Step 1: Generate the compile_commands.json (see chapter "Compilation Database" below) for your project

The code browser is built around the clang tooling infrastructure that uses compile_commands.json http://clang.llvm.org/docs/JSONCompilationDatabase.html

See the section "Compilation Database (compile_commands.json)" below.

Step 2: Create code HTML using codebrowser_generator

Before generating, make sure the output directory is empty or does not contains stale files from a previous generation.

Call the codebrowser_generator. See later for argument specification

Step 3: Generate the directory index HTML files using codebrowser_indexgenerator

By running the codebrowser_indexgenerator with the output directory as an argument

Step 4: Copy the static data/ directory one level above the generated html

Step 5: Open it in a browser or upload it to your webserver

Note: By default, browsers do not allow AJAX on file:// for security reasons. You need to upload the output directory on a web server, or serve your files with a local apache or nginx server. Alternatively, you can disable that security in Firefox by setting security.fileuri.strict_origin_policy to false in about:config (http://kb.mozillazine.org/Security.fileuri.strict_origin_policy) or start Chrome with the --allow-file-access-from-files option.

Full usage example

Let's be meta in this example and try to generate the HTML files for the code browser itself. Assuming you are in the cloned directory:

OUTPUT_DIRECTORY=~/public_html/codebrowser
DATA_DIRECTORY=$OUTPUT_DIRECTORY/../data
BUILD_DIRECTORY=$PWD
SOURCE_DIRECTORY=$PWD
VERSION=`git describe --always --tags`
cmake . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
./generator/codebrowser_generator -b $BUILD_DIRECTORY -a -o $OUTPUT_DIRECTORY -p codebrowser:$SOURCE_DIRECTORY:$VERSION
./indexgenerator/codebrowser_indexgenerator $OUTPUT_DIRECTORY
cp -rv ./data $DATA_DIRECTORY

You can adjust the variables and try similar commands to generate other projects.

Arguments to codebrowser_generator

Compiles sources into HTML files

codebrowser_generator -a -o <output_dir> -b <buld_dir> -p <projectname>:<source_dir>[:<revision>] [-d <data_url>] [-e <remote_path>:<source_dir>:<remote_url>]

-a process all files from the compile_commands.json. If this argument is not passed, the list of files to process need to be passed

-o with the output directory where the generated files will be put

-b the "build directory" containing the compile_commands.json If this argument is not passed, the compilation arguments can be passed on the command line after --

-p (one or more) with project specification. That is the name of the project, the absolute path of the source code, and the revision separated by colons example: -p projectname:/path/to/source/code:0.3beta

-d specify the data url where all the javascript and css files are found. default to ../data relative to the output dir example: -d https://code.woboq.org/data

-e reference to an external project. example:-e clang/include/clang:/opt/llvm/include/clang/:https://code.woboq.org/llvm

Arguments to codebrowser_indexgenerator

Generates index HTML files for each directory for the generated HTML files

codebrowser_indexgenerator <output_dir> [-d data_url] [-p project_definition]

-p (one or more) with project specification. That is the name of the project, the absolute path of the source code, and the revision separated by colons example: -p projectname:/path/to/source/code:0.3beta

-d specify the data url where all the javascript and css files are found. default to ../data relative to the output dir example: -d https://code.woboq.org/data

Compilation Database (compile_commands.json)

The generator is a tool which uses clang's LibTooling. It needs either a compile_commands.json or the arguments to be passed after '--' if they are the same for every file.

To generate the compile_commands.json:

  • For cmake, pass -DCMAKE_EXPORT_COMPILE_COMMANDS=ON as a cmake parameter
  • For qmake, configure/autoconf and others, follow the instructions in scripts/fake_compiler.sh or scripts/woboq_cc.js. These are fake compilers that append the compiler invocation to the json file and forward to the real compiler. Your real compiler is overriden using the CC/CXX environment variables Make sure to have the json file properly terminated.
  • If you use ninja, you can use ninja -t compdb
  • If you use qbs, you can use qbs generate --generator clangdb
  • There is also a project called Build EAR (Bear) that achieves a similar thing as our fake compilers but is using LD_PRELOAD to inject itself into the build process to catch how the compiler is invoked. https://github.com/rizsotto/Bear

There is also some further information on https://sarcasm.github.io/notes/dev/compilation-database.html#clang

Getting help

No matter if you are a licensee or are just curious and evaulating, we'd love to help you. Ask us via e-mail on [email protected] Or on IRC in #woboq on irc.freenode.net

If you find a bug or incompatibility, please file a github issue: https://github.com/woboq/woboq_codebrowser/issues

Licence information

Licensees holding valid commercial licenses provided by Woboq may use this software in accordance with the terms contained in a written agreement between the licensee and Woboq. For further information see https://woboq.com/codebrowser.html

Alternatively, this work may be used under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 (CC-BY-NC-SA 3.0) License. http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US

This license does not allow you to use the code browser to assist the development of your commercial software. If you intent to do so, consider purchasing a commercial licence.

More Repositories

1

hotspot

The Linux perf GUI for performance analysis.
C++
3,925
star
2

GammaRay

GammaRay is a tool to poke around in a Qt-application and also to manipulate the application to some extent.
C++
1,410
star
3

cxx-qt

Safe interop between Rust and Qt
Rust
941
star
4

KDDockWidgets

KDAB's Dock Widget Framework for Qt
C++
623
star
5

android_openssl

OpenSSL scripts and bins for Android (useful for Qt on Android apps)
C
291
star
6

KDToolBox

KDAB's collection of miscellaneous useful C++ classes and stuff
C++
259
star
7

KDBindings

Reactive programming & data binding in C++
C++
208
star
8

Charm

The Cross-Platform Time Tracker
C++
192
star
9

kdabtv

This repository contains the code of the examples showcased in the KDAB TV video series.
C++
186
star
10

DeclarativeWidgets

Library and tools for creating QtWidget UIs using QML
C++
168
star
11

KDStateMachineEditor

A framework for creating Qt State Machine metacode using a graphical user interface
C++
159
star
12

KDSoap

A Qt-based client-side and server-side SOAP component
C++
140
star
13

kuesa

Professional 3D asset creation and integration workflow for Qt
C++
137
star
14

qt3d-examples

Qt3D Examples
C++
131
star
15

KDReports

Qt library for generating printable and exportable reports from code and from XML descriptions.
C++
115
star
16

KDChart

A Qt tool for creating business and scientific charts. This is the canonical repository for KDChart.
C++
99
star
17

KDAlgorithms

Algorithm wrappers
C++
77
star
18

sqlate

C++
58
star
19

android

KDAB's Android gems
C++
45
star
20

KDSingleApplication

KDAB's helper class for single-instance policy applications
CMake
45
star
21

integrating-qq2-with-opengl

C++
43
star
22

virtual-keyboard-demo

Example source code for the implementation of a virtual keyboard based on Qt input method framework
C++
42
star
23

Qt4to5

C++
40
star
24

KDMacTouchBar

KDAB's Qt Widget for the Mac Touch Bar
Objective-C++
37
star
25

KDTools

KDTools aims to ease the daily work of Qt programmers by providing a number of well-designed, easy-to-use widgets and non-gui classes.
C++
30
star
26

FatCRM

Desktop Application for SugarCRM
C++
28
star
27

qsslint

Linter for Qt stylesheet files
C++
21
star
28

ctf2ctf

Common Trace Format to Chrome Trace Format converter
C++
18
star
29

eglinfo

Provides information about available EGL configurations.
C++
16
star
30

GammaRay-plugin-examples

Example plug-ins for GammaRay
C++
14
star
31

perfparser

fork of qt-creator/perfparser.git with not-yet upstreamed changes required for hotspot
C++
14
star
32

homebrew-tap

Homebrew formulas for KDAB projects
Ruby
11
star
33

OpenEmbedded-Archos

An Angstrom distro for the Archos 101IT tablet based on OpenEmbedded, with Qt4 and Qt5 support including multitouch and OpenGL/ES2
C
11
star
34

QMemstat

Inspect Pagemaps of Programs
C++
8
star
35

KDBoatDemo

KDAB Nautical UI - concept of the next generation UI for sailing boats
QML
8
star
36

KDUtils

A set of C++ helpers and wrappers around the C++ standard library
C++
7
star
37

autogen

Common build system code for KDAB products
Python
5
star
38

clang-format-rs

clang-format wrapper for rust
Rust
4
star
39

patent_defense

Defensive Patent Publications
C
3
star
40

qnxtools

Python
3
star
41

KDGpu

KDGpu is a thin wrapper around Vulkan to make modern graphics easier to learn and use
C++
3
star
42

WebKit

QtWebkit clone
C++
2
star
43

event_loop_watchdog

A class to detect whenever your main event loop gets blocked for more than x milliseconds
Dart
2
star
44

cabin-demo

KDAB Flutter demo application.
Dart
1
star
45

GammaRayPlatformProbe

GammaRay Platform Probe
C++
1
star
46

kdab-overlay

Gentoo Portage overlay containing KDAB software
Shell
1
star
47

kuserfeedbackdocker

Docker container for the KUserFeedback server.
PHP
1
star
48

unicode_view

Playground repo for unicode view
C++
1
star
49

blog-vscode-template

vscode template for C++ projects (Cross referenced by the blog, do not delete)
CMake
1
star
50

vscode-qttest

VSCode extension for supporting Qt tests in the "Testing" sidebar
TypeScript
1
star