Skip to content

Commit

Permalink
fix: add missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
graelo committed Aug 18, 2022
1 parent 89cc537 commit 0bf3738
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/actions/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
tmux::{self, pane::Pane, session::Session, window::Window},
};

/// Restore all sessions, windows & panes from the backup file.
pub async fn restore<P: AsRef<Path>>(backup_filepath: P) -> Result<v1::Overview> {
let start = Instant::now();
tmux::server::start().await?;
Expand Down Expand Up @@ -67,7 +68,7 @@ pub async fn restore<P: AsRef<Path>>(backup_filepath: P) -> Result<v1::Overview>
Ok(metadata.overview())
}

/// Associates a pane from the backup with a new target pane id.
/// Association between a pane from the backup with a new target pane id.
#[derive(Debug, Clone)]
struct Pair {
/// Pane definition from the backup.
Expand Down
1 change: 0 additions & 1 deletion src/bin/tmux-backup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![warn(missing_docs)]
//! Main runner

use async_std::task;
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![warn(missing_docs)]

//! A backup & restore solution for Tmux sessions.
//!
//! Version requirement: _rustc 1.50+_
Expand Down
2 changes: 2 additions & 0 deletions src/management/archive/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
//! Define the archive formats (only one currently) and related functions.

pub mod v1;
2 changes: 2 additions & 0 deletions src/tmux/display.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Functions for reporting information inside Tmux.

use std::process::Command;

/// Returns a list of all `Pane` from all sessions.
Expand Down
14 changes: 14 additions & 0 deletions src/tmux/layout.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
//! Parse the window layout string.
//!
//! Tmux reports the layout for a window, it can also use it to apply an existing layout to a
//! window.
//!
//! A window layout has this format:
//!
//! ```text
//! "41e9,279x71,0,0[279x40,0,0,71,279x30,0,41{147x30,0,41,72,131x30,148,41,73}]"
//! ```
//!
//! The parser in this module returns the corresponding [`WindowLayout`].

use nom::{
branch::alt,
character::complete::{char, digit1, hex_digit1},
Expand All @@ -9,6 +22,7 @@ use nom::{

use crate::error::ParseError;

/// Represent a parsed window layout.
#[derive(Debug, PartialEq, Eq)]
pub struct WindowLayout {
/// 4-char hex id, such as `9f58`.
Expand Down
2 changes: 2 additions & 0 deletions src/tmux/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Functions to read or manipulate Tmux

pub mod display;
pub use display::display_message;
pub mod layout;
Expand Down
1 change: 1 addition & 0 deletions src/tmux/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::window_id::WindowId;
use crate::error;
use serde::{Deserialize, Serialize};

/// A Tmux pane.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Pane {
/// Pane identifier, e.g. `%37`.
Expand Down
6 changes: 6 additions & 0 deletions src/tmux/pane_id.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
//! Pane id.

use std::fmt;
use std::str::FromStr;

use crate::error;
use serde::{Deserialize, Serialize};

/// The id of a Tmux pane.
///
/// This wraps the raw tmux representation (`%12`).
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct PaneId(pub String);

Expand All @@ -28,6 +33,7 @@ impl From<&u16> for PaneId {
}

impl PaneId {
/// Extract a string slice containing the raw representation.
pub fn as_str(&self) -> &str {
&self.0
}
Expand Down
1 change: 1 addition & 0 deletions src/tmux/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use serde::{Deserialize, Serialize};
use super::{pane_id::PaneId, session_id::SessionId, window_id::WindowId};
use crate::error::ParseError;

/// A Tmux session.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Session {
/// Session identifier, e.g. `$3`.
Expand Down
5 changes: 5 additions & 0 deletions src/tmux/session_id.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
//! Session Id.

use std::fmt;
use std::str::FromStr;

use serde::{Deserialize, Serialize};

use crate::error::ParseError;

/// The id of a Tmux session.
///
/// This wraps the raw tmux representation (`$11`).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SessionId(String);

Expand Down
4 changes: 2 additions & 2 deletions src/tmux/window.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! This module provides a few types and functions to handle Tmux windows.
//!
//! The main use cases are running Tmux commands & parsing Tmux window
//! information.
//! The main use cases are running Tmux commands & parsing Tmux window information.

use std::path::Path;
use std::str::FromStr;
Expand All @@ -13,6 +12,7 @@ use serde::{Deserialize, Serialize};
use super::{pane_id::PaneId, window_id::WindowId};
use crate::{error::ParseError, tmux::layout};

/// A Tmux window.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Window {
/// Window identifier, e.g. `@3`.
Expand Down
6 changes: 6 additions & 0 deletions src/tmux/window_id.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
//! Window Id.

use std::fmt;
use std::str::FromStr;

use serde::{Deserialize, Serialize};

use crate::error;

/// The id of a Tmux window.
///
/// This wraps the raw tmux representation (`@41`).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WindowId(String);

Expand All @@ -24,6 +29,7 @@ impl FromStr for WindowId {
}

impl WindowId {
/// Extract a string slice containing the raw representation.
pub fn as_str(&self) -> &str {
&self.0
}
Expand Down

0 comments on commit 0bf3738

Please sign in to comment.