8

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?

4

3 回答 3

7

如果去掉{$REGION}标签,Document Insight 仍然有效,旧版本应将文档视为普通注释。在支持代码折叠的 IDE 版本中,您将无法再折叠文档,仅此而已。

于 2013-01-24T02:04:27.323 回答
5

如果您必须有一个代码库在新旧 Delphi 中没有任何更改即可编译,则此解决方案将不起作用。

这很丑陋,当您从旧版本的 Delphi 到新版本的 Delphi 来回移动时,必须完成和撤消。

但是,您可以来回 grep 整个项目。

例如,从 XE2 到 D7 时,您需要将其转换为

{$REGION 'Documentation'} 

通过插入一个空格并删除尾随 },它看起来像这样:

{ $REGION 'Documumentation'

从 D7 到 XE2 你会做相反的添加 } 在每行开头的末尾

{$ REGION

并删除 $ 之后的空格。

就像我说的,它很丑。

于 2013-01-24T02:13:53.503 回答
0

Documentation Insight 支持一些内置的区域样式(请参阅选项对话框)。您可以选择兼容样式,它会自动生成 {$IFDEF NoDEF}{$REGION 'xxx'}{$ENDIF} 等指令。

于 2013-02-17T15:26:08.827 回答