From 78c2d40cb8941d0ebfd5efb083b5a509d5c7bc4b Mon Sep 17 00:00:00 2001 From: mejrs Date: Sun, 2 May 2021 21:10:53 +0200 Subject: [PATCH 01/16] install doc_cfg feature and workflow --- .github/workflows/ci.yml | 17 +++++++++++++++++ pyo3-macros-backend/src/lib.rs | 1 + pyo3-macros/src/lib.rs | 1 + src/lib.rs | 1 + 4 files changed, 20 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ff4252a..32fd8299 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,6 +173,23 @@ jobs: # Once cargo's `resolver = "2"` is stable (~ MSRV Rust 1.52), remove this. PYO3_CI: 1 + + docs: + name: docs + needs: [fmt] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + toolchain: nightly + override: true + - name: "Build docs with docsrs flag" + run: cargo doc --no-deps --features=default,multiple-pymethods,extension-module,num-bigint,num-complex,hashbrown,serde,nightly + env: + # docsrs gates doc_cfg and doc_alias functionality + RUSTDOCFLAGS: --cfg docsrs + coverage: needs: [fmt] runs-on: ubuntu-latest diff --git a/pyo3-macros-backend/src/lib.rs b/pyo3-macros-backend/src/lib.rs index d2198c72..9c990d7f 100644 --- a/pyo3-macros-backend/src/lib.rs +++ b/pyo3-macros-backend/src/lib.rs @@ -1,6 +1,7 @@ // Copyright (c) 2017-present PyO3 Project and Contributors //! This crate contains the implementation of the proc macro attributes +#![cfg_attr(docsrs, feature(doc_cfg))] #![recursion_limit = "1024"] // Listed first so that macros in this module are available in the rest of the crate. diff --git a/pyo3-macros/src/lib.rs b/pyo3-macros/src/lib.rs index 756bb5d8..483e6b39 100644 --- a/pyo3-macros/src/lib.rs +++ b/pyo3-macros/src/lib.rs @@ -2,6 +2,7 @@ //! This crate declares only the proc macro attributes, as a crate defining proc macro attributes //! must not contain any other public items. +#![cfg_attr(docsrs, feature(doc_cfg))] extern crate proc_macro; use proc_macro::TokenStream; diff --git a/src/lib.rs b/src/lib.rs index 69735f74..babbf2c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![cfg_attr(feature = "nightly", feature(specialization))] +#![cfg_attr(docsrs, feature(doc_cfg))] #![allow(clippy::missing_safety_doc)] // FIXME (#698) //! Rust bindings to the Python interpreter. From 800584cfd56b575992d98710cde7c4defb8c5899 Mon Sep 17 00:00:00 2001 From: mejrs Date: Sun, 2 May 2021 21:19:30 +0200 Subject: [PATCH 02/16] added some docsrs tags --- src/lib.rs | 5 +++++ src/types/num.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index babbf2c7..389182ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -160,7 +160,9 @@ mod internal_tricks; // The CPython stable ABI does not include PyBuffer. #[cfg(not(Py_LIMITED_API))] +#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] pub mod buffer; + #[doc(hidden)] pub mod callback; pub mod class; @@ -175,8 +177,11 @@ pub mod ffi; pub mod freelist; mod gil; mod instance; + #[cfg(not(Py_LIMITED_API))] +#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] pub mod marshal; + pub mod once_cell; pub mod panic; pub mod prelude; diff --git a/src/types/num.rs b/src/types/num.rs index 81c0a68f..a9c2b72c 100644 --- a/src/types/num.rs +++ b/src/types/num.rs @@ -357,6 +357,10 @@ mod test_128bit_intergers { } #[cfg(all(feature = "num-bigint", not(any(Py_LIMITED_API, PyPy))))] +#[cfg_attr( + docsrs, + doc(cfg(all(feature = "num-bigint", not(any(Py_LIMITED_API, PyPy))))) +)] mod bigint_conversion { use super::*; use crate::{err, Py}; From 51ad0d2e0a3b5f6779649e7f86c25c611c7941a1 Mon Sep 17 00:00:00 2001 From: mejrs Date: Sun, 2 May 2021 22:51:41 +0200 Subject: [PATCH 03/16] do not use actions/cache --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32fd8299..57a6a005 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -180,7 +180,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/cache@v2 + - uses: actions-rs/toolchain@v1 with: toolchain: nightly override: true From 1c740ecbdcb64524f3fb83be82e65902202fb0a1 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Mon, 3 May 2021 19:50:19 +0200 Subject: [PATCH 04/16] Update .github/workflows/ci.yml Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57a6a005..d49e414d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -185,7 +185,7 @@ jobs: toolchain: nightly override: true - name: "Build docs with docsrs flag" - run: cargo doc --no-deps --features=default,multiple-pymethods,extension-module,num-bigint,num-complex,hashbrown,serde,nightly + run: cargo doc --no-deps --no-default-features --features "macros num-bigint num-complex hashbrown serde multiple-pymethods" env: # docsrs gates doc_cfg and doc_alias functionality RUSTDOCFLAGS: --cfg docsrs From 9a74c7fc656772605e004baa7a88c500f3c5910c Mon Sep 17 00:00:00 2001 From: mejrs Date: Mon, 3 May 2021 20:03:03 +0200 Subject: [PATCH 05/16] impl docsrs in mod.rs --- src/class/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/class/mod.rs b/src/class/mod.rs index 4b7543aa..29315a82 100644 --- a/src/class/mod.rs +++ b/src/class/mod.rs @@ -7,6 +7,7 @@ mod macros; pub mod basic; #[cfg(not(Py_LIMITED_API))] +#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] pub mod buffer; pub mod context; pub mod descr; @@ -23,6 +24,7 @@ pub mod sequence; pub use self::basic::PyObjectProtocol; #[cfg(not(Py_LIMITED_API))] +#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] pub use self::buffer::PyBufferProtocol; pub use self::context::PyContextProtocol; pub use self::descr::PyDescrProtocol; From 624921a83e8bba051a4bdce92be8f81061ef8e95 Mon Sep 17 00:00:00 2001 From: mejrs Date: Mon, 3 May 2021 20:03:27 +0200 Subject: [PATCH 06/16] impl docsrs in /types --- src/types/complex.rs | 10 +++++++++- src/types/dict.rs | 1 + src/types/iterator.rs | 1 + src/types/mod.rs | 3 +++ src/types/module.rs | 1 + src/types/sequence.rs | 1 + src/types/set.rs | 1 + src/types/tuple.rs | 3 +-- 8 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/types/complex.rs b/src/types/complex.rs index 19ad2771..5e0d0f73 100644 --- a/src/types/complex.rs +++ b/src/types/complex.rs @@ -34,6 +34,7 @@ impl PyComplex { } /// Returns `|self|`. #[cfg(not(any(Py_LIMITED_API, PyPy)))] + #[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))] pub fn abs(&self) -> c_double { unsafe { let val = (*(self.as_ptr() as *mut ffi::PyComplexObject)).cval; @@ -42,6 +43,7 @@ impl PyComplex { } /// Returns `self ** other` #[cfg(not(any(Py_LIMITED_API, PyPy)))] + #[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))] pub fn pow(&self, other: &PyComplex) -> &PyComplex { unsafe { self.py() @@ -63,6 +65,7 @@ unsafe fn complex_operation( } #[cfg(not(any(Py_LIMITED_API, PyPy)))] +#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))] impl<'py> Add for &'py PyComplex { type Output = &'py PyComplex; fn add(self, other: &'py PyComplex) -> &'py PyComplex { @@ -74,6 +77,7 @@ impl<'py> Add for &'py PyComplex { } #[cfg(not(any(Py_LIMITED_API, PyPy)))] +#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))] impl<'py> Sub for &'py PyComplex { type Output = &'py PyComplex; fn sub(self, other: &'py PyComplex) -> &'py PyComplex { @@ -85,6 +89,7 @@ impl<'py> Sub for &'py PyComplex { } #[cfg(not(any(Py_LIMITED_API, PyPy)))] +#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))] impl<'py> Mul for &'py PyComplex { type Output = &'py PyComplex; fn mul(self, other: &'py PyComplex) -> &'py PyComplex { @@ -96,6 +101,7 @@ impl<'py> Mul for &'py PyComplex { } #[cfg(not(any(Py_LIMITED_API, PyPy)))] +#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))] impl<'py> Div for &'py PyComplex { type Output = &'py PyComplex; fn div(self, other: &'py PyComplex) -> &'py PyComplex { @@ -107,6 +113,7 @@ impl<'py> Div for &'py PyComplex { } #[cfg(not(any(Py_LIMITED_API, PyPy)))] +#[cfg_attr(docsrs, doc(cfg(not(any(Py_LIMITED_API, PyPy)))))] impl<'py> Neg for &'py PyComplex { type Output = &'py PyComplex; fn neg(self) -> &'py PyComplex { @@ -119,13 +126,14 @@ impl<'py> Neg for &'py PyComplex { } #[cfg(feature = "num-complex")] +#[cfg_attr(docsrs, doc(cfg(feature = "num-complex")))] mod complex_conversion { use super::*; use crate::{FromPyObject, PyErr, PyNativeType, PyObject, PyResult, ToPyObject}; use num_complex::Complex; impl PyComplex { - /// Creates a new Python `PyComplex` object from num_complex::Complex. + /// Creates a new Python `PyComplex` object from `num_complex`'s [`Complex`]. pub fn from_complex>(py: Python, complex: Complex) -> &PyComplex { unsafe { let ptr = ffi::PyComplex_FromDoubles(complex.re.into(), complex.im.into()); diff --git a/src/types/dict.rs b/src/types/dict.rs index abd03958..fa3de68c 100644 --- a/src/types/dict.rs +++ b/src/types/dict.rs @@ -37,6 +37,7 @@ impl PyDict { /// Returns an error on invalid input. In the case of key collisions, /// this keeps the last entry seen. #[cfg(not(PyPy))] + #[cfg_attr(docsrs, doc(cfg(not(PyPy))))] pub fn from_sequence(py: Python, seq: PyObject) -> PyResult<&PyDict> { unsafe { let dict = py.from_owned_ptr::(ffi::PyDict_New()); diff --git a/src/types/iterator.rs b/src/types/iterator.rs index ab936f24..d24e82e8 100644 --- a/src/types/iterator.rs +++ b/src/types/iterator.rs @@ -69,6 +69,7 @@ impl<'p> Iterator for &'p PyIterator { // PyIter_Check does not exist in the limited API until 3.8 #[cfg(any(not(Py_LIMITED_API), Py_3_8))] +#[cfg_attr(docsrs, doc(cfg(any(not(Py_LIMITED_API), Py_3_8))))] impl<'v> PyTryFrom<'v> for PyIterator { fn try_from>(value: V) -> Result<&'v PyIterator, PyDowncastError<'v>> { let value = value.into(); diff --git a/src/types/mod.rs b/src/types/mod.rs index 96459f37..fe3dc653 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -8,6 +8,7 @@ pub use self::bytearray::PyByteArray; pub use self::bytes::PyBytes; pub use self::complex::PyComplex; #[cfg(not(Py_LIMITED_API))] +#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] pub use self::datetime::{ PyDate, PyDateAccess, PyDateTime, PyDelta, PyDeltaAccess, PyTime, PyTimeAccess, PyTzInfo, }; @@ -141,6 +142,7 @@ macro_rules! pyobject_native_type_sized { ($name: ty, $layout: path $(;$generics: ident)*) => { // To prevent inheriting native types with ABI3 #[cfg(not(Py_LIMITED_API))] + #[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] impl $crate::type_object::PySizedLayout<$name> for $layout {} impl<'a, $($generics,)*> $crate::derive_utils::PyBaseTypeUtils for $name { type Dict = $crate::pyclass_slots::PyClassDummySlot; @@ -230,6 +232,7 @@ mod bytearray; mod bytes; mod complex; #[cfg(not(Py_LIMITED_API))] +#[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] mod datetime; mod dict; mod floatob; diff --git a/src/types/module.rs b/src/types/module.rs index 9608e536..a670a5d1 100644 --- a/src/types/module.rs +++ b/src/types/module.rs @@ -112,6 +112,7 @@ impl PyModule { /// /// May fail if the module does not have a `__file__` attribute. #[cfg(not(all(windows, PyPy)))] + #[cfg_attr(docsrs, doc(cfg(not(all(windows, PyPy)))))] pub fn filename(&self) -> PyResult<&str> { use crate::types::PyString; unsafe { diff --git a/src/types/sequence.rs b/src/types/sequence.rs index 423021d0..79fb05a0 100644 --- a/src/types/sequence.rs +++ b/src/types/sequence.rs @@ -188,6 +188,7 @@ impl PySequence { /// number of keys for which `self[key] == value`. #[inline] #[cfg(not(PyPy))] + #[cfg_attr(docsrs, doc(cfg(not(PyPy))))] pub fn count(&self, value: V) -> PyResult where V: ToBorrowedObject, diff --git a/src/types/set.rs b/src/types/set.rs index 3989edfb..cf12faaa 100644 --- a/src/types/set.rs +++ b/src/types/set.rs @@ -324,6 +324,7 @@ impl<'a> std::iter::IntoIterator for &'a PyFrozenSet { } #[cfg(feature = "hashbrown")] +#[cfg_attr(docsrs, doc(cfg(feature = "hashbrown")))] mod hashbrown_hashset_conversion { use super::*; use crate::{FromPyObject, PyObject, PyResult, ToPyObject}; diff --git a/src/types/tuple.rs b/src/types/tuple.rs index 70647a6a..8fe9da85 100644 --- a/src/types/tuple.rs +++ b/src/types/tuple.rs @@ -78,9 +78,8 @@ impl PyTuple { } /// Returns `self` as a slice of objects. - /// - /// Not available when compiled with Py_LIMITED_API. #[cfg(not(Py_LIMITED_API))] + #[cfg_attr(docsrs, doc(cfg(not(Py_LIMITED_API))))] pub fn as_slice(&self) -> &[&PyAny] { // This is safe because &PyAny has the same memory layout as *mut ffi::PyObject, // and because tuples are immutable. From f4b11f61d539bf4d746e80ccbc12d0890be5e5b8 Mon Sep 17 00:00:00 2001 From: mejrs Date: Mon, 3 May 2021 20:03:41 +0200 Subject: [PATCH 07/16] impl docs for conversions --- src/conversion.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conversion.rs b/src/conversion.rs index 5ec8a8e0..45bc4284 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -108,6 +108,7 @@ where T: ToPyObject, { #[cfg(feature = "nightly")] + #[cfg_attr(docsrs, doc(cfg(feature = "nightly")))] default fn with_borrowed_ptr(&self, py: Python, f: F) -> R where F: FnOnce(*mut ffi::PyObject) -> R, @@ -122,6 +123,7 @@ where } #[cfg(feature = "nightly")] +#[cfg_attr(docsrs, doc(cfg(feature = "nightly")))] impl ToBorrowedObject for T where T: ToPyObject + AsPyPointer, From d11de0e15dcbf7267e40ded92331ca4011ad13fc Mon Sep 17 00:00:00 2001 From: mejrs Date: Mon, 3 May 2021 20:03:56 +0200 Subject: [PATCH 08/16] impl docsrs for gil --- src/gil.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gil.rs b/src/gil.rs index 2b30f904..15a7488c 100644 --- a/src/gil.rs +++ b/src/gil.rs @@ -45,9 +45,6 @@ pub(crate) fn gil_is_acquired() -> bool { /// If both the Python interpreter and Python threading are already initialized, /// this function has no effect. /// -/// # Availability -/// This function is not available on PyPy. -/// /// # Panics /// - If the Python interpreter is initialized but Python threading is not, /// a panic occurs. @@ -68,6 +65,7 @@ pub(crate) fn gil_is_acquired() -> bool { /// } /// ``` #[cfg(not(PyPy))] +#[cfg_attr(docsrs, doc(cfg(not(PyPy))))] #[allow(clippy::clippy::collapsible_if)] // for if cfg! pub fn prepare_freethreaded_python() { // Protect against race conditions when Python is not yet initialized and multiple threads @@ -106,9 +104,6 @@ pub fn prepare_freethreaded_python() { /// single process, it is not safe to call this function more than once. (Many such modules will not /// initialize correctly on the second run.) /// -/// # Availability -/// This function is not available on PyPy. -/// /// # Panics /// - If the Python interpreter is already initalized before calling this function. /// @@ -132,6 +127,7 @@ pub fn prepare_freethreaded_python() { /// } /// ``` #[cfg(not(PyPy))] +#[cfg_attr(docsrs, doc(cfg(not(PyPy))))] #[allow(clippy::clippy::collapsible_if)] // for if cfg! pub unsafe fn with_embedded_python_interpreter(f: F) -> R where From 4c3cbcdde20384dad9562600607c77437a685991 Mon Sep 17 00:00:00 2001 From: mejrs Date: Mon, 3 May 2021 20:04:13 +0200 Subject: [PATCH 09/16] impl docsrs for lib.rs --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 389182ca..42190893 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,6 +133,7 @@ pub use crate::conversion::{ }; pub use crate::err::{PyDowncastError, PyErr, PyErrArguments, PyResult}; #[cfg(not(PyPy))] +#[cfg_attr(docsrs, doc(cfg(not(PyPy))))] pub use crate::gil::{prepare_freethreaded_python, with_embedded_python_interpreter}; pub use crate::gil::{GILGuard, GILPool}; pub use crate::instance::{Py, PyNativeType, PyObject}; From 40dd618c46c1dbc2f420c37174a46e42272e3102 Mon Sep 17 00:00:00 2001 From: mejrs Date: Mon, 3 May 2021 20:31:53 +0200 Subject: [PATCH 10/16] added doc alias for intopy --- src/conversion.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/conversion.rs b/src/conversion.rs index 45bc4284..914c2445 100644 --- a/src/conversion.rs +++ b/src/conversion.rs @@ -203,6 +203,7 @@ where /// } /// ``` /// Python code will see this as any of the `int`, `string` or `None` objects. +#[cfg_attr(docsrs, doc(alias = "IntoPyCallbackOutput"))] pub trait IntoPy: Sized { /// Performs the conversion. fn into_py(self, py: Python) -> T; From ce03fb4e7122f501e7867ce885cbda6e8ab1d546 Mon Sep 17 00:00:00 2001 From: mejrs Date: Tue, 4 May 2021 12:38:22 +0200 Subject: [PATCH 11/16] fixed whitespace --- src/types/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/mod.rs b/src/types/mod.rs index 786be9bc..2f17878f 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -240,4 +240,4 @@ mod set; mod slice; mod string; mod tuple; -mod typeobject; \ No newline at end of file +mod typeobject; From dd26566d0cd29012bdc37708d757abd8b3698df0 Mon Sep 17 00:00:00 2001 From: mejrs Date: Tue, 4 May 2021 23:25:09 +0200 Subject: [PATCH 12/16] added package.metadata.docs.rs information --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index e48f49d1..533b816b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,3 +79,8 @@ members = [ "examples/setuptools-rust-starter", "examples/word-count" ] + +[package.metadata.docs.rs] +no-default-features = true +features = ["macros", "num-bigint", "num-complex", "hashbrown", "serde", "multiple-pymethods"] +rustdoc-args = ["--cfg", "docsrs"] \ No newline at end of file From 620c2730f5cad2829b458ff90cf88bc7121fa828 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 5 May 2021 11:26:03 +0800 Subject: [PATCH 13/16] Build docs of main branch with docsrs feature --- .github/workflows/ci.yml | 1 + .github/workflows/guide.yml | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba056de8..1670e8a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -183,6 +183,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: nightly + profile: minimal override: true - name: "Build docs with docsrs flag" run: cargo doc --no-deps --no-default-features --features "macros num-bigint num-complex hashbrown serde multiple-pymethods" diff --git a/.github/workflows/guide.yml b/.github/workflows/guide.yml index c62d2c4e..95ec32f5 100644 --- a/.github/workflows/guide.yml +++ b/.github/workflows/guide.yml @@ -18,6 +18,11 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + profile: minimal + - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: @@ -38,7 +43,7 @@ jobs: # This adds the docs to gh-pages-build/doc - name: Build the doc run: | - cargo doc --features="default num-bigint num-complex" --no-deps + cargo +nightly rustdoc --lib --features="macros num-bigint num-complex hashbrown serde multiple-pymethods" -- --cfg docsrs cp -r target/doc gh-pages-build/doc echo "" > gh-pages-build/doc/index.html From 3402e72427854fddcff041645dfbf39afa03abd6 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 5 May 2021 11:27:12 +0800 Subject: [PATCH 14/16] Run guide workflow on pull request --- .github/workflows/guide.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/guide.yml b/.github/workflows/guide.yml index 95ec32f5..f2ee35a4 100644 --- a/.github/workflows/guide.yml +++ b/.github/workflows/guide.yml @@ -4,6 +4,7 @@ on: push: branches: - main + pull_request: release: types: [published] @@ -48,6 +49,7 @@ jobs: echo "" > gh-pages-build/doc/index.html - name: Deploy + if: github.ref == 'refs/heads/main' uses: peaceiris/actions-gh-pages@v3.7.0-8 with: github_token: ${{ secrets.GITHUB_TOKEN }} From 8a89d04ee9721248ee4d05fa9d843e20b5cf85ab Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 5 May 2021 16:35:18 +0800 Subject: [PATCH 15/16] Remove docs job from CI workflow --- .github/workflows/ci.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1670e8a2..d8ec8eb2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -173,24 +173,6 @@ jobs: # Once cargo's `resolver = "2"` is stable (~ MSRV Rust 1.52), remove this. PYO3_CI: 1 - - docs: - name: docs - needs: [fmt] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - profile: minimal - override: true - - name: "Build docs with docsrs flag" - run: cargo doc --no-deps --no-default-features --features "macros num-bigint num-complex hashbrown serde multiple-pymethods" - env: - # docsrs gates doc_cfg and doc_alias functionality - RUSTDOCFLAGS: --cfg docsrs - coverage: needs: [fmt] runs-on: ubuntu-latest From 136b7d400fd098c538385362ae8edad9c13ca312 Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 5 May 2021 16:35:37 +0800 Subject: [PATCH 16/16] Also run gh-pages deploy on release --- .github/workflows/guide.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/guide.yml b/.github/workflows/guide.yml index f2ee35a4..2dea1b9f 100644 --- a/.github/workflows/guide.yml +++ b/.github/workflows/guide.yml @@ -44,12 +44,12 @@ jobs: # This adds the docs to gh-pages-build/doc - name: Build the doc run: | - cargo +nightly rustdoc --lib --features="macros num-bigint num-complex hashbrown serde multiple-pymethods" -- --cfg docsrs + cargo +nightly rustdoc --lib --no-default-features --features="macros num-bigint num-complex hashbrown serde multiple-pymethods" -- --cfg docsrs cp -r target/doc gh-pages-build/doc echo "" > gh-pages-build/doc/index.html - name: Deploy - if: github.ref == 'refs/heads/main' + if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }} uses: peaceiris/actions-gh-pages@v3.7.0-8 with: github_token: ${{ secrets.GITHUB_TOKEN }}