Opened 4 years ago

Closed 3 years ago

# CodeExamplePath should take regexes for start-1 and stop+1

Reported by: Owned by: simon@… nuald normal CodeExampleMacro normal 0.11

### Description

For CodeExamplePath it'd be nice to be able to specify start-1 and stop+1 lines with regexes. The point being that you could delineate parts of actual running code (typically unit tests) with comments (e.g. EXAMPLE 1 START and EXAMPLE 1 STOP) and have the Macro include everything BETWEEN those two lines.

Specifying the start line as regex and the number of lines is a bit brittle. It requires that the start line of the example is uniquely matchable (i.e. a method name) and that you change the macro invocation if you change the code example in the source.

### comment:1 Changed 4 years ago by nuald

There is an ability to to highlight lines from the repository: #6624. Maybe it can be useful for you.

The documentation is not up to dated now, because I'm thinking about the way to get rid of "Path" suffixes. But all patches are welcomed :)

### comment:2 Changed 3 years ago by nuald

• Resolution set to fixed
• Status changed from new to closed

It is already implemented. Just use the path parameter as:

## path = <file>@<rev>:<lines>#L<line>


Lines are the list of <line_start>-<line_end> separated by commas. The same syntax is used in TracLinks.

#L parameter is used for the title link (if you click the title, it will forward you to the sources and show the line from #L value).

An example (for Git repo, for SVN just use the revision number instead of hash):

{{{
#!CodeExample
## type = bad
## path=GPGMail/Source/GPGMailBundle.m@b27be2b1023f0bdef865dd98eb0d77202a712fd5:110-115
#!objective-c
}}}


### Modify Ticket

Change Properties