Skip to content

Commit

Permalink
Improve the docs of connect and serve (#1450)
Browse files Browse the repository at this point in the history
* Improve the docs of `connect` and `serve`

* Fix doctest
  • Loading branch information
emilk committed Mar 2, 2023
1 parent 33cb135 commit 22049e1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ doc-valid-idents = [
"sRGB",
"sRGBA",
"WebGL",
"WebSockets",
]
25 changes: 21 additions & 4 deletions crates/re_sdk/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,23 @@ impl Session {
self.recording_source = recording_source;
}

/// Send log data to a remote server.
/// Send log data to a remote viewer/server.
///
/// Usually this is done by running the `rerun` binary (`cargo install rerun`) without arguments,
/// and then connecting to it.
///
/// Send all currently buffered messages.
/// If we are already connected, we will re-connect to this new address.
///
/// This function returns immediately.
/// Disconnect with [`Self::disconnect`].
///
/// ## Example:
///
/// ``` no_run
/// # let mut session = re_sdk::Session::new();
/// session.connect(re_sdk::default_server_addr());
/// ```
pub fn connect(&mut self, addr: SocketAddr) {
if !self.enabled {
re_log::debug!("Rerun disabled - call to connect() ignored");
Expand Down Expand Up @@ -209,10 +220,16 @@ impl Session {
}
}

/// Serve a Rerun web viewer and stream the log messages to it.
/// Serve log-data over WebSockets and serve a Rerun web viewer over HTTP.
///
/// If the `open_browser` argument is `true`, your default browser
/// will be opened with a connected web-viewer.
///
/// If not, you can connect to this server using the `rerun` binary (`cargo install rerun`).
///
/// NOTE: you can not connect one `Session` to another.
///
/// If the `open_browser` argument is set, your default browser
/// will be opened to show the viewer.
/// This function returns immediately.
#[cfg(feature = "web_viewer")]
pub fn serve(&mut self, open_browser: bool) {
if !self.enabled {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/remote_viewer_app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::App;

/// Connects to a server over `WebSockets`.
/// Connects to a server over WebSockets.
pub struct RemoteViewerApp {
build_info: re_build_info::BuildInfo,
app_env: crate::AppEnvironment,
Expand Down
8 changes: 7 additions & 1 deletion rerun_py/rerun_sdk/rerun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ def connect(addr: Optional[str] = None) -> None:
Requires that you first start a Rerun Viewer, e.g. with 'python -m rerun'
This function returns immediately.
Parameters
----------
addr
Expand Down Expand Up @@ -287,10 +289,14 @@ def spawn(port: int = 9876, connect: bool = True) -> None:

def serve(open_browser: bool = True) -> None:
"""
Serve a Rerun Web Viewer.
Serve log-data over WebSockets and serve a Rerun web viewer over HTTP.
You can connect to this server using `python -m rerun`.
WARNING: This is an experimental feature.
This function returns immediately.
Parameters
----------
open_browser
Expand Down

0 comments on commit 22049e1

Please sign in to comment.