@@ -190,7 +190,7 @@ def __init__(
190190 self ._saved_page_arg = page
191191
192192 async def open (self ):
193- """Build page and temporary file if we need one, then opens browser."""
193+ """Build page and temporary file if we need one, then open browser."""
194194 page = self ._saved_page_arg
195195 del self ._saved_page_arg
196196
@@ -423,7 +423,35 @@ async def write_fig_from_object(
423423 _write : bool = True , # backwards compatibility!
424424 stepper : bool = False ,
425425 ) -> None | bytes | tuple [Exception ]:
426- """Temp."""
426+ """
427+ Create one or more plotly figures from a specification dictionary.
428+
429+ If every figure needs a different `opts` or `path` argument, you use
430+ this instead of `write_fig`.
431+
432+ Args:
433+ fig_dicts:
434+ Any single figure dict, or an iterable of figure dictionaries. The
435+ figure dictionaries *must* have a "fig" key with a plotly figure or
436+ its dict representation. It can have the following keys: path, opts,
437+ and topojson. This is roughly equal to the `write_fig` arguments.
438+
439+ cancel_on_error (boolean, default: False):
440+ If False, any errors during rendering will be returned from the function
441+ call in a list. If True, any error will be raised immediately and the
442+ rest of the renders will be cancelled.
443+
444+ stepper (boolean, default False):
445+ This is a debugging argument and is not part of the stable API.
446+ If set to true, kaleido will wait for a key press to render each
447+ image, in case one would want to inspect the browser environment.
448+
449+ Returns:
450+ If cancel_on_error is True, it always returns None on success.
451+ If cancel_on_error is False, it always returns a tuple, possibly
452+ with errors.
453+
454+ """
427455 if not _write :
428456 cancel_on_error = True
429457
@@ -479,7 +507,51 @@ async def write_fig( # noqa: PLR0913
479507 cancel_on_error : bool = False ,
480508 stepper : bool = False ,
481509 ) -> tuple [Exception ] | None :
482- """Temp."""
510+ """
511+ Create one or more plotly figures.
512+
513+ While fig may be an iterable, only a single path and opts may be passed.
514+ Use write_fig_from_object if you need to specify different paths or opts
515+ for each figure.
516+
517+ Args:
518+ fig:
519+ A plotly figure or its dict representation. It can have the
520+ following keys: path, opts, and topojson. This is roughly equal
521+ to the `write_fig` arguments.
522+
523+ path (None, Path, str):
524+ The path where the image will be written. The default is the
525+ current directory. If a filename isn't specified, we try to
526+ generate one from the title or use a default "fig-". If you
527+ pass many figures, this argument should be a directory.
528+
529+ opts (None, LayoutOpts dict):
530+ The layout options are a dictionary with the following optional keys:
531+ - scale: a number to multiply the image by.
532+ - width: a number to set the pixel width.
533+ - height: a number to set the pixel height.
534+ - format: One of jpg, png, svg, pdf, json, or webp.
535+
536+ topojson:
537+ An optional json-format map specification when using geomaps.
538+
539+ cancel_on_error (boolean, default: False):
540+ If False, any errors during rendering will be returned from the function
541+ call in a list. If True, any error will be raised immediately and the
542+ rest of the renders will be cancelled.
543+
544+ stepper (boolean, default False):
545+ This is a debugging argument and is not part of the stable API.
546+ If set to true, kaleido will wait for a key press to render each
547+ image, in case one would want to inspect the browser environment.
548+
549+ Returns:
550+ If cancel_on_error is True, it always returns None on success.
551+ If cancel_on_error is False, it always returns a tuple, possibly
552+ with errors.
553+
554+ """
483555 if fig_tools .is_figurish (fig ) or not isinstance (
484556 fig ,
485557 (Iterable , AsyncIterable ),
@@ -511,7 +583,15 @@ async def calc_fig(
511583 topojson : str | None = None ,
512584 stepper : bool = False ,
513585 ) -> bytes :
514- """Temp."""
586+ """
587+ Run write_fig but instead of writing a file, return the bytes.
588+
589+ The arguments are the same as write_fig, but path does nothing.
590+
591+ Returns:
592+ The calculated bytes.
593+
594+ """
515595 if path is not None :
516596 warnings .warn (
517597 "The path argument is deprecated in `kaleido.calc_fig`. "
0 commit comments