Using yelp as a help viewer

From Code::Blocks

I wanted to use Gnome's Yelp as my wxWidgets help viewer with Code::Blocks, so I installed the wxWidgets docs debian package and wrote a shell script to launch yelp to the page for the class under the cursor when I hit F1.

If you'd like to set this up for yourself, follow the steps below:

This applies to Ubuntu, and possibly others.


Install the wxWidgets Documentation and integrate into Yelp

Skip steps 1 and 2 if your distro includes the wxWidgets packages (like Ubuntu Feisty)

1. Add the following repository to /etc/apt/sources.list:

deb http://apt.tt-solutions.com/ubuntu/ dapper main

2. Reload your repositories:

sudo apt-get update

3. Install the documentation package:

sudo apt-get install wx2.8-doc

The wxWidgets docs are now installed and integrated into Yelp.

Get the Yelp launching/searching script

Copy the following script into a file named wxyelpsearcher.sh

Note that you may need to change the helproot and prefix variables for your distro

#!/bin/sh
# wxyelpsearcher.sh
# Launch yelp with a wxWidgets class to search for it

helproot=/usr/share/doc/wx2.8-doc/wx-manual.html/
prefix=wx_
# before Feisty it was this
# prefix=wx2.8-manual_
defaultpath=${prefix}classref.html#classref

# If there is no argument, lauch yelp at the wxWidgets alphabetical class reference
if [ ! -n "$1" ]
then
 yelp file://$helproot$defaultpath &
  exit
fi  

# Convert first argument to lowercase, this is the class name
classname=$(echo "$1" | tr 'A-Z' 'a-z')

classpath=${prefix}${classname}.html

if [ -n "$2" ]
then
	index=#${classname}$(echo "$2" | tr 'A-Z' 'a-z')
else
	index=#${classname}
fi

if [ -e "$helproot$classpath" ]
then
	yelp file://$helproot$classpath$index &
else
	yelp file://$helproot$defaultpath &
fi

exit

Make the script executable:

sudo chmod +rx wxyelpsearcher.sh

Setup the Help Plugin in Code::Blocks

  • In Code::Blocks, goto Settings->Environment->Help Files
  • Click "Add" and name your new help entry.
  • Choose "Yes" when prompted to browse for a help file.
  • Browse for the wxyelpsearcher.sh script that you just created.
  • Add " $(keyword)" to the end of path. Example full path: /home/rrmulder/wxyelpsearcher.sh $(keyword)
  • Check the boxes for "This is the default help file (shortcut: F1) and "This line represents a full command to be executed"
  • Click "Ok"

Now when you hit F1 while the cursor is over a wxWidgets class, yelp will be launched and will show the documentation for that class.