Skip to content

Commit 6aac1ae

Browse files
committed
Update docs for conditional compilation
- Update README to explain the versioning - Add attributes that make conditional features stand out in the generated rustdocs. This relies on an experimental `doc_cfg` compiler feature which doesn't exist on stable, so opt into it with a `dox` feature in i3ipc-rs that can be enabled for documentation builds.
1 parent 5ea59da commit 6aac1ae

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ serde_json = "0.6.0"
1616
i3-4-12 = []
1717
i3-4-13 = ["i3-4-12"]
1818
i3-4-14 = ["i3-4-13"]
19+
i3-next = ["i3-4-14"]
20+
dox = ["i3-next"]

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ A Rust library for controlling i3-wm through its [IPC interface](https://i3wm.or
1010
## Usage
1111
Add this to your Cargo.toml
1212
```toml
13-
[dependencies]
14-
i3ipc = "0.7.0"
13+
[dependencies.i3ipc]
14+
version = "0.7.0"
1515
```
1616

1717
## Messages:
@@ -59,8 +59,14 @@ fn main() {
5959
}
6060
```
6161

62-
## Compatibility
62+
## Versioning
6363

64-
This library was last updated for **i3 version 4.11**, but is forward compatible. Contributions are welcome!
64+
By default i3ipc-rs targets minimum i3 version 4.11. To unlock additional features you can increase this by selecting one of `"i3-4-12"`, ..., `"i3-4-14"` in Cargo.toml.
6565

66-
All documented functionality from i3 version 4.11 can be handled by this library. Additions to the i3 IPC interface that are not understood by this library will generally return an `Unknown` value and log a warning to the target `"i3ipc"` using the [log crate](http://doc.rust-lang.org/log). Binaries using this library should [install a logger](https://doc.rust-lang.org/log/log/index.html#in-executables) to view details of such additions.
66+
```
67+
[dependencies.i3ipc]
68+
version = "0.7.0"
69+
features = ["i3-4-14"]
70+
```
71+
72+
Additions to the i3 IPC interface that are not understood by your compiled binary will generally return an `Unknown` value and log a warning to the target `"i3ipc"` using the [log crate](http://doc.rust-lang.org/log). Binaries using this library should [install a logger](https://doc.rust-lang.org/log/log/index.html#in-executables) to view details of such additions.

src/event.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub enum Event {
1818
BindingEvent(BindingEventInfo),
1919

2020
#[cfg(feature = "i3-4-14")]
21+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-14")))]
2122
ShutdownEvent(ShutdownEventInfo),
2223
}
2324

@@ -217,11 +218,13 @@ impl FromStr for BindingEventInfo {
217218
/// Data for `ShutdownEvent`.
218219
#[derive(Debug)]
219220
#[cfg(feature = "i3-4-14")]
221+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-14")))]
220222
pub struct ShutdownEventInfo {
221223
pub change: ShutdownChange,
222224
}
223225

224226
#[cfg(feature = "i3-4-14")]
227+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-14")))]
225228
impl FromStr for ShutdownEventInfo {
226229
type Err = json::error::Error;
227230
fn from_str(s: &str) -> Result<Self, Self::Err> {
@@ -285,6 +288,7 @@ pub mod inner {
285288

286289
/// A mark has been added to or removed from the window.
287290
#[cfg(feature = "i3-4-13")]
291+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-13")))]
288292
Mark,
289293

290294
/// A WindowChange we don't support yet.
@@ -333,6 +337,7 @@ pub mod inner {
333337
/// The kind of shutdown change.
334338
#[derive(Debug)]
335339
#[cfg(feature = "i3-4-14")]
340+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-14")))]
336341
pub enum ShutdownChange {
337342
Restart,
338343
Exit,

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
//! This library should cover all of i3's documented ipc features. If it's missing something
1616
//! please open an issue on github.
1717
18+
#![cfg_attr(feature = "dox", feature(doc_cfg))]
19+
1820
extern crate unix_socket;
1921
extern crate byteorder;
2022
#[macro_use]
@@ -211,6 +213,7 @@ pub enum Subscription {
211213
BarConfig,
212214
Binding,
213215
#[cfg(feature = "i3-4-14")]
216+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-14")))]
214217
Shutdown,
215218
}
216219

@@ -478,6 +481,7 @@ impl I3Connection {
478481

479482
/// Gets the list of currently configured binding modes.
480483
#[cfg(feature = "i3-4-13")]
484+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-13")))]
481485
pub fn get_binding_modes(&mut self) -> Result<reply::BindingModes, MessageError> {
482486
if let Err(e) = self.stream.send_i3_message(8, "") {
483487
return Err(MessageError::Send(e));

src/reply.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,19 @@ pub enum ColorableBarPart {
221221

222222
/// Background color of the bar on the currently focused monitor output.
223223
#[cfg(feature = "i3-4-12")]
224+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
224225
FocusedBackground,
225226

226227
/// Text color to be used for the statusline on the currently focused
227228
/// monitor output.
228229
#[cfg(feature = "i3-4-12")]
230+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
229231
FocusedStatusline,
230232

231233
/// Text color to be used for the separator on the currently focused
232234
/// monitor output.
233235
#[cfg(feature = "i3-4-12")]
236+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-12")))]
234237
FocusedSeparator,
235238

236239
/// Text color for a workspace button when the workspace has focus.
@@ -357,6 +360,7 @@ pub struct Version {
357360

358361
/// The reply to the `get_binding_modes` request.
359362
#[cfg(feature = "i3-4-13")]
363+
#[cfg_attr(feature = "dox", doc(cfg(feature = "i3-4-13")))]
360364
#[derive(Debug)]
361365
pub struct BindingModes {
362366
/// A vector of all currently configured binding modes.

0 commit comments

Comments
 (0)