Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gir: Use docsrs attribute #1078

Merged
merged 7 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
0.16=0.16
0.15=0.15
0.14=0.14
RUSTFLAGS: --cfg docsrs
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -37,7 +38,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: doc
args: -p cairo-rs -p cairo-sys-rs -p gdk-pixbuf -p gdk-pixbuf-sys -p gio -p gio-sys -p glib -p gobject-sys -p glib-sys -p glib-macros -p glib-build-tools -p graphene-rs -p graphene-sys -p pango -p pango-sys -p pangocairo -p pangocairo-sys --features dox --no-deps
args: -p cairo-rs -p cairo-sys-rs -p gdk-pixbuf -p gdk-pixbuf-sys -p gio -p gio-sys -p glib -p gobject-sys -p glib-sys -p glib-macros -p glib-build-tools -p graphene-rs -p graphene-sys -p pango -p pango-sys -p pangocairo -p pangocairo-sys --no-deps --all-features
- run: echo "RELEASE=$(echo '${{ github.event.release.tag_name }}' | grep -Po '(\d+)\.(\d+)')" >> ${GITHUB_ENV}
- run: echo "DEST=$(if [ "$GITHUB_EVENT_NAME" == "release" ]; then echo 'stable/${{ env.RELEASE }}'; else echo 'git'; fi)" >> ${GITHUB_ENV}
- name: Grab gtk-rs LOGO
Expand Down
3 changes: 1 addition & 2 deletions cairo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ freetype = ["ffi/freetype", "freetype-rs"]
script = ["ffi/script"]
xcb = ["ffi/xcb"]
xlib = ["ffi/xlib"]
dox = ["ffi/dox", "glib/dox", "freetype"]
win32-surface = ["ffi/win32-surface"]
AaronErhardt marked this conversation as resolved.
Show resolved Hide resolved

[package.metadata.docs.rs]
features = ["dox"]
rustdoc-args = ["--cfg", "docsrs"]

[dependencies.glib]
optional = true
Expand Down
8 changes: 4 additions & 4 deletions cairo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ Currently, the minimum supported Rust version is `1.64.0`.
* [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/cairo)
* [C API](https://www.cairographics.org/documentation/)

## Documentation features

* **dox** - Used to keep system dependent items in documentation

## X Window features

* **xcb** - X Window System rendering using the XCB library
Expand All @@ -44,6 +40,10 @@ Currently, the minimum supported Rust version is `1.64.0`.

* **win32-surface** - Microsoft Windows surface support

## Documentation rustdoc attributes

* **docsrs** - Used to keep system dependent items in documentation

## Using

We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs),
Expand Down
21 changes: 14 additions & 7 deletions cairo/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,26 @@ pub const MIME_TYPE_UNIQUE_ID: &str = "application/x-cairo.uuid";
pub const MIME_TYPE_JBIG2: &str = "application/x-cairo.jbig2";
pub const MIME_TYPE_JBIG2_GLOBAL: &str = "application/x-cairo.jbig2-global";
pub const MIME_TYPE_JBIG2_GLOBAL_ID: &str = "application/x-cairo.jbig2-global-id";
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub const MIME_TYPE_CCITT_FAX: &str = "image/g3fax";
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub const MIME_TYPE_CCITT_FAX_PARAMS: &str = "application/x-cairo.ccitt.params";
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub const MIME_TYPE_EPS: &str = "application/postscript";
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub const MIME_TYPE_EPS_PARAMS: &str = "application/x-cairo.eps.params";

#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub const PDF_OUTLINE_ROOT: i32 = 0;

#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub const CAIRO_TAG_DEST: &str = "cairo.dest";
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub const CAIRO_TAG_LINK: &str = "Link";
17 changes: 13 additions & 4 deletions cairo/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl fmt::Display for RectangleList {
pub struct Context(ptr::NonNull<cairo_t>);

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl IntoGlibPtr<*mut ffi::cairo_t> for Context {
#[inline]
unsafe fn into_glib_ptr(self) -> *mut ffi::cairo_t {
Expand All @@ -72,6 +73,7 @@ impl IntoGlibPtr<*mut ffi::cairo_t> for Context {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl<'a> ToGlibPtr<'a, *mut ffi::cairo_t> for &'a Context {
type Storage = PhantomData<&'a Context>;

Expand All @@ -87,6 +89,7 @@ impl<'a> ToGlibPtr<'a, *mut ffi::cairo_t> for &'a Context {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl FromGlibPtrNone<*mut ffi::cairo_t> for Context {
#[inline]
unsafe fn from_glib_none(ptr: *mut ffi::cairo_t) -> Context {
Expand All @@ -95,6 +98,7 @@ impl FromGlibPtrNone<*mut ffi::cairo_t> for Context {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl FromGlibPtrBorrow<*mut ffi::cairo_t> for Context {
#[inline]
unsafe fn from_glib_borrow(ptr: *mut ffi::cairo_t) -> crate::Borrowed<Context> {
Expand All @@ -103,6 +107,7 @@ impl FromGlibPtrBorrow<*mut ffi::cairo_t> for Context {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl FromGlibPtrFull<*mut ffi::cairo_t> for Context {
#[inline]
unsafe fn from_glib_full(ptr: *mut ffi::cairo_t) -> Context {
Expand Down Expand Up @@ -358,13 +363,15 @@ impl Context {
unsafe { ffi::cairo_get_line_width(self.0.as_ptr()) }
}

#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "cairo_set_hairline")]
pub fn set_hairline(&self, set_hairline: bool) {
unsafe { ffi::cairo_set_hairline(self.0.as_ptr(), set_hairline.into()) }
}

#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "get_hairline")]
#[doc(alias = "cairo_get_hairline")]
pub fn hairline(&self) -> bool {
Expand Down Expand Up @@ -926,7 +933,8 @@ impl Context {
self.status().map(|_| (x1, y1, x2, y2))
}

#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "cairo_tag_begin")]
pub fn tag_begin(&self, tag_name: &str, attributes: &str) {
unsafe {
Expand All @@ -936,7 +944,8 @@ impl Context {
}
}

#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "cairo_tag_end")]
pub fn tag_end(&self, tag_name: &str) {
unsafe {
Expand Down
41 changes: 28 additions & 13 deletions cairo/src/device.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Take a look at the license at the top of the repository in the LICENSE file.

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
use std::ffi::CString;
#[cfg(feature = "use_glib")]
use std::marker::PhantomData;
#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
use std::path::Path;
use std::{fmt, ptr};

#[cfg(feature = "use_glib")]
use glib::translate::*;

use crate::{utils::status_to_result, DeviceType, Error};
#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
use crate::{Content, RecordingSurface, ScriptMode, Surface};

#[derive(Debug)]
Expand Down Expand Up @@ -56,7 +56,8 @@ impl Device {
self.0.as_ptr()
}

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
#[doc(alias = "cairo_script_create")]
pub fn create<P: AsRef<Path>>(filename: P) -> Option<Device> {
unsafe {
Expand All @@ -71,7 +72,8 @@ impl Device {
}
}

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
#[doc(alias = "cairo_script_from_recording_surface")]
pub fn from_recording_surface(&self, surface: &RecordingSurface) -> Result<(), Error> {
unsafe {
Expand All @@ -81,20 +83,23 @@ impl Device {
}
}

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
#[doc(alias = "cairo_script_get_mode")]
#[doc(alias = "get_mode")]
pub fn mode(&self) -> ScriptMode {
unsafe { ScriptMode::from(ffi::cairo_script_get_mode(self.to_raw_none())) }
}

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
#[doc(alias = "cairo_script_set_mode")]
pub fn set_mode(&self, mode: ScriptMode) {
unsafe { ffi::cairo_script_set_mode(self.to_raw_none(), mode.into()) }
}

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
#[doc(alias = "cairo_script_surface_create")]
pub fn surface_create(
&self,
Expand All @@ -112,7 +117,8 @@ impl Device {
}
}

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
#[doc(alias = "cairo_script_surface_create_for_target")]
pub fn surface_create_for_target(&self, target: impl AsRef<Surface>) -> Result<Surface, Error> {
let target = target.as_ref();
Expand All @@ -125,7 +131,8 @@ impl Device {
}
}

#[cfg(any(feature = "script", feature = "dox"))]
#[cfg(feature = "script")]
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
#[doc(alias = "cairo_script_write_comment")]
pub fn write_comment(&self, comment: &str) {
unsafe {
Expand Down Expand Up @@ -195,7 +202,8 @@ impl Device {
unsafe { ffi::cairo_device_observer_stroke_elapsed(self.to_raw_none()) }
}

#[cfg(any(feature = "xlib", feature = "xcb", feature = "dox"))]
#[cfg(any(feature = "xlib", feature = "xcb"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "xlib", feature = "xcb"))))]
#[doc(alias = "cairo_xlib_device_debug_cap_xrender_version")]
#[doc(alias = "cairo_xcb_device_debug_cap_xrender_version")]
pub fn debug_cap_xrender_version(&self, _major_version: i32, _minor_version: i32) {
Expand Down Expand Up @@ -232,7 +240,8 @@ impl Device {
}
}

#[cfg(any(feature = "xlib", feature = "xcb", feature = "dox"))]
#[cfg(any(feature = "xlib", feature = "xcb"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "xlib", feature = "xcb"))))]
#[doc(alias = "cairo_xlib_device_debug_get_precision")]
#[doc(alias = "cairo_xcb_device_debug_get_precision")]
pub fn debug_get_precision(&self) -> i32 {
Expand Down Expand Up @@ -261,7 +270,8 @@ impl Device {
}
}

#[cfg(any(feature = "xlib", feature = "xcb", feature = "dox"))]
#[cfg(any(feature = "xlib", feature = "xcb"))]
#[cfg_attr(docsrs, doc(cfg(any(feature = "xlib", feature = "xcb"))))]
#[doc(alias = "cairo_xlib_device_debug_set_precision")]
#[doc(alias = "cairo_xcb_device_debug_set_precision")]
pub fn debug_set_precision(&self, _precision: i32) {
Expand Down Expand Up @@ -304,6 +314,7 @@ impl Device {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl IntoGlibPtr<*mut ffi::cairo_device_t> for Device {
#[inline]
unsafe fn into_glib_ptr(self) -> *mut ffi::cairo_device_t {
Expand All @@ -312,6 +323,7 @@ impl IntoGlibPtr<*mut ffi::cairo_device_t> for Device {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl<'a> ToGlibPtr<'a, *mut ffi::cairo_device_t> for Device {
type Storage = PhantomData<&'a Device>;

Expand All @@ -327,6 +339,7 @@ impl<'a> ToGlibPtr<'a, *mut ffi::cairo_device_t> for Device {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl FromGlibPtrNone<*mut ffi::cairo_device_t> for Device {
#[inline]
unsafe fn from_glib_none(ptr: *mut ffi::cairo_device_t) -> Device {
Expand All @@ -335,6 +348,7 @@ impl FromGlibPtrNone<*mut ffi::cairo_device_t> for Device {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl FromGlibPtrBorrow<*mut ffi::cairo_device_t> for Device {
#[inline]
unsafe fn from_glib_borrow(ptr: *mut ffi::cairo_device_t) -> crate::Borrowed<Device> {
Expand All @@ -343,6 +357,7 @@ impl FromGlibPtrBorrow<*mut ffi::cairo_device_t> for Device {
}

#[cfg(feature = "use_glib")]
#[cfg_attr(docsrs, doc(cfg(feature = "use_glib")))]
impl FromGlibPtrFull<*mut ffi::cairo_device_t> for Device {
#[inline]
unsafe fn from_glib_full(ptr: *mut ffi::cairo_device_t) -> Device {
Expand Down
Loading