Add stab tag for metamethods

This commit is contained in:
lumi 2025-06-26 00:39:22 +10:00
parent cbb47840e4
commit da5acd6bc8
Signed by: luaneko
GPG Key ID: 406809B8763FF07A
2 changed files with 11 additions and 7 deletions

View File

@ -9,12 +9,12 @@ use std::{
#[allow(non_camel_case_types)]
pub mod stub_types {
pub struct any;
pub type nil = ();
pub struct nil;
pub type boolean = bool;
pub type lightuserdata = *mut ();
pub type number = f64;
pub type integer = i64;
pub type string = &'static str;
pub struct lightuserdata;
pub struct number;
pub struct integer;
pub type string = String;
pub struct table;
pub struct function;
pub struct userdata;

View File

@ -763,13 +763,13 @@ 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 is a C/FFI function." style="float: right; 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 is a Lua function." style="float: right; 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>"#
]));
}
@ -799,6 +799,10 @@ fn document_metamethod(func: &mut ImplItemFn, method: Metamethod) {
_ => format!("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>"#
]));
func.attrs.push(parse_quote!(#[doc = ""]));
func.attrs.push(parse_quote!(#[doc = #s]));
}