Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can compile documented Delphi code in older Delphi versions (<2005)

I'm using the Documentation Insight feature to document a Delphi library, currently this work fine with Delphi 2005 to XE3. Now I want to add support for old versions of Delphi (5, 6, 7) too.

But when try to compile a code like this in Delphi versions minor than 2005 (Delphi 5, 6, 7)

 {$REGION 'Documentation'}
 ///    <summary>
 ///      This is a sample text 
 ///    </summary>
 {$ENDREGION}
 TFoo=class
   procedure Tick;
 end;

I receive a compiler error

Invalid Compiler Directive REGION

What is fine because the REGION reserved word was introduced when the Delphi IDE was Changed to Galileo (Delphi 2005).

So, for now as workaround I'm using this syntax in order to compile the code in Delphi 5 - to XE3.

 {$IFDEF NODEF}{$REGION 'Documentation'}{$ENDIF}
 ///    <summary>
 ///      This is a sample text 
 ///    </summary>
 {$IFDEF NODEF}{$ENDREGION}{$ENDIF}
 TFoo=class
   procedure Tick;
 end;

But now using such code the Documentation Insight no longer works in Delphi XE2 and XE3.

So the question is, How i can compile documented Delphi code in older versions of Delphi without affect Documentation Insight in the newer Delphi versions?

like image 644
RRUZ Avatar asked Jan 24 '13 01:01

RRUZ


2 Answers

If you get rid of the {$REGION} tags, Document Insight still works, and older versions should treat the documentation as normal comments. You just won't be able to collapse the documentation anymore in IDE versions that support code folding, that's all.

like image 91
Remy Lebeau Avatar answered Dec 06 '22 23:12

Remy Lebeau


If you have to have one code base that compiles with no changes in old and new Delphi, this solution won't work.

It's ugly and would have to be done and undone as you move back and forth from an older version of Delphi to a newer one.

But, you could grep your entire project back and forth.

When going from XE2 to D7, for example, you'd convert this

{$REGION 'Documentation'} 

by inserting a space and removing the trailing } so it looks like this:

{ $REGION 'Documumentation'

And going from D7 to XE2 you'd do the reverse adding a } at the end of every line that begins with

{$ REGION

and removing the space after the $.

Like I said, it's ugly.

like image 36
RobertFrank Avatar answered Dec 06 '22 22:12

RobertFrank