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

std.exception.assumeUnique ddox has weird example errors #204

Open
schveiguy opened this issue Apr 10, 2018 · 4 comments
Open

std.exception.assumeUnique ddox has weird example errors #204

schveiguy opened this issue Apr 10, 2018 · 4 comments

Comments

@schveiguy
Copy link
Member

Hard to explain, I'm not sure what's happening, but the examples seem to be incorrectly parsed:

https://dlang.org/library/std/exception/assume_unique.html

@Biotronic
Copy link

My first though was the RUNNABLE_EXAMPLE macro was incorrectly expanded - it invokes DIVC, which invokes TC. In the end, the </div> part is escaped before it's included in the page, and the raw example code is dumped verbatim into the generated HTML. The fact the last two examples are not mutilated in this way (they are not using the RUNNABLE_EXAMPLE macro) further indicates this might be the reason.

There seems to be more to it though - ifThrown also uses the RUNNABLE_EXAMPLE macro, and does not exhibit the same issue. Looking at the examples, those which fail contain a function right inside the ---- blocks, and each line starts with an asterisk, while those who work, exhibit neither of those features. Example failing:

 * $(RUNNABLE_EXAMPLE
 * ----
 * string letters() pure
 * {
 *   char[] result = new char['z' - 'a' + 1];
 *   foreach (i, ref e; result)
 *   {
 *     e = cast(char)('a' + i);
 *   }
 *   return result;
 * }
 * ----
 * )

Example working:

$(RUNNABLE_EXAMPLE
--------------------
//Revert to a default value upon an error:
assert("x".to!int().ifThrown(0) == 0);
--------------------
)

I can't get ddox to compile (running into https://issues.dlang.org/show_bug.cgi?id=17508), so figuring out the root cause is kinda hard. Hope this will be helpful to someone.

@schveiguy
Copy link
Member Author

schveiguy commented May 8, 2018

Hm... it's possible to use the d auto tester to check some theories. We can create a PR that adds * to the example that works, and check the result from the tester.

@wilzbach
Copy link
Member

wilzbach commented May 8, 2018

I can't get ddox to compile (running into https://issues.dlang.org/show_bug.cgi?id=17508)

Did you try to build it with mscoff?

@wilzbach
Copy link
Member

wilzbach commented May 8, 2018

The problem is that DDox throws away newline when processing macros. We can workaround this directly at dlang.org: dlang/dlang.org#2364

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

3 participants