Opened 8 years ago

Closed 8 years ago

#6981 closed enhancement (fixed)

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

Reported by: simon@… Owned by: Alexander Slesarev
Priority: normal Component: CodeExampleMacro
Severity: normal Keywords:
Cc: Trac Release: 0.11


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.

Attachments (0)

Change History (2)

comment:1 Changed 8 years ago by Alexander Slesarev

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 8 years ago by Alexander Slesarev

Resolution: fixed
Status: newclosed

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):

## type = bad
## path=GPGMail/Source/GPGMailBundle.m@b27be2b1023f0bdef865dd98eb0d77202a712fd5:110-115

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Alexander Slesarev.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.