Bug 9497 – ddoc: add support for handling undefined macros
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-10T14:16:54Z
Last change time
2018-03-30T06:54:41Z
Keywords
preapproved, pull
Assigned to
No Owner
Creator
Andrei Alexandrescu
Comments
Comment #0 by andrei — 2013-02-10T14:16:54Z
Currently an undefined ddoc macro expands to the empty string. This makes typos in macros and ill-configured builds difficult to debug.
Handling undefined macros should be done with a predefined macro DDOC_UNDEFINED_MACRO. If macro XYZ is used as e.g. $(XYZ arg1,arg2) without being defined, it is replaced with $(DDOC_UNDEFINED_MACRO XYZ,arg1,arg2). If in turn DDOC_UNDEFINED_MACRO is undefined, the expansion is the empty string (thus ensuring backward compatibility).
This allows users to define useful behaviors, such as:
a) replace with a comment:
DDOC_UNDEFINED_MACRO=$(DDOC_COMMENT $(DOLLAR)($1 $+))
b) keep verbatim
DDOC_UNDEFINED_MACRO=$(DOLLAR)($1 $+)
c) keep only the argument text
DDOC_UNDEFINED_MACRO=$+
d) replace with a greppable text such that subsequent tools can find all occurrences:
DDOC_UNDEFINED_MACRO=ERROR_UNDEFINED_MACRO: "$1"