Skip to content

Enable ctags support

Jonas Haag edited this page May 10, 2016 · 5 revisions

klaus ships with built-in support for Exuberant Ctags. Once enabled, all symbols in your source code (variable names, function names, …) are hyperlinked to the place of their definition.

Setup

  1. Install Exuberant Ctags:
    • Debian/Ubuntu/…: apt-get install exuberant-ctags
    • Mac OS X: brew install ctags
  2. Install the python-ctags3 package from PyPI: pip install python-ctags3

Usage

In the CLI, ctags support may be activated using --ctags <policy>, where <policy> allows you to fine-tune for what revisions ctags support should be enabled. The choices are

  • none: This is like not passing --ctags at all (default).
  • tags-and-branches: Only enable ctags support for the HEADs of branches and tags (recommended).
  • ALL: Enable ctags support for ALL revisions (don't use in production!)

The ALL option not recommended in production because it enables visitors to cause a lot of load on your servers. This is due to the fact that each time a source code file is viewed in klaus, an Exuberant Ctags file is generated by executing the ctags process (unless the tagsfile is already in klaus' internal cache). Running the ctags process scans all files in the repository for symbol names, which causes both a lot of I/O and CPU load on your system.

Outside the CLI

If you're running klaus behind a proper Web server, i.e. have rolled your own WSGI deployment script, you can enable Ctags support by passing the ctags_policy argument to make_app, like so:

from klaus import make_app

application = make_app(
    ["/path/to/repo1", "/path/to/repo2"],
    "John Doe's Git Repositories",
    ...
    ctags_policy='tags-and-branches',
)