Contents
Code example box with syntax highlighting
Description
The CodeExampleMacro renders a code example box that supports syntax highlighting. It support three types of examples: simple, correct, and incorrect. The SELECT ALL link highlights all of the code in the box to simplify the copy and paste action.
All rights reserved by Codedgers Inc.
Bugs/Feature Requests
Existing bugs and feature requests for CodeExampleMacro are here.
If you have any issues, create a new ticket.
Download
Download the zipped source from here.
Source
You can check out CodeExampleMacro from here using Subversion, or browse the source with Trac.
Example
The simple example:
{{{
#!CodeExample
#!python
def apply_timer(self):
timer = QTimer(self)
self.connect(timer, SIGNAL('timeout()'), self.update_statusbar)
timer.start(settings.HINTS_UPDATE_PERIOD)
}}}
will be rendered as:
The incorrect example:
{{{
#!BadCodeExample
#!python
def create_hint_list(self):
self.hints.extend(self.globals.get_hint_list())
}}}
will be rendered as:
The correct example:
{{{
#!GoodCodeExample
#!python
def update_statusbar(self):
self.combo_box.insertItem(0, self.hints.get_current_hint())
self.combo_box.setCurrentIndex(0)
}}}
will be rendered as:
The is also support for getting sources from the repository using CodeExamplePath, BadCodeExamplePath, GoodCodeExamplePath.
{{{
#!GoodCodeExamplePath
#!python
path=gws/main/main_view.py
regex="def update_statusbar"
lines=3
}}}
will be rendered as:
Parameters for *Path macros:
- path - a file in the repository
- regex - (optional) a regular expression indicates which to start getting
- lines - (optional) limits number of lines of code to get
Recent Changes
[7635] by nuald on 02/18/10 04:09:18
Ticket #6662 has been fixed.
[7633] by nuald on 02/17/10 14:54:49
Ticket #6655 has been fixed.
[7632] by nuald on 02/17/10 13:39:59
Ticket #6624 has been implemented.
[7630] by nuald on 02/17/10 09:03:06
Ticket #6622 has been fixed.
Author/Contributors
Attachments
- example.png (15.8 kB) -
The simple example image.
, added by nuald on 05/22/09 08:56:33. - correct_example.png (12.9 kB) -
The correct example image.
, added by nuald on 05/22/09 08:57:41. - incorrect_example.png (8.9 kB) -
The incorrect example image.
, added by nuald on 05/22/09 08:58:08.




