@@ -21,7 +21,12 @@ class VNClient(CompositeClient):
2121
2222 @property
2323 def tcp (self ) -> TCPClient :
24- """Get the TCP client."""
24+ """
25+ Access the underlying TCP client.
26+
27+ Returns:
28+ TCPClient: The TCP client instance stored in this composite client's children mapping.
29+ """
2530 return typing .cast ("TCPClient" , self .children ["tcp" ])
2631
2732 def stream (self , method = "connect" ):
@@ -34,7 +39,15 @@ async def stream_async(self, method="connect"):
3439
3540 @contextlib .contextmanager
3641 def session (self , * , encrypt : bool = True ) -> typing .Iterator [str ]:
37- """Create a new VNC session."""
42+ """
43+ Open a noVNC session and yield the connection URL.
44+
45+ Parameters:
46+ encrypt (bool): If True, request an encrypted vnc connection.
47+
48+ Returns:
49+ url (str): The URL to connect to the VNC session.
50+ """
3851 with NovncAdapter (client = self .tcp , method = "connect" , encrypt = encrypt ) as adapter :
3952 yield adapter
4053
@@ -43,11 +56,32 @@ def get_default_encrypt(self) -> bool:
4356 return self .portal .call (DriverClient .call_async , self , "get_default_encrypt" )
4457
4558 def cli (self ) -> click .Command :
46- """Return a click command handler for this driver."""
59+ """
60+ Provide a Click command group for running VNC sessions.
61+
62+ The returned command exposes a `session` subcommand that opens a VNC session,
63+ prints the connection URL, optionally opens it in the user's browser,
64+ and waits until the user cancels the session.
65+
66+ Returns:
67+ click.Command: Click command group with a `session` subcommand that accepts
68+ `--browser/--no-browser` and `--encrypt/--no-encrypt` options.
69+ """
4770
4871 @driver_click_group (self )
4972 def vnc ():
50- """Open a VNC session."""
73+ """
74+ Open a VNC session and block until the user closes it.
75+
76+ When invoked, prints the connection URL for the noVNC session, optionally
77+ opens that URL in the user's web browser, and waits for user-initiated
78+ termination (for example, Ctrl+C). On exit, prints a message indicating
79+ the session is closing.
80+
81+ Parameters:
82+ browser (bool): If True, open the session URL in the default web browser.
83+ encrypt_override (bool): If True, request an encrypted vnc connection.
84+ """
5185
5286 @vnc .command ()
5387 @click .option ("--browser/--no-browser" , default = True , help = "Open the session in a web browser." )
@@ -56,16 +90,26 @@ def vnc():
5690 "encrypt_override" ,
5791 flag_value = True ,
5892 default = None ,
59- help = "Force an encrypted connection (wss://) . Overrides the driver default." ,
93+ help = "Force an encrypted vnc connection . Overrides the driver default." ,
6094 )
6195 @click .option (
6296 "--no-encrypt" ,
6397 "encrypt_override" ,
6498 flag_value = False ,
65- help = "Force an unencrypted connection (ws://) . Overrides the driver default." ,
99+ help = "Force an unencrypted vnc connection . Overrides the driver default." ,
66100 )
67101 def session (browser : bool , encrypt_override : bool | None ):
68- """Open a VNC session."""
102+ """
103+ Open an interactive VNC session and wait for the user to terminate it.
104+
105+ Starts a VNC session using the client's session context, prints the connection
106+ URL, optionally opens that URL in a web browser, and blocks until the user
107+ cancels (e.g., Ctrl+C), then closes the session.
108+
109+ Parameters:
110+ browser (bool): If True, open the session URL in the default web browser.
111+ encrypt (bool): If True, request noVNC to use an encrypted vnc connection.
112+ """
69113 encrypt = encrypt_override if encrypt_override is not None else self .get_default_encrypt ()
70114 # The NovncAdapter is a blocking context manager that runs in a thread.
71115 # We can enter it, open the browser, and then just wait for the user
0 commit comments