MCPcopy Index your code
hub / github.com/plotly/plotly.py / add_docstring

Function add_docstring

codegen/datatypes.py:506–604  ·  view source on GitHub ↗

Write docstring for a compound datatype node Parameters ---------- buffer : StringIO Buffer to write to node : PlotlyNode Compound datatype plotly node for which to write docstring header : Top-level header for docstring that will preceded the input

(
    buffer, node, header, prepend_extras=(), append_extras=(), return_type=None
)

Source from the content-addressed store, hash-verified

504
505
506def add_docstring(
507 buffer, node, header, prepend_extras=(), append_extras=(), return_type=None
508):
509 """
510 Write docstring for a compound datatype node
511
512 Parameters
513 ----------
514 buffer : StringIO
515 Buffer to write to
516 node : PlotlyNode
517 Compound datatype plotly node for which to write docstring
518 header :
519 Top-level header for docstring that will preceded the input node's
520 own description. Header should be < 71 characters long
521 prepend_extras :
522 List or tuple of propery name / description pairs that should be
523 included at the beginning of the docstring
524 append_extras :
525 List or tuple of propery name / description pairs that should be
526 included at the end of the docstring
527 return_type :
528 The docstring return type
529 Returns
530 -------
531
532 """
533 # Validate inputs
534 assert node.is_compound
535
536 # Build wrapped description
537 node_description = node.description
538 if node_description:
539 description_lines = textwrap.wrap(
540 node_description,
541 width=79 - 8,
542 initial_indent=" " * 8,
543 subsequent_indent=" " * 8,
544 )
545
546 node_description = "\n".join(description_lines) + "\n\n"
547
548 # Write header and description
549 buffer.write(
550 f"""
551 \"\"\"
552 {header}
553
554{node_description} Parameters
555 ----------"""
556 )
557
558 # Write parameter descriptions
559
560 # Write any prepend extras
561 for p, v in prepend_extras:
562 v_wrapped = "\n".join(
563 textwrap.wrap(

Callers 2

build_figure_pyFunction · 0.90
build_datatype_pyFunction · 0.85

Calls 3

wrapMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected