-
Notifications
You must be signed in to change notification settings - Fork 2
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
idea: new syntax #4
Comments
Is there any way to bootstrap? Use this crate to improve documentation for itself. |
Yeah I'm planning to make use of the new features within docify as they get added. The tricky thing is it's not actually possible to use all of docify fully within docify at least on the macro side of the crate because you end up with a circular dependency. This is why most of the tests are hoisted to the top level of the crate. |
similar issue mersinvald/aquamarine#5 |
btw, yes it seems to be a fundamental issue in rust atm that you can't generate an inner attribute from a macro. If we could write custom inner attributes this would be different, but we cannot. even if you put a macro like this in another crate: macro_rules! my_macro {
() => {
//! hey
}
} and then in the main crate call foo::my_macro!(); as the first line, it won't work because the macro invocation itself already puts us in item position, and there is no way to do custom inner attributes update: MIGHT be possible if we remove the semi-colon and try to force the macro to not be item position error: macro rhs must be delimited
--> bar/src/lib.rs:3:11
|
3 | () => //! hey
| ^^^^^^^
error: could not document `bar` so decl macros can't do it, will try proc nope, totally impossible: #[proc_macro]
pub fn my_macro(_: TokenStream) -> TokenStream {
"//! hey".parse().unwrap()
} bar::my_macro!() bar::my_macro! {} bar::my_macro!();
|
Yandros proposed a new syntax that looks like this:
Originally mentioned here: paritytech/substrate#14672 (comment)
If we were to go with this syntax, we would finally be able to limit expansion of docify embeds to only be attempted if the caller is
#[cfg(doc)]
which we currently lack the context information to be able to do, and which is currently impossible in#[doc = ..]
position but is possible for an "outer attribute" approach like this.The text was updated successfully, but these errors were encountered: