Changes between Version 11 and Version 12 of CodeExampleMacro


Ignore:
Timestamp:
Sep 29, 2010, 8:53:36 AM (4 years ago)
Author:
nuald
Comment:

New parameters using style has been documented.

Legend:

Unmodified
Added
Removed
Modified
  • CodeExampleMacro

    v11 v12  
    2929#!CodeExample
    3030#!python
    31     def apply_timer(self):
    32         timer = QTimer(self)
    33         self.connect(timer, SIGNAL('timeout()'), self.update_statusbar)
    34         timer.start(settings.HINTS_UPDATE_PERIOD)
     31@staticmethod
     32def get_templates_dirs():
     33    """ Notify Trac about templates dir. """
     34    from pkg_resources import resource_filename
     35    return [resource_filename(__name__, 'templates')]
    3536}}}
    3637}}}
     
    3839will be rendered as:
    3940
    40 [[Image(example.png)]]
     41[[Image(example1.png)]]
    4142
    4243The incorrect example:
    4344{{{
    4445{{{
    45 #!BadCodeExample
    46 #!python
    47     def create_hint_list(self):
    48         self.hints.extend(self.globals.get_hint_list())
     46#!CodeExample
     47## type = bad
     48#!haskell
     49fibs = 0 : 1 : [ a + b | a <- fibs | b <- tail fibs ]
    4950}}}
    5051}}}
     
    5253will be rendered as:
    5354
    54 [[Image(incorrect_example.png)]]
     55[[Image(example2.png)]]
    5556
    5657The correct example:
    5758{{{
    5859{{{
    59 #!GoodCodeExample
    60 #!python
    61     def update_statusbar(self):
    62         self.combo_box.insertItem(0, self.hints.get_current_hint())
    63         self.combo_box.setCurrentIndex(0)
     60#!CodeExample
     61## type = good
     62#!haskell
     63fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
    6464}}}
    6565}}}
     
    6767will be rendered as:
    6868
    69 [[Image(correct_example.png)]]
     69[[Image(example3.png)]]
    7070
    71 The is also support for getting sources from the repository using !CodeExamplePath, !BadCodeExamplePath, !GoodCodeExamplePath.
    72 
     71There is also support for getting sources from the repository:
    7372{{{
    7473{{{
    75 #!GoodCodeExamplePath
    76 #!python
    77 path=gws/main/main_view.py
    78 regex="def update_statusbar"
    79 lines=3
     74#!CodeExample
     75## path=GPGMail/Source/GPGMailPreferences.m
     76## regex=".*updater\s*{"
     77## lines=3
     78#!objective-c
    8079}}}
    8180}}}
     
    8382will be rendered as:
    8483
    85 [[Image(correct_example.png)]]
     84[[Image(example4.png)]]
    8685
    87 Parameters for *Path macros:
    88  * '''path''' - a file in the repository
    89  * '''regex''' - (optional) a regular expression indicates which to start getting
    90  * '''lines''' - (optional) limits number of lines of code to get
     86Parameters:
     87    * '''type''' - (optional) a type of the example: simple (default),
     88    good, bad
     89    * '''path''' - (optional) a file in the repository (using TracLinks
     90    format for source code)
     91    * '''regex''' - (optional) a regular expression indicates
     92    where to start an example
     93    * '''lines''' - (optional) number of lines to show
    9194
    9295== Recent Changes ==