Skip to content

Commit

Permalink
docs(crate): Generate documenation for traits enabled by optional fea…
Browse files Browse the repository at this point in the history
…tures
  • Loading branch information
alerque committed Oct 26, 2024
1 parent d090deb commit 3395f52
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ predicates = "3.1"
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(build)'] }

[package.metadata.docs.rs]
features = ["luamodule", "luajit", "pythonmodule", "wasm"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.git-cliff.git]
protect_breaking_commits = true
commit_parsers = [
Expand Down
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-3.0-only

#![doc = include_str!("../README.md")]
#![cfg_attr(docsrs, feature(doc_cfg))]

mod content;
mod types;
Expand All @@ -10,15 +11,19 @@ pub use content::Chunk;
pub use types::{Case, Locale, StyleGuide};

#[cfg(feature = "cli")]
#[doc(hidden)]
pub mod cli;

#[cfg(feature = "luamodule")]
#[doc(hidden)]
pub mod lua;

#[cfg(feature = "pythonmodule")]
#[doc(hidden)]
pub mod python;

#[cfg(feature = "wasm")]
#[doc(hidden)]
pub mod wasm;

mod en;
Expand Down
6 changes: 4 additions & 2 deletions src/lua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
use crate::*;
use mlua::prelude::*;

pub use crate::types::{Case, Locale, Result, StyleGuide};

#[mlua::lua_module]
fn decasify(lua: &Lua) -> LuaResult<LuaTable> {
let exports = lua.create_table()?;
Expand Down Expand Up @@ -35,6 +33,7 @@ fn decasify(lua: &Lua) -> LuaResult<LuaTable> {
Ok(exports)
}

#[cfg_attr(docsrs, doc(cfg(feature = "luamodule")))]
impl FromLua for Chunk {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
match value {
Expand All @@ -44,6 +43,7 @@ impl FromLua for Chunk {
}
}

#[cfg_attr(docsrs, doc(cfg(feature = "luamodule")))]
impl FromLua for Locale {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
match value {
Expand All @@ -54,6 +54,7 @@ impl FromLua for Locale {
}
}

#[cfg_attr(docsrs, doc(cfg(feature = "luamodule")))]
impl FromLua for Case {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
match value {
Expand All @@ -64,6 +65,7 @@ impl FromLua for Case {
}
}

#[cfg_attr(docsrs, doc(cfg(feature = "luamodule")))]
impl FromLua for StyleGuide {
fn from_lua(value: LuaValue, _: &Lua) -> LuaResult<Self> {
match value {
Expand Down
3 changes: 1 addition & 2 deletions src/python.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// SPDX-FileCopyrightText: © 2023 Caleb Maclennan <caleb@alerque.com>
// SPDX-License-Identifier: LGPL-3.0-only

use crate::*;
use pyo3::prelude::*;

pub use crate::types::{Case, Locale, Result, StyleGuide};

#[pymodule]
fn decasify(module: &Bound<'_, PyModule>) -> PyResult<()> {
module.add_class::<Case>()?;
Expand Down
4 changes: 2 additions & 2 deletions src/wasm.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-FileCopyrightText: © 2023 Caleb Maclennan <caleb@alerque.com>
// SPDX-License-Identifier: LGPL-3.0-only

use crate::*;

use std::result::Result;
use wasm_bindgen::prelude::*;

pub use crate::types::{Case, Locale, StyleGuide};

#[wasm_bindgen]
pub fn case(input: &str, case: Case, locale: Locale, style: StyleGuide) -> Result<String, JsError> {
Ok(crate::case(input, case, locale, style))
Expand Down

0 comments on commit 3395f52

Please sign in to comment.