Skip to content

Commit

Permalink
fix: doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaarf committed Oct 15, 2024
1 parent 4363bdf commit e1e09cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
26 changes: 13 additions & 13 deletions src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
//!
//! // create and join a workspace
//! client.create_workspace("some-workspace").await?;
//! let workspace = client.join_workspace("some-workspace").await?;
//! let workspace = client.attach_workspace("some-workspace").await?;
//!
//! // create a new buffer in this workspace and attach to it
//! workspace.create("/my/file.txt").await?;
//! let buffer = workspace.attach("/my/file.txt").await?;
//! workspace.create_buffer("/my/file.txt").await?;
//! let buffer = workspace.attach_buffer("/my/file.txt").await?;
//!
//! // write `hello!` at the beginning of this buffer
//! buffer.send(codemp::api::TextChange {
Expand Down Expand Up @@ -49,12 +49,12 @@
//! });
//!
//! // create and join a workspace
//! await client.create_workspace("some-workspace");
//! let workspace = await client.join_workspace("some-workspace");
//! await client.createWorkspace("some-workspace");
//! let workspace = await client.attachWorkspace("some-workspace");
//!
//! // create a new buffer in this workspace and attach to it
//! await workspace.create("/my/file.txt");
//! let buffer = await workspace.attach("/my/file.txt");
//! await workspace.createBuffer("/my/file.txt");
//! let buffer = await workspace.attachBuffer("/my/file.txt");
//!
//! // write `hello!` at the beginning of this buffer
//! await buffer.send({
Expand Down Expand Up @@ -87,11 +87,11 @@
//!
//! # create and join a workspace
//! client.create_workspace("some-workspace").wait()
//! workspace = client.join_workspace("some-workspace").wait()
//! workspace = client.attach_workspace("some-workspace").wait()
//!
//! # create a new buffer in this workspace and attach to it
//! workspace.create("/my/file.txt").wait()
//! buffer = workspace.attach("/my/file.txt").wait()
//! buffer = workspace.attach_buffer("/my/file.txt").wait()
//!
//! # write `hello!` at the beginning of this buffer
//! buffer.send(
Expand Down Expand Up @@ -132,7 +132,7 @@
//!
//! -- create and join a workspace
//! client:create_workspace("my-workspace"):await()
//! local workspace = client:join_workspace("my-workspace"):await()
//! local workspace = client:attach_workspace("my-workspace"):await()
//!
//! -- create a new buffer in this workspace and attach to it
//! workspace:create_buffer("/my/file.txt"):await()
Expand Down Expand Up @@ -170,11 +170,11 @@
//!
//! // create and join a workspace
//! client.createWorkspace("some-workspace");
//! Workspace workspace = client.joinWorkspace("some-workspace");
//! Workspace workspace = client.attachWorkspace("some-workspace");
//!
//! // create a new buffer in this workspace and attach to it
//! workspace.createBuffer("/my/file.txt");
//! BufferController buffer = workspace.attachToBuffer("/my/file.txt");
//! BufferController buffer = workspace.attachBuffer("/my/file.txt");
//!
//! // write `hello!` at the beginning of this buffer
//! buffer.send(new data.TextChange(
Expand All @@ -184,7 +184,7 @@
//!
//! // wait for cursor movements
//! while (true) {
//! data.Cursor event = workspace.getCursor().recv();
//! data.Cursor event = workspace.cursor().recv();
//! System.out.printf("user %s moved on buffer %s\n", event.user, event.buffer);
//! }
//! ```
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
//! ```
//!
//! A [`Client`] can acquire a [`Workspace`] handle by joining an existing one it can access with
//! [`Client::join_workspace`] or create a new one with [`Client::create_workspace`].
//! [`Client::attach_workspace`] or create a new one with [`Client::create_workspace`].
//!
//! ```no_run
//! # async {
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
//! client.create_workspace("my-workspace").await.expect("failed to create workspace!");
//! let workspace = client.join_workspace("my-workspace").await.expect("failed to attach!");
//! let workspace = client.attach_workspace("my-workspace").await.expect("failed to attach!");
//! # };
//! ```
//!
Expand All @@ -49,7 +49,7 @@
//! # async {
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
//! # client.create_workspace("").await.unwrap();
//! # let workspace = client.join_workspace("").await.unwrap();
//! # let workspace = client.attach_workspace("").await.unwrap();
//! use codemp::api::controller::{AsyncSender, AsyncReceiver}; // needed to access trait methods
//! let cursor = workspace.cursor();
//! let event = cursor.recv().await.expect("disconnected while waiting for event!");
Expand All @@ -65,9 +65,9 @@
//! # async {
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
//! # client.create_workspace("").await.unwrap();
//! # let workspace = client.join_workspace("").await.unwrap();
//! # let workspace = client.attach_workspace("").await.unwrap();
//! # use codemp::api::controller::{AsyncSender, AsyncReceiver};
//! let buffer = workspace.attach("/some/file.txt").await.expect("failed to attach");
//! let buffer = workspace.attach_buffer("/some/file.txt").await.expect("failed to attach");
//! buffer.content(); // force-sync
//! if let Some(mut update) = buffer.try_recv().await.unwrap() {
//! println!(
Expand Down

0 comments on commit e1e09cb

Please sign in to comment.