You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/12/27 11:36:59 UTC

(incubator-opendal) 01/01: docs: Enable doc_auto_cfg when docs cfg has been enabled

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch add-docs-cfg
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit 8d1e69e7d1910be7f2c3b0623f82a5521e0f2c7f
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Wed Dec 27 19:36:32 2023 +0800

    docs: Enable doc_auto_cfg when docs cfg has been enabled
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 .github/workflows/docs.yml | 8 +++++++-
 core/Cargo.toml            | 7 +------
 core/src/docs/features.md  | 1 -
 core/src/lib.rs            | 4 +++-
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 17ddc9bb5..0e198cb64 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -47,15 +47,21 @@ jobs:
           need-protoc: true
           github-token: ${{ secrets.GITHUB_TOKEN }}
 
+      - name: Setup Rust Nightly
+        run: |
+          rustup toolchain install nightly
+
       - uses: actions/setup-java@v4
         with:
           distribution: temurin
           java-version: '17'
 
       - name: Build OpenDAL doc
-        run: cargo doc --lib --no-deps --all-features -p opendal
+        run: cargo +nightly --lib --no-deps --all-features -p opendal
         env:
           LD_LIBRARY_PATH: ${{ env.JAVA_HOME }}/lib/server:${{ env.LD_LIBRARY_PATH }}
+          # Enable cfg docs to make sure docs are built.
+          RUSTDOCFLAGS: "--cfg docs"
 
       - name: Upload docs
         uses: actions/upload-artifact@v3
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 8bb1a528a..dda7dc977 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -32,6 +32,7 @@ version.workspace = true
 
 [package.metadata.docs.rs]
 all-features = true
+rustdoc-args = ["--cfg", "docs"]
 
 [features]
 default = [
@@ -53,12 +54,6 @@ default = [
   "services-azfile",
 ]
 
-# Build docs or not.
-#
-# This features is used to control whether or not to build opendal's docs.
-# And doesn't have any other effects.
-docs = []
-
 # Build test utils or not.
 #
 # This features is used to control whether or not to build opendal's test utils.
diff --git a/core/src/docs/features.md b/core/src/docs/features.md
index 75ea78ec1..4777e5f11 100644
--- a/core/src/docs/features.md
+++ b/core/src/docs/features.md
@@ -16,7 +16,6 @@
 - `services-moka`: Enable moka service support.
 - `services-ipfs`: Enable ipfs service support.
 - `services-redis`: Enable redis service support without TLS.
-- `services-redis-rustls`: Enable redis service support with `rustls`.
 - `services-redis-native-tls`: Enable redis service support with `native-tls`.
 - `services-rocksdb`: Enable rocksdb service support.
 - `services-atomicserver`: Enable atomicserver service support.
diff --git a/core/src/lib.rs b/core/src/lib.rs
index d4bf8d75b..01a57a183 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -15,6 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
+#![cfg_attr(docs, feature(doc_auto_cfg))]
+
 //! OpenDAL is the Open Data Access Layer to **freely** access data.
 //!
 //! - Documentation: All docs are carried by self, visit [`docs`] for more.
@@ -70,7 +72,7 @@ mod types;
 pub use types::*;
 
 // Public modules, they will be accessed like `opendal::layers::Xxxx`
-#[cfg(feature = "docs")]
+#[cfg(docs)]
 pub mod docs;
 pub mod layers;
 pub mod raw;