Skip to content

Commit

Permalink
Update documentation references
Browse files Browse the repository at this point in the history
Using rustdoc links (see RFC rust-lang/rfcs#1946)
  • Loading branch information
khvzak committed Oct 11, 2021
1 parent 559f9e6 commit ed48b11
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 127 deletions.
26 changes: 14 additions & 12 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,56 +96,58 @@ pub enum Error {
/// [`Thread::status`] can be used to check if the coroutine can be resumed without causing this
/// error.
///
/// [`Thread::resume`]: struct.Thread.html#method.resume
/// [`Thread::status`]: struct.Thread.html#method.status
/// [`Thread::resume`]: crate::Thread::resume
/// [`Thread::status`]: crate::Thread::status
CoroutineInactive,
/// An [`AnyUserData`] is not the expected type in a borrow.
///
/// This error can only happen when manually using [`AnyUserData`], or when implementing
/// metamethods for binary operators. Refer to the documentation of [`UserDataMethods`] for
/// details.
///
/// [`AnyUserData`]: struct.AnyUserData.html
/// [`UserDataMethods`]: trait.UserDataMethods.html
/// [`AnyUserData`]: crate::AnyUserData
/// [`UserDataMethods`]: crate::UserDataMethods
UserDataTypeMismatch,
/// An [`AnyUserData`] borrow failed because it has been destructed.
///
/// This error can happen either due to to being destructed in a previous __gc, or due to being
/// destructed from exiting a `Lua::scope` call.
///
/// [`AnyUserData`]: struct.AnyUserData.html
/// [`AnyUserData`]: crate::AnyUserData
UserDataDestructed,
/// An [`AnyUserData`] immutable borrow failed because it is already borrowed mutably.
///
/// This error can occur when a method on a [`UserData`] type calls back into Lua, which then
/// tries to call a method on the same [`UserData`] type. Consider restructuring your API to
/// prevent these errors.
///
/// [`AnyUserData`]: struct.AnyUserData.html
/// [`UserData`]: trait.UserData.html
/// [`AnyUserData`]: crate::AnyUserData
/// [`UserData`]: crate::UserData
UserDataBorrowError,
/// An [`AnyUserData`] mutable borrow failed because it is already borrowed.
///
/// This error can occur when a method on a [`UserData`] type calls back into Lua, which then
/// tries to call a method on the same [`UserData`] type. Consider restructuring your API to
/// prevent these errors.
///
/// [`AnyUserData`]: struct.AnyUserData.html
/// [`UserData`]: trait.UserData.html
/// [`AnyUserData`]: crate::AnyUserData
/// [`UserData`]: crate::UserData
UserDataBorrowMutError,
/// A [`MetaMethod`] operation is restricted (typically for `__gc` or `__metatable`).
///
/// [`MetaMethod`]: enum.MetaMethod.html
/// [`MetaMethod`]: crate::MetaMethod
MetaMethodRestricted(StdString),
/// A [`MetaMethod`] (eg. `__index` or `__newindex`) has invalid type.
///
/// [`MetaMethod`]: enum.MetaMethod.html
/// [`MetaMethod`]: crate::MetaMethod
MetaMethodTypeError {
method: StdString,
type_name: &'static str,
message: Option<StdString>,
},
/// A `RegistryKey` produced from a different Lua state was used.
/// A [`RegistryKey`] produced from a different Lua state was used.
///
/// [`RegistryKey`]: crate::RegistryKey
MismatchedRegistryKey,
/// A Rust callback returned `Err`, raising the contained `Error` as a Lua error.
CallbackError {
Expand Down
2 changes: 1 addition & 1 deletion src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl<'lua> Function<'lua> {
/// # }
/// ```
///
/// [`AsyncThread`]: struct.AsyncThread.html
/// [`AsyncThread`]: crate::AsyncThread
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn call_async<'fut, A, R>(&self, args: A) -> LocalBoxFuture<'fut, Result<R>>
Expand Down
2 changes: 1 addition & 1 deletion src/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::util::callback_error;
/// found in the [Lua 5.3 documentation][lua_doc].
///
/// [lua_doc]: https://www.lua.org/manual/5.3/manual.html#lua_Debug
/// [`Lua::set_hook`]: struct.Lua.html#method.set_hook
/// [`Lua::set_hook`]: crate::Lua::set_hook
#[derive(Clone)]
pub struct Debug<'a> {
ar: *mut lua_Debug,
Expand Down
46 changes: 23 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,24 @@
//! to [`Function`]s and [`UserData`].
//!
//! [Lua programming language]: https://www.lua.org/
//! [`Lua`]: struct.Lua.html
//! [executing]: struct.Chunk.html#method.exec
//! [evaluating]: struct.Chunk.html#method.eval
//! [globals]: struct.Lua.html#method.globals
//! [`ToLua`]: trait.ToLua.html
//! [`FromLua`]: trait.FromLua.html
//! [`ToLuaMulti`]: trait.ToLuaMulti.html
//! [`FromLuaMulti`]: trait.FromLuaMulti.html
//! [`Function`]: struct.Function.html
//! [`UserData`]: trait.UserData.html
//! [`UserDataFields`]: trait.UserDataFields.html
//! [`UserDataMethods`]: trait.UserDataMethods.html
//! [`LuaSerdeExt`]: serde/trait.LuaSerdeExt.html
//! [`Value`]: enum.Value.html
//! [`create_async_function`]: struct.Lua.html#method.create_async_function
//! [`call_async`]: struct.Function.html#method.call_async
//! [`AsyncThread`]: struct.AsyncThread.html
//! [`Future`]: ../futures_core/future/trait.Future.html
//! [`Lua`]: crate::Lua
//! [executing]: crate::Chunk::exec
//! [evaluating]: crate::Chunk::eval
//! [globals]: crate::Lua::globals
//! [`ToLua`]: crate::ToLua
//! [`FromLua`]: crate::FromLua
//! [`ToLuaMulti`]: crate::ToLuaMulti
//! [`FromLuaMulti`]: crate::FromLuaMulti
//! [`Function`]: crate::Function
//! [`UserData`]: crate::UserData
//! [`UserDataFields`]: crate::UserDataFields
//! [`UserDataMethods`]: crate::UserDataMethods
//! [`LuaSerdeExt`]: crate::LuaSerdeExt
//! [`Value`]: crate::Value
//! [`create_async_function`]: crate::Lua::create_async_function
//! [`call_async`]: crate::Function::call_async
//! [`AsyncThread`]: crate::AsyncThread
//! [`Future`]: std::future::Future
//! [`serde::Serialize`]: https://docs.serde.rs/serde/ser/trait.Serialize.html
//! [`serde::Deserialize`]: https://docs.serde.rs/serde/de/trait.Deserialize.html

Expand Down Expand Up @@ -98,6 +98,8 @@ mod userdata;
mod util;
mod value;

pub mod prelude;

pub use crate::{ffi::lua_CFunction, ffi::lua_State};

pub use crate::error::{Error, ExternalError, ExternalResult, Result};
Expand All @@ -120,13 +122,11 @@ pub use crate::value::{FromLua, FromLuaMulti, MultiValue, Nil, ToLua, ToLuaMulti
pub use crate::thread::AsyncThread;

#[cfg(feature = "serialize")]
#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))]
#[doc(inline)]
pub use crate::serde::{
de::Options as DeserializeOptions, ser::Options as SerializeOptions, LuaSerdeExt,
};

pub mod prelude;
#[cfg(feature = "serialize")]
#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))]
pub mod serde;
Expand Down Expand Up @@ -185,9 +185,9 @@ extern crate mlua_derive;
///
/// Everything else should work.
///
/// [`AsChunk`]: trait.AsChunk.html
/// [`UserData`]: trait.UserData.html
/// [`ToLua`]: trait.ToLua.html
/// [`AsChunk`]: crate::AsChunk
/// [`UserData`]: crate::UserData
/// [`ToLua`]: crate::ToLua
#[cfg(any(feature = "macros"))]
#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
pub use mlua_derive::chunk;
Expand Down
45 changes: 23 additions & 22 deletions src/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl Lua {
///
/// See [`StdLib`] documentation for a list of unsafe modules that cannot be loaded.
///
/// [`StdLib`]: struct.StdLib.html
/// [`StdLib`]: crate::StdLib
#[allow(clippy::new_without_default)]
pub fn new() -> Lua {
mlua_expect!(
Expand All @@ -237,7 +237,7 @@ impl Lua {
///
/// See [`StdLib`] documentation for a list of unsafe modules that cannot be loaded.
///
/// [`StdLib`]: struct.StdLib.html
/// [`StdLib`]: crate::StdLib
pub fn new_with(libs: StdLib, options: LuaOptions) -> Result<Lua> {
if libs.contains(StdLib::DEBUG) {
return Err(Error::SafetyError(
Expand Down Expand Up @@ -271,7 +271,7 @@ impl Lua {
/// # Safety
/// The created Lua state will not have safety guarantees and allow to load C modules.
///
/// [`StdLib`]: struct.StdLib.html
/// [`StdLib`]: crate::StdLib
pub unsafe fn unsafe_new_with(libs: StdLib, options: LuaOptions) -> Lua {
ffi::keep_lua_symbols();
Self::inner_new(libs, options)
Expand Down Expand Up @@ -513,7 +513,7 @@ impl Lua {
///
/// Use the [`StdLib`] flags to specify the libraries you want to load.
///
/// [`StdLib`]: struct.StdLib.html
/// [`StdLib`]: crate::StdLib
pub fn load_from_std_lib(&self, libs: StdLib) -> Result<()> {
if self.safe && libs.contains(StdLib::DEBUG) {
return Err(Error::SafetyError(
Expand Down Expand Up @@ -700,8 +700,8 @@ impl Lua {
/// # }
/// ```
///
/// [`HookTriggers`]: struct.HookTriggers.html
/// [`HookTriggers.every_nth_instruction`]: struct.HookTriggers.html#field.every_nth_instruction
/// [`HookTriggers`]: crate::HookTriggers
/// [`HookTriggers.every_nth_instruction`]: crate::HookTriggers::every_nth_instruction
pub fn set_hook<F>(&self, triggers: HookTriggers, callback: F) -> Result<()>
where
F: 'static + MaybeSend + FnMut(&Lua, Debug) -> Result<()>,
Expand Down Expand Up @@ -906,10 +906,11 @@ impl Lua {
/// similar on the returned builder. Code is not even parsed until one of these methods is
/// called.
///
/// If this `Lua` was created with `unsafe_new`, `load` will automatically detect and load
/// If this `Lua` was created with [`unsafe_new`], `load` will automatically detect and load
/// chunks of either text or binary type, as if passing `bt` mode to `luaL_loadbufferx`.
///
/// [`Chunk::exec`]: struct.Chunk.html#method.exec
/// [`Chunk::exec`]: crate::Chunk::exec
/// [`unsafe_new`]: #method.unsafe_new
#[track_caller]
pub fn load<'lua, 'a, S>(&'lua self, source: &'a S) -> Chunk<'lua, 'a>
where
Expand Down Expand Up @@ -1105,8 +1106,8 @@ impl Lua {
/// # }
/// ```
///
/// [`ToLua`]: trait.ToLua.html
/// [`ToLuaMulti`]: trait.ToLuaMulti.html
/// [`ToLua`]: crate::ToLua
/// [`ToLuaMulti`]: crate::ToLuaMulti
pub fn create_function<'lua, 'callback, A, R, F>(&'lua self, func: F) -> Result<Function<'lua>>
where
'lua: 'callback,
Expand Down Expand Up @@ -1191,8 +1192,8 @@ impl Lua {
/// }
/// ```
///
/// [`Thread`]: struct.Thread.html
/// [`AsyncThread`]: struct.AsyncThread.html
/// [`Thread`]: crate::Thread
/// [`AsyncThread`]: crate::AsyncThread
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn create_async_function<'lua, 'callback, A, R, F, FR>(
Expand Down Expand Up @@ -1484,7 +1485,7 @@ impl Lua {
/// Be warned, garbage collection of values held inside the registry is not automatic, see
/// [`RegistryKey`] for more details.
///
/// [`RegistryKey`]: struct.RegistryKey.html
/// [`RegistryKey`]: crate::RegistryKey
pub fn create_registry_value<'lua, T: ToLua<'lua>>(&'lua self, t: T) -> Result<RegistryKey> {
let t = t.to_lua(self)?;
unsafe {
Expand Down Expand Up @@ -2206,7 +2207,7 @@ impl Lua {

/// Returned from [`Lua::load`] and is used to finalize loading and executing Lua main chunks.
///
/// [`Lua::load`]: struct.Lua.html#method.load
/// [`Lua::load`]: crate::Lua::load
#[must_use = "`Chunk`s do nothing unless one of `exec`, `eval`, `call`, or `into_function` are called on them"]
pub struct Chunk<'lua, 'a> {
lua: &'lua Lua,
Expand All @@ -2226,7 +2227,7 @@ pub enum ChunkMode {
/// Trait for types [loadable by Lua] and convertible to a [`Chunk`]
///
/// [loadable by Lua]: https://www.lua.org/manual/5.3/manual.html#3.3.2
/// [`Chunk`]: struct.Chunk.html
/// [`Chunk`]: crate::Chunk
pub trait AsChunk<'lua> {
/// Returns chunk data (can be text or binary)
fn source(&self) -> &[u8];
Expand Down Expand Up @@ -2284,7 +2285,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
/// Lua does not check the consistency of binary chunks, therefore this mode is allowed only
/// for instances created with [`Lua::unsafe_new`].
///
/// [`Lua::unsafe_new`]: struct.Lua.html#method.unsafe_new
/// [`Lua::unsafe_new`]: crate::Lua::unsafe_new
pub fn set_mode(mut self, mode: ChunkMode) -> Chunk<'lua, 'a> {
self.mode = Some(mode);
self
Expand All @@ -2300,11 +2301,11 @@ impl<'lua, 'a> Chunk<'lua, 'a> {

/// Asynchronously execute this chunk of code.
///
/// See [`Chunk::exec`] for more details.
/// See [`exec`] for more details.
///
/// Requires `feature = "async"`
///
/// [`Chunk::exec`]: struct.Chunk.html#method.exec
/// [`exec`]: #method.exec
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn exec_async<'fut>(self) -> LocalBoxFuture<'fut, Result<()>>
Expand Down Expand Up @@ -2340,11 +2341,11 @@ impl<'lua, 'a> Chunk<'lua, 'a> {

/// Asynchronously evaluate the chunk as either an expression or block.
///
/// See [`Chunk::eval`] for more details.
/// See [`eval`] for more details.
///
/// Requires `feature = "async"`
///
/// [`Chunk::eval`]: struct.Chunk.html#method.eval
/// [`eval`]: #method.eval
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn eval_async<'fut, R>(self) -> LocalBoxFuture<'fut, Result<R>>
Expand Down Expand Up @@ -2378,11 +2379,11 @@ impl<'lua, 'a> Chunk<'lua, 'a> {

/// Load the chunk function and asynchronously call it with the given arguments.
///
/// See [`Chunk::call`] for more details.
/// See [`call`] for more details.
///
/// Requires `feature = "async"`
///
/// [`Chunk::call`]: struct.Chunk.html#method.call
/// [`call`]: #method.call
#[cfg(feature = "async")]
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
pub fn call_async<'fut, A, R>(self, args: A) -> LocalBoxFuture<'fut, Result<R>>
Expand Down
4 changes: 2 additions & 2 deletions src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ impl<'lua> FromLuaMulti<'lua> for MultiValue<'lua> {
/// # }
/// ```
///
/// [`FromLua`]: trait.FromLua.html
/// [`MultiValue`]: struct.MultiValue.html
/// [`FromLua`]: crate::FromLua
/// [`MultiValue`]: crate::MultiValue
#[derive(Debug, Clone)]
pub struct Variadic<T>(Vec<T>);

Expand Down
4 changes: 3 additions & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Re-exports most types with an extra `Lua*` prefix to prevent name clashes.

#[doc(no_inline)]
pub use crate::{
AnyUserData as LuaAnyUserData, Chunk as LuaChunk, Error as LuaError,
ExternalError as LuaExternalError, ExternalResult as LuaExternalResult, FromLua, FromLuaMulti,
Expand All @@ -14,10 +15,11 @@ pub use crate::{
};

#[cfg(feature = "async")]
#[doc(no_inline)]
pub use crate::AsyncThread as LuaAsyncThread;

#[cfg(feature = "serialize")]
#[doc(inline)]
#[doc(no_inline)]
pub use crate::{
DeserializeOptions as LuaDeserializeOptions, LuaSerdeExt,
SerializeOptions as LuaSerializeOptions,
Expand Down
Loading

0 comments on commit ed48b11

Please sign in to comment.