Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh|Specs] Not compliant with macros argument text specs #28

Open
Geod24 opened this issue Sep 29, 2015 · 0 comments
Open

[Enh|Specs] Not compliant with macros argument text specs #28

Geod24 opened this issue Sep 29, 2015 · 0 comments

Comments

@Geod24
Copy link
Member

Geod24 commented Sep 29, 2015

Specs says:

The argument text can contain nested parentheses, "" or '' strings, comments, or tags. If stray, unnested parentheses are used, they can be replaced with the entity ( for ( and ) for ).

There are however several problems with this definition:

  1. I don't see how there could be an unmatched ')', as it would be interpreted as the end of the macro argument list. However there could be unmatched '('. I'm not sure how good it is to replace it with HTML entity though, but since we got $(LPAREN), not a big deal.
  2. The 'or tags' apparently refers to XML <tag></tag> (the only other reference to the word 'tag' in this page refers to XML). So this requires quite a lot of complexity for such a small feature, which has a limited interest.
  3. DMD isn't compliant with the definition. Based on my understanding of this spec, I came up with the following test:

Command : dmd -c -Dffoo.html test.d debug.ddoc
debug.ddoc:

DDOC=$(BODY)
DDOC_SUMMARY=[SUMMARY $0]
DDOC_DESCRIPTION=[DESCRIPTION $0]

test.d:

/**
 * Module title
 *
 * $(B (Nested parenthesis))
 * $(B "Double quoted: )")
 * $(B 'Quoted: )')
 * $(B <!-- Commented: ) -->)
 * $(B <tagged>)</tagged>)
 * $(B (Hello)
 *
 */
module doc.test;

Expected output:

<!-- Generated by Ddoc from test.d -->
$(DDOC_SECTIONS [SUMMARY Module title
]
[DESCRIPTION <b>(Nested parenthesis)</b>
 <b>"Double quoted: )"</b>
 <b>'Quoted: )'</b>
 <b><!-- Commented: ) -->)
 <b><tagged>)</tagged></b>
 <b>&#40;Hello</b>
]

Actual output:

<!-- Generated by Ddoc from test.d -->
$(DDOC_SECTIONS [SUMMARY Module title
]
[DESCRIPTION <b>(Nested parenthesis)</b>
 <b>"Double quoted: </b>")
 <b>'Quoted: </b>')
 <b><!-- Commented: ) -->)
 <b><tagged></b></tagged>)
 (B (Hello)</b>

So as you can see DMD gets all but the nested parenthesis wrong (and almost get the HTML/XML comment right). I'm definitely going to do a specs issue / P.R. to remove tags, and will consider the others cases, as supporting string would lead to supporting escaping. I'd rather ask users to use $({L,R}PAREN) whenever needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant