Skip to content

Commit 31a1e3d

Browse files
committed
Document features, fix documentation links
1 parent 4a4370c commit 31a1e3d

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
uses: actions-rs/cargo@v1
4242
env:
4343
LIBCLANG_PATH: ${{ runner.temp }}/llvm-${{ matrix.llvm }}/lib
44+
RUSTDOCFLAGS: --cfg docs
4445
with:
4546
command: doc
4647
args: --release

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(non_upper_case_globals)]
44
#![allow(non_camel_case_types)]
55
#![allow(non_snake_case)]
6+
#![cfg_attr(docs, feature(doc_cfg))]
67

78
#[macro_use]
89
pub mod macros;
@@ -433,7 +434,8 @@ pub use ext_php_rs_derive::php_startup;
433434
pub mod prelude {
434435
pub use crate::php::module::ModuleBuilder;
435436
pub use crate::php::types::callable::Callable;
436-
#[cfg(feature = "closure")]
437+
#[cfg(any(docs, feature = "closure"))]
438+
#[cfg_attr(docs, doc(cfg(feature = "closure")))]
437439
pub use crate::php::types::closure::Closure;
438440
pub use crate::php_class;
439441
pub use crate::php_const;

src/php/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Objects relating to PHP and the Zend engine.
22
3-
#[cfg(feature = "alloc")]
3+
#[cfg(any(docs, feature = "alloc"))]
4+
#[cfg_attr(docs, doc(cfg(feature = "alloc")))]
45
pub mod alloc;
56

67
pub mod args;

src/php/types/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
pub mod array;
55
pub mod binary;
66
pub mod callable;
7-
#[cfg(feature = "closure")]
7+
#[cfg(any(docs, feature = "closure"))]
8+
#[cfg_attr(docs, doc(cfg(feature = "closure")))]
89
pub mod closure;
910
pub mod long;
1011
pub mod object;

src/php/types/object.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ where
353353
///
354354
/// This must be statically allocated, and is usually done through the [`macro@php_class`]
355355
/// macro.
356+
///
357+
/// [`macro@php_class`]: crate::php_class
356358
fn get_metadata() -> &'static ClassMetadata<Self>;
357359

358360
/// Attempts to retrieve a property from the class object.
@@ -369,7 +371,7 @@ where
369371
/// # Safety
370372
///
371373
/// Caller must guarantee that the object the function is called on is immediately followed
372-
/// by a [`zend_object`], which is true when the object was instantiated from [`ZendClassObject`].
374+
/// by a [`zend_object`], which is true when the object was instantiated by PHP.
373375
unsafe fn get_property<'a, T: FromZval<'a>>(&'a self, name: &str) -> Option<T> {
374376
let obj = ZendClassObject::<Self>::from_obj_ptr(self)?;
375377
let zv = obj.std.get_property(name).ok()?;
@@ -391,7 +393,7 @@ where
391393
/// # Safety
392394
///
393395
/// Caller must guarantee that the object the function is called on is immediately followed
394-
/// by a [`zend_object`], which is true when the object was instantiated from [`ZendClassObject`].
396+
/// by a [`zend_object`], which is true when the object was instantiated by PHP.
395397
unsafe fn set_property(&mut self, name: &str, value: impl IntoZval) -> Option<()> {
396398
let obj = ZendClassObject::<Self>::from_obj_ptr(self)?;
397399
obj.std.set_property(name, value).ok()?;

0 commit comments

Comments
 (0)