Ddoc and version

Sean Kelly sean at f4.ca
Thu Aug 17 14:29:39 PDT 2006


Walter Bright wrote:
> version is a problem with Ddoc, however, it may be a generally 
> unresolvable one.
> 
> But I think it's a little odd that you'd have two different descriptions 
> for the same code???
> 
> Here's a way to do it, not the nicest, but workable:
> 
>   version(XYZZY)
>   {
>    /** Some description.
>    */
>    void someFunc() { implementation(); }
>   }
>   else
>   {
>    /** Some other description.
>    */
>    void someFunc() { implementation(); }
>   }
> 
>   void implementation()
>   {
>     ...
>   }

You can also document a function declaration:

version(XYZZY)
{
   /** Some description.
    */
   void someFunc();
}
else
{
   /** Some other description.
    */
   void someFunc();
}

void someFunc()
{
   ...
}

In a few cases I generate docs inside version(DDoc) blocks rather than 
above the actual implementation, either because I have different 
versions of a function for different platforms and I don't want to tie 
the docs to a specific platform block, or because I'm using some dirty 
trick to declare the function that I don't want the user to be aware of. 
  This last case is most common in code where I'm hacking around ITI 
limitations and the function decl doesn't exactly match what it 'should' be.


Sean



More information about the Digitalmars-d-bugs mailing list