From 576de255cf6be6f5a652c1e77a80d800cec87493 Mon Sep 17 00:00:00 2001 From: Jonathan Schwender Date: Thu, 18 Jul 2024 10:53:24 +0200 Subject: [PATCH] Fix docs.rs and test building docs in CI Signed-off-by: Jonathan Schwender --- .github/workflows/ci.yml | 16 +++++++++++++++- components/drawing/src/lib.rs | 18 ++++++++++++++++++ src/lib.rs | 3 ++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9610098..45f24b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,4 +52,18 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - run: cargo build --features ${{ matrix.api_level }} --features ${{ matrix.component }} - name: Build minimal features \ No newline at end of file + name: Build minimal features + + rustdoc: + name: Build Documentation + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: [ stable nightly ] + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + - name: Build docs + run: cargo doc --all=features --workspace --no-deps + env: + RUSTDOCFLAGS: "--cfg=docsrs" \ No newline at end of file diff --git a/components/drawing/src/lib.rs b/components/drawing/src/lib.rs index 53189ee..b9c2d58 100644 --- a/components/drawing/src/lib.rs +++ b/components/drawing/src/lib.rs @@ -1,3 +1,21 @@ +//! FFI Bindings for `native_drawing` on OpenHarmony +//! +//! The native drawing module provides APIs for drawing 2D graphics and text. +//! The graphics and text drawn by using the APIs cannot be directly displayed on the screen. +//! To display the drawn graphics and text, you'll need the capabilities provided by the and native window module. +//! +//! Please consult the official documentation for more details: [English docs], [Chinese docs] +//! +//! [English docs]: https://docs.openharmony.cn/pages/v5.0/en/application-dev/graphics/drawing-guidelines.md +//! [Chinese docs]: https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/graphics/drawing-guidelines.md +//! +//! ## Feature flags +#![cfg_attr( + feature = "document-features", + cfg_attr(doc, doc = ::document_features::document_features!()) +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + #[link(name = "native_drawing")] extern "C" {} diff --git a/src/lib.rs b/src/lib.rs index 57bd01c..938c12d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,8 @@ feature = "document-features", cfg_attr(doc, doc = ::document_features::document_features!()) )] -#[cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_cfg))] + #[cfg(feature = "drawing")] #[cfg_attr(docsrs, doc(cfg(feature = "drawing")))] pub mod drawing {