Skip to content

Commit 20572fd

Browse files
committed
Fix conditional compilation manually
1 parent 04f3685 commit 20572fd

39 files changed

+593
-366
lines changed

cairo/src/constants.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@ pub const MIME_TYPE_UNIQUE_ID: &str = "application/x-cairo.uuid";
88
pub const MIME_TYPE_JBIG2: &str = "application/x-cairo.jbig2";
99
pub const MIME_TYPE_JBIG2_GLOBAL: &str = "application/x-cairo.jbig2-global";
1010
pub const MIME_TYPE_JBIG2_GLOBAL_ID: &str = "application/x-cairo.jbig2-global-id";
11-
#[cfg(any(feature = "v1_16", docsrs))]
11+
#[cfg(feature = "v1_16")]
12+
#[cfg_attr(docsrs, cfg(doc(feature = "v1_16")))]
1213
pub const MIME_TYPE_CCITT_FAX: &str = "image/g3fax";
13-
#[cfg(any(feature = "v1_16", docsrs))]
14+
#[cfg(feature = "v1_16")]
15+
#[cfg_attr(docsrs, cfg(doc(feature = "v1_16")))]
1416
pub const MIME_TYPE_CCITT_FAX_PARAMS: &str = "application/x-cairo.ccitt.params";
15-
#[cfg(any(feature = "v1_16", docsrs))]
17+
#[cfg(feature = "v1_16")]
18+
#[cfg_attr(docsrs, cfg(doc(feature = "v1_16")))]
1619
pub const MIME_TYPE_EPS: &str = "application/postscript";
17-
#[cfg(any(feature = "v1_16", docsrs))]
20+
#[cfg(feature = "v1_16")]
21+
#[cfg_attr(docsrs, cfg(doc(feature = "v1_16")))]
1822
pub const MIME_TYPE_EPS_PARAMS: &str = "application/x-cairo.eps.params";
1923

20-
#[cfg(any(feature = "v1_16", docsrs))]
24+
#[cfg(feature = "v1_16")]
25+
#[cfg_attr(docsrs, cfg(doc(feature = "v1_16")))]
2126
pub const PDF_OUTLINE_ROOT: i32 = 0;
2227

23-
#[cfg(any(feature = "v1_16", docsrs))]
28+
#[cfg(feature = "v1_16")]
29+
#[cfg_attr(docsrs, cfg(doc(feature = "v1_16")))]
2430
pub const CAIRO_TAG_DEST: &str = "cairo.dest";
25-
#[cfg(any(feature = "v1_16", docsrs))]
31+
#[cfg(feature = "v1_16")]
32+
#[cfg_attr(docsrs, cfg(doc(feature = "v1_16")))]
2633
pub const CAIRO_TAG_LINK: &str = "Link";

cairo/src/context.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ impl fmt::Display for RectangleList {
6464
pub struct Context(ptr::NonNull<cairo_t>);
6565

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

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

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

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

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

105109
#[cfg(feature = "use_glib")]
110+
#[cfg_attr(docsrs, cfg(doc(feature = "use_glib")))]
106111
impl FromGlibPtrFull<*mut ffi::cairo_t> for Context {
107112
#[inline]
108113
unsafe fn from_glib_full(ptr: *mut ffi::cairo_t) -> Context {
@@ -111,6 +116,7 @@ impl FromGlibPtrFull<*mut ffi::cairo_t> for Context {
111116
}
112117

113118
#[cfg(feature = "use_glib")]
119+
#[cfg_attr(docsrs, cfg(doc(feature = "use_glib")))]
114120
gvalue_impl!(
115121
Context,
116122
cairo_t,
@@ -358,13 +364,15 @@ impl Context {
358364
unsafe { ffi::cairo_get_line_width(self.0.as_ptr()) }
359365
}
360366

361-
#[cfg(any(feature = "v1_18", docsrs))]
367+
#[cfg(feature = "v1_18")]
368+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
362369
#[doc(alias = "cairo_set_hairline")]
363370
pub fn set_hairline(&self, set_hairline: bool) {
364371
unsafe { ffi::cairo_set_hairline(self.0.as_ptr(), set_hairline.into()) }
365372
}
366373

367-
#[cfg(any(feature = "v1_18", docsrs))]
374+
#[cfg(feature = "v1_18")]
375+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
368376
#[doc(alias = "get_hairline")]
369377
#[doc(alias = "cairo_get_hairline")]
370378
pub fn hairline(&self) -> bool {
@@ -926,7 +934,8 @@ impl Context {
926934
self.status().map(|_| (x1, y1, x2, y2))
927935
}
928936

929-
#[cfg(any(feature = "v1_16", docsrs))]
937+
#[cfg(feature = "v1_16")]
938+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
930939
#[doc(alias = "cairo_tag_begin")]
931940
pub fn tag_begin(&self, tag_name: &str, attributes: &str) {
932941
unsafe {
@@ -936,7 +945,8 @@ impl Context {
936945
}
937946
}
938947

939-
#[cfg(any(feature = "v1_16", docsrs))]
948+
#[cfg(feature = "v1_16")]
949+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
940950
#[doc(alias = "cairo_tag_end")]
941951
pub fn tag_end(&self, tag_name: &str) {
942952
unsafe {

cairo/src/device.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
#[cfg(any(feature = "script", docsrs))]
3+
#[cfg(feature = "script")]
44
use std::ffi::CString;
55
#[cfg(feature = "use_glib")]
66
use std::marker::PhantomData;
7-
#[cfg(any(feature = "script", docsrs))]
7+
#[cfg(feature = "script")]
88
use std::path::Path;
99
use std::{fmt, ptr};
1010

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

1414
use crate::{utils::status_to_result, DeviceType, Error};
15-
#[cfg(any(feature = "script", docsrs))]
15+
#[cfg(feature = "script")]
1616
use crate::{Content, RecordingSurface, ScriptMode, Surface};
1717

1818
#[derive(Debug)]
@@ -56,7 +56,8 @@ impl Device {
5656
self.0.as_ptr()
5757
}
5858

59-
#[cfg(any(feature = "script", docsrs))]
59+
#[cfg(feature = "script")]
60+
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
6061
#[doc(alias = "cairo_script_create")]
6162
pub fn create<P: AsRef<Path>>(filename: P) -> Option<Device> {
6263
unsafe {
@@ -71,7 +72,8 @@ impl Device {
7172
}
7273
}
7374

74-
#[cfg(any(feature = "script", docsrs))]
75+
#[cfg(feature = "script")]
76+
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
7577
#[doc(alias = "cairo_script_from_recording_surface")]
7678
pub fn from_recording_surface(&self, surface: &RecordingSurface) -> Result<(), Error> {
7779
unsafe {
@@ -81,20 +83,23 @@ impl Device {
8183
}
8284
}
8385

84-
#[cfg(any(feature = "script", docsrs))]
86+
#[cfg(feature = "script")]
87+
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
8588
#[doc(alias = "cairo_script_get_mode")]
8689
#[doc(alias = "get_mode")]
8790
pub fn mode(&self) -> ScriptMode {
8891
unsafe { ScriptMode::from(ffi::cairo_script_get_mode(self.to_raw_none())) }
8992
}
9093

91-
#[cfg(any(feature = "script", docsrs))]
94+
#[cfg(feature = "script")]
95+
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
9296
#[doc(alias = "cairo_script_set_mode")]
9397
pub fn set_mode(&self, mode: ScriptMode) {
9498
unsafe { ffi::cairo_script_set_mode(self.to_raw_none(), mode.into()) }
9599
}
96100

97-
#[cfg(any(feature = "script", docsrs))]
101+
#[cfg(feature = "script")]
102+
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
98103
#[doc(alias = "cairo_script_surface_create")]
99104
pub fn surface_create(
100105
&self,
@@ -112,7 +117,8 @@ impl Device {
112117
}
113118
}
114119

115-
#[cfg(any(feature = "script", docsrs))]
120+
#[cfg(feature = "script")]
121+
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
116122
#[doc(alias = "cairo_script_surface_create_for_target")]
117123
pub fn surface_create_for_target(&self, target: impl AsRef<Surface>) -> Result<Surface, Error> {
118124
let target = target.as_ref();
@@ -125,7 +131,8 @@ impl Device {
125131
}
126132
}
127133

128-
#[cfg(any(feature = "script", docsrs))]
134+
#[cfg(feature = "script")]
135+
#[cfg_attr(docsrs, doc(cfg(feature = "script")))]
129136
#[doc(alias = "cairo_script_write_comment")]
130137
pub fn write_comment(&self, comment: &str) {
131138
unsafe {
@@ -195,7 +202,8 @@ impl Device {
195202
unsafe { ffi::cairo_device_observer_stroke_elapsed(self.to_raw_none()) }
196203
}
197204

198-
#[cfg(any(feature = "xlib", feature = "xcb", docsrs))]
205+
#[cfg(any(feature = "xlib", feature = "xcb"))]
206+
#[cfg_attr(docsrs, doc(cfg(any(feature = "xlib", feature = "xcb"))))]
199207
#[doc(alias = "cairo_xlib_device_debug_cap_xrender_version")]
200208
#[doc(alias = "cairo_xcb_device_debug_cap_xrender_version")]
201209
pub fn debug_cap_xrender_version(&self, _major_version: i32, _minor_version: i32) {
@@ -232,7 +240,8 @@ impl Device {
232240
}
233241
}
234242

235-
#[cfg(any(feature = "xlib", feature = "xcb", docsrs))]
243+
#[cfg(any(feature = "xlib", feature = "xcb"))]
244+
#[cfg_attr(docsrs, doc(cfg(any(feature = "xlib", feature = "xcb"))))]
236245
#[doc(alias = "cairo_xlib_device_debug_get_precision")]
237246
#[doc(alias = "cairo_xcb_device_debug_get_precision")]
238247
pub fn debug_get_precision(&self) -> i32 {
@@ -261,7 +270,8 @@ impl Device {
261270
}
262271
}
263272

264-
#[cfg(any(feature = "xlib", feature = "xcb", docsrs))]
273+
#[cfg(any(feature = "xlib", feature = "xcb"))]
274+
#[cfg_attr(docsrs, doc(cfg(any(feature = "xlib", feature = "xcb"))))]
265275
#[doc(alias = "cairo_xlib_device_debug_set_precision")]
266276
#[doc(alias = "cairo_xcb_device_debug_set_precision")]
267277
pub fn debug_set_precision(&self, _precision: i32) {
@@ -304,6 +314,7 @@ impl Device {
304314
}
305315

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

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

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

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

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

345359
#[cfg(feature = "use_glib")]
360+
#[cfg_attr(docsrs, cfg(doc(feature = "use_glib")))]
346361
impl FromGlibPtrFull<*mut ffi::cairo_device_t> for Device {
347362
#[inline]
348363
unsafe fn from_glib_full(ptr: *mut ffi::cairo_device_t) -> Device {
@@ -351,6 +366,7 @@ impl FromGlibPtrFull<*mut ffi::cairo_device_t> for Device {
351366
}
352367

353368
#[cfg(feature = "use_glib")]
369+
#[cfg_attr(docsrs, cfg(doc(feature = "use_glib")))]
354370
gvalue_impl!(
355371
Device,
356372
ffi::cairo_device_t,

0 commit comments

Comments
 (0)