www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - ddoc and CODE_HIGHLIGHT macro

reply Nick Treleaven <ntrel-public yahoo.co.uk> writes:
Hi,
Ddoc doesn't seem to expand a macro near top of 
http://dlang.org/hash-map.html:

// The $(CODE_HIGHLIGHT KeyType) is string

Which is weird because it expands it for 'remove' on this line not far 
below it:

b.remove("hello");

Maybe a bug in dmd?

Also, I build some dlang.org docs individually and CODE_HIGHLIGHT is 
inserting a line break in the html. I think this is because the macro 
has an empty line after it:

CODE_HIGHLIGHT=$(B $(I $0))

MDASH=<nobr>&#x200A;&mdash;&#x200A;</nobr>

I can't tell from git blame when it was introduced, the website html 
doesn't show the line break. Is there a workaround, or just remove the 
empty line?
Jul 26 2014
parent reply Alix Pexton <alix.DOT.pexton gmail.DOT.com> writes:
On 26/07/2014 4:31 PM, Nick Treleaven wrote:
 Hi,
 Ddoc doesn't seem to expand a macro near top of
 http://dlang.org/hash-map.html:

 // The $(CODE_HIGHLIGHT KeyType) is string

 Which is weird because it expands it for 'remove' on this line not far
 below it:

 b.remove("hello");

 Maybe a bug in dmd?
This is because the macro is used within a comment in a code section (between lines of hyphens). Macros are normally expanded within code sections, but inside comments they get ignored. I filed an enhancement request. https://issues.dlang.org/show_bug.cgi?id=13211
 Also, I build some dlang.org docs individually and CODE_HIGHLIGHT is
 inserting a line break in the html. I think this is because the macro
 has an empty line after it:

 CODE_HIGHLIGHT=$(B $(I $0))

 MDASH=<nobr>&#x200A;&mdash;&#x200A;</nobr>

 I can't tell from git blame when it was introduced, the website html
 doesn't show the line break. Is there a workaround, or just remove the
 empty line?
I've reproduced this, it seems it is related to the platform of the file, ie a macro with a blank line after it declared in a file with windows line endings (CR; + LF;) will have a line break on the end but one in file with single character line breaks won't. I filed that one as a bug. https://issues.dlang.org/show_bug.cgi?id=13212 A...
Jul 27 2014
parent Nick Treleaven <ntrel-public yahoo.co.uk> writes:
On 27/07/2014 09:44, Alix Pexton wrote:
 On 26/07/2014 4:31 PM, Nick Treleaven wrote:
 Hi,
 Ddoc doesn't seem to expand a macro near top of
 http://dlang.org/hash-map.html:

 // The $(CODE_HIGHLIGHT KeyType) is string

 Which is weird because it expands it for 'remove' on this line not far
 below it:

 b.remove("hello");

 Maybe a bug in dmd?
This is because the macro is used within a comment in a code section (between lines of hyphens). Macros are normally expanded within code sections, but inside comments they get ignored. I filed an enhancement request. https://issues.dlang.org/show_bug.cgi?id=13211
OK, great.
 Also, I build some dlang.org docs individually and CODE_HIGHLIGHT is
 inserting a line break in the html. I think this is because the macro
 has an empty line after it:

 CODE_HIGHLIGHT=$(B $(I $0))

 MDASH=<nobr>&#x200A;&mdash;&#x200A;</nobr>

 I can't tell from git blame when it was introduced, the website html
 doesn't show the line break. Is there a workaround, or just remove the
 empty line?
I've reproduced this, it seems it is related to the platform of the file, ie a macro with a blank line after it declared in a file with windows line endings (CR; + LF;) will have a line break on the end but one in file with single character line breaks won't. I filed that one as a bug. https://issues.dlang.org/show_bug.cgi?id=13212
Interesting, so assuming the site docs were generated on Linux that's why they are OK. Git on Windows checks out the file as CRLF automagically.
Jul 27 2014