Improve doc
This commit is contained in:
@@ -798,55 +798,73 @@ fn inject_merged_drop(registry: &mut Registry, lua: Option<&LuaFunction>) -> Res
|
||||
|
||||
fn document_ffi_function(func: &mut ImplItemFn) {
|
||||
func.attrs.insert(0, parse_quote!(#[doc =
|
||||
r#"<span class="stab" title="This function is implemented in Rust and called via FFI." style="float: right; background: #fff5d6; font-weight: 500; margin-left: 3px; padding-left: 5px; padding-right: 5px;">FFI</span>"#
|
||||
r#"<span
|
||||
class="stab"
|
||||
title="This function is implemented in Rust and called via FFI."
|
||||
style="float: right; background: #fff5d6; font-weight: 500; margin-left: 3px; padding-left: 5px; padding-right: 5px;"
|
||||
>FFI</span>"#
|
||||
]));
|
||||
}
|
||||
|
||||
fn document_lua_function(func: &mut ImplItemFn) {
|
||||
func.attrs.insert(0, parse_quote!(#[doc =
|
||||
r#"<span class="stab" title="This function is implemented in Lua." style="float: right; background: #ebf5ff; font-weight: 500; margin-left: 3px; padding-left: 5px; padding-right: 5px;">Lua</span>"#
|
||||
r#"<span
|
||||
class="stab"
|
||||
title="This function is implemented in Lua."
|
||||
style="float: right; background: #ebf5ff; font-weight: 500; margin-left: 3px; padding-left: 5px; padding-right: 5px;"
|
||||
>Lua</span>"#
|
||||
]));
|
||||
}
|
||||
|
||||
fn document_async(func: &mut ImplItemFn) {
|
||||
func.attrs.insert(0, parse_quote!(#[doc =
|
||||
r#"<span class="stab" title="This function is asynchronous." style="float: right; background: #ebf5ff; margin-left: 3px; padding-left: 5px; padding-right: 5px;">Async</span>"#
|
||||
r#"<span
|
||||
class="stab"
|
||||
title="This function is asynchronous and will yield the calling thread."
|
||||
style="float: right; background: #ebf5ff; margin-left: 3px; padding-left: 5px; padding-right: 5px;"
|
||||
>Async</span>"#
|
||||
]));
|
||||
}
|
||||
|
||||
fn document_metamethod(func: &mut ImplItemFn, method: Metamethod) {
|
||||
let s = match method {
|
||||
Metamethod::Eq => "This is a metamethod which is called by the `==` operator.",
|
||||
Metamethod::Len => "This is a metamethod which is called by the `#` operator.",
|
||||
Metamethod::Lt => "This is a metamethod which is called by the `<` operator.",
|
||||
Metamethod::Le => "This is a metamethod which is called by the `<=` operator.",
|
||||
Metamethod::Concat => "This is a metamethod which is called by the `..` operator.",
|
||||
Metamethod::Call => {
|
||||
"This is a metamethod which can be called by calling `(...)` on the value directly."
|
||||
}
|
||||
Metamethod::Add => "This is a metamethod which is called by the `+` operator.",
|
||||
Metamethod::Sub => "This is a metamethod which is called by the `-` operator.",
|
||||
Metamethod::Mul => "This is a metamethod which is called by the `*` operator.",
|
||||
Metamethod::Div => "This is a metamethod which is called by the `/` operator.",
|
||||
Metamethod::Mod => "This is a metamethod which is called by the `%` operator.",
|
||||
Metamethod::Pow => "This is a metamethod which is called by the `^` operator.",
|
||||
Metamethod::Unm => "This is a metamethod which is called by the `-` operator.",
|
||||
Metamethod::ToString => {
|
||||
"This is a metamethod which is called by the [`tostring(...)`](https://www.lua.org/manual/5.1/manual.html#pdf-tostring) built-in function."
|
||||
}
|
||||
Metamethod::Pairs => {
|
||||
"This is a metamethod which is called by the [`pairs(...)`](https://www.lua.org/manual/5.1/manual.html#pdf-pairs) built-in function."
|
||||
}
|
||||
Metamethod::Ipairs => {
|
||||
"This is a metamethod which is called by the [`ipairs(...)`](https://www.lua.org/manual/5.1/manual.html#pdf-ipairs) built-in function."
|
||||
}
|
||||
_ => "This is a metamethod and cannot be called directly.",
|
||||
};
|
||||
|
||||
func.attrs.insert(0, parse_quote!(#[doc =
|
||||
r#"<span class="stab" title="This function is a metamethod." style="float: right; background: #ebf5ff; margin-left: 3px; padding-left: 5px; padding-right: 5px;">Metamethod</span>"#
|
||||
r#"<span
|
||||
class="stab"
|
||||
title="This function is a metamethod."
|
||||
style="float: right; background: #ebf5ff; margin-left: 3px; padding-left: 5px; padding-right: 5px;"
|
||||
>Metamethod</span>"#
|
||||
]));
|
||||
|
||||
let doc = match method {
|
||||
Metamethod::Eq => "This function is a metamethod which is called by the `==` operator.",
|
||||
Metamethod::Len => "This function is a metamethod which is called by the `#` operator.",
|
||||
Metamethod::Lt => "This function is a metamethod which is called by the `<` operator.",
|
||||
Metamethod::Le => "This function is a metamethod which is called by the `<=` operator.",
|
||||
Metamethod::Concat => "This function is a metamethod which is called by the `..` operator.",
|
||||
Metamethod::Call => {
|
||||
"This function is a metamethod which can be called by calling `(...)` on the value directly."
|
||||
}
|
||||
Metamethod::Add => "This function is a metamethod which is called by the `+` operator.",
|
||||
Metamethod::Sub => "This function is a metamethod which is called by the `-` operator.",
|
||||
Metamethod::Mul => "This function is a metamethod which is called by the `*` operator.",
|
||||
Metamethod::Div => "This function is a metamethod which is called by the `/` operator.",
|
||||
Metamethod::Mod => "This function is a metamethod which is called by the `%` operator.",
|
||||
Metamethod::Pow => "This function is a metamethod which is called by the `^` operator.",
|
||||
Metamethod::Unm => "This function is a metamethod which is called by the `-` operator.",
|
||||
Metamethod::ToString => {
|
||||
"This function is a metamethod which is called by the [`tostring(...)`](https://www.lua.org/manual/5.1/manual.html#pdf-tostring) built-in function."
|
||||
}
|
||||
Metamethod::Pairs => {
|
||||
"This function is a metamethod which is called by the [`pairs(...)`](https://www.lua.org/manual/5.1/manual.html#pdf-pairs) built-in function."
|
||||
}
|
||||
Metamethod::Ipairs => {
|
||||
"This function is a metamethod which is called by the [`ipairs(...)`](https://www.lua.org/manual/5.1/manual.html#pdf-ipairs) built-in function."
|
||||
}
|
||||
_ => "This function is a metamethod and cannot be called directly.",
|
||||
};
|
||||
|
||||
func.attrs.push(parse_quote!(#[doc = ""]));
|
||||
func.attrs.push(parse_quote!(#[doc = #s]));
|
||||
func.attrs.push(parse_quote!(#[doc = "# Metamethod"]));
|
||||
func.attrs.push(parse_quote!(#[doc = ""]));
|
||||
func.attrs.push(parse_quote!(#[doc = #doc]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user