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

Add new macro REF, a variadic and more general XREF #1184

Merged
merged 1 commit into from Jan 13, 2016

Conversation

JakobOvrum
Copy link
Member

Usage is like:

$(REF File.writeln, std, stdio)
$(REF splitter, std, algorithm, iteration)
$(REF_ALTTEXT forward range, isForwardRange, std, range, primitives)

Added to dlang.org.ddoc because that's where XREF is defined. Can be used to link to symbols rooted in std, core, etc or any other root package.

Implementation is a bit messy. I don't know quite why, but using TAIL instead of those helper macros didn't work. Commas showed up in the output.

Will implement for DDox output ASAP.

@JakobOvrum
Copy link
Member Author

Pushed a DDox implementation but I have no clue how to test it.

JakobOvrum pushed a commit to JakobOvrum/phobos that referenced this pull request Jan 8, 2016
@JakobOvrum
Copy link
Member Author

Pushed dlang/phobos/pull/3911 as an example of how it replaces existing macros.

@CyberShadow
Copy link
Member

I don't know quite why, but using TAIL instead of those helper macros didn't work. Commas showed up in the output.

IIRC the situation is something along the lines of - some of the parameter macros (don't remember which exactly, one of $0 / $+ / etc.) pass their content as a series of parameters (which get expanded to $1/$2/...), but some pass it as a single string. This is what allows $(COMMA) to work inside nested macros AFAIU.

PREFIX_DOT_SKIP=$(PREFIX_DOT $+)
PREFIX_UNDERSCORE=_$1$(PREFIX_UNDERSCORE $+)
PREFIX_UNDERSCORE_SKIP=$(PREFIX_UNDERSCORE $+)
PREFIX_UNDERSCORE_SKIP2=$(PREFIX_UNDERSCORE_SKIP $+)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See @adamdruppe 's recent PR for simple macros that prefix with dots, underscores etc.

@JakobOvrum JakobOvrum force-pushed the variadic_xref branch 2 times, most recently from 9f9189b to baa4851 Compare January 10, 2016 03:48
@JakobOvrum
Copy link
Member Author

Moved the new *_PREFIXED macros from std.ddoc to macros.ddoc and used them in REF (which is in dlang.ddoc).

@JakobOvrum
Copy link
Member Author

OK, can confirm that the DDox override works.

@JakobOvrum
Copy link
Member Author

Removed duplicate DOT_PREFIXED_SKIP definition from std-ddox.ddoc.

@JakobOvrum
Copy link
Member Author

Alright, now REF and MREF and all helper macros are all in dlang.org.ddoc. Also changed MREF to use $(D …) for the link text.

edit: Actually, most existing module links in Phobos do not use $(D …), so I reverted that.

@JakobOvrum
Copy link
Member Author

REF and MREF now use ROOT_DIR in their paths.

CyberShadow added a commit that referenced this pull request Jan 13, 2016
Add new macro REF, a variadic and more general XREF
@CyberShadow CyberShadow merged commit 28fcaf5 into dlang:master Jan 13, 2016
@CyberShadow
Copy link
Member

LGTM :)

JakobOvrum pushed a commit to JakobOvrum/phobos that referenced this pull request Jan 13, 2016
@JakobOvrum
Copy link
Member Author

Thanks!

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