Using yelp as a help viewer

From Code::Blocks
Revision as of 00:19, 22 March 2007 by Rjmyst3 (talk | contribs) (Using yelp as a wxWidgets help viewer)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

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

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

Reload your repositories:

sudo apt-get update

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

#!/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=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.