mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 07:14:50 +01:00
fix: doctests
This commit is contained in:
parent
4363bdfa7e
commit
e1e09cb20e
2 changed files with 18 additions and 18 deletions
|
@ -13,11 +13,11 @@
|
||||||
//!
|
//!
|
||||||
//! // create and join a workspace
|
//! // create and join a workspace
|
||||||
//! client.create_workspace("some-workspace").await?;
|
//! 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
|
//! // create a new buffer in this workspace and attach to it
|
||||||
//! workspace.create("/my/file.txt").await?;
|
//! workspace.create_buffer("/my/file.txt").await?;
|
||||||
//! let buffer = workspace.attach("/my/file.txt").await?;
|
//! let buffer = workspace.attach_buffer("/my/file.txt").await?;
|
||||||
//!
|
//!
|
||||||
//! // write `hello!` at the beginning of this buffer
|
//! // write `hello!` at the beginning of this buffer
|
||||||
//! buffer.send(codemp::api::TextChange {
|
//! buffer.send(codemp::api::TextChange {
|
||||||
|
@ -49,12 +49,12 @@
|
||||||
//! });
|
//! });
|
||||||
//!
|
//!
|
||||||
//! // create and join a workspace
|
//! // create and join a workspace
|
||||||
//! await client.create_workspace("some-workspace");
|
//! await client.createWorkspace("some-workspace");
|
||||||
//! let workspace = await client.join_workspace("some-workspace");
|
//! let workspace = await client.attachWorkspace("some-workspace");
|
||||||
//!
|
//!
|
||||||
//! // create a new buffer in this workspace and attach to it
|
//! // create a new buffer in this workspace and attach to it
|
||||||
//! await workspace.create("/my/file.txt");
|
//! await workspace.createBuffer("/my/file.txt");
|
||||||
//! let buffer = await workspace.attach("/my/file.txt");
|
//! let buffer = await workspace.attachBuffer("/my/file.txt");
|
||||||
//!
|
//!
|
||||||
//! // write `hello!` at the beginning of this buffer
|
//! // write `hello!` at the beginning of this buffer
|
||||||
//! await buffer.send({
|
//! await buffer.send({
|
||||||
|
@ -87,11 +87,11 @@
|
||||||
//!
|
//!
|
||||||
//! # create and join a workspace
|
//! # create and join a workspace
|
||||||
//! client.create_workspace("some-workspace").wait()
|
//! 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
|
//! # create a new buffer in this workspace and attach to it
|
||||||
//! workspace.create("/my/file.txt").wait()
|
//! 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
|
//! # write `hello!` at the beginning of this buffer
|
||||||
//! buffer.send(
|
//! buffer.send(
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
//!
|
//!
|
||||||
//! -- create and join a workspace
|
//! -- create and join a workspace
|
||||||
//! client:create_workspace("my-workspace"):await()
|
//! 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
|
//! -- create a new buffer in this workspace and attach to it
|
||||||
//! workspace:create_buffer("/my/file.txt"):await()
|
//! workspace:create_buffer("/my/file.txt"):await()
|
||||||
|
@ -170,11 +170,11 @@
|
||||||
//!
|
//!
|
||||||
//! // create and join a workspace
|
//! // create and join a workspace
|
||||||
//! client.createWorkspace("some-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
|
//! // create a new buffer in this workspace and attach to it
|
||||||
//! workspace.createBuffer("/my/file.txt");
|
//! 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
|
//! // write `hello!` at the beginning of this buffer
|
||||||
//! buffer.send(new data.TextChange(
|
//! buffer.send(new data.TextChange(
|
||||||
|
@ -184,7 +184,7 @@
|
||||||
//!
|
//!
|
||||||
//! // wait for cursor movements
|
//! // wait for cursor movements
|
||||||
//! while (true) {
|
//! 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);
|
//! System.out.printf("user %s moved on buffer %s\n", event.user, event.buffer);
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -32,13 +32,13 @@
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! A [`Client`] can acquire a [`Workspace`] handle by joining an existing one it can access with
|
//! 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
|
//! ```no_run
|
||||||
//! # async {
|
//! # async {
|
||||||
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
|
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
|
||||||
//! client.create_workspace("my-workspace").await.expect("failed to create workspace!");
|
//! 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!");
|
||||||
//! # };
|
//! # };
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
//! # async {
|
//! # async {
|
||||||
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
|
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
|
||||||
//! # client.create_workspace("").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
|
//! use codemp::api::controller::{AsyncSender, AsyncReceiver}; // needed to access trait methods
|
||||||
//! let cursor = workspace.cursor();
|
//! let cursor = workspace.cursor();
|
||||||
//! let event = cursor.recv().await.expect("disconnected while waiting for event!");
|
//! let event = cursor.recv().await.expect("disconnected while waiting for event!");
|
||||||
|
@ -65,9 +65,9 @@
|
||||||
//! # async {
|
//! # async {
|
||||||
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
|
//! # let client = codemp::Client::connect(codemp::api::Config::new("", "")).await.unwrap();
|
||||||
//! # client.create_workspace("").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};
|
//! # 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
|
//! buffer.content(); // force-sync
|
||||||
//! if let Some(mut update) = buffer.try_recv().await.unwrap() {
|
//! if let Some(mut update) = buffer.try_recv().await.unwrap() {
|
||||||
//! println!(
|
//! println!(
|
||||||
|
|
Loading…
Reference in a new issue