L iCUdZddlmZddlZddlZddlZddlZddlZddlm Z m Z m Z m Z ddl Z ddlmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lm Z e r dd l!m"Z"ddlm#Z#dZ$de%d<GddZ&d(dZ'd)dZ(d)dZ)d)dZ*d)dZ+d*dZ,d+dZ-ej\dZ/d*dZ0d,dZ1d-dZ2d.dZ3d/d Z4d0d!Z5d1d"Z6d2d#Z7d3d$Z8d4d5d%Z9d6d&Z:d7d'Z;y)8z@Allows us to create and absorb changes (aka Deltas) to elements.) annotationsN) TYPE_CHECKINGAnyFinalcast) LayoutConfigvalidate_width) DocString)Member) CachedFunc)gather_metrics)__file__)Secrets)is_mem_address_str)DeltaGenerator)WidthWithoutContent)z (element, r CONFUSING_STREAMLIT_SIG_PREFIXEScPeZdZedefdd ddZeddZy) HelpMixinhelpstretchwidthct}t|dt|}t|||jj d||S)u Display help and other information for a given object. Depending on the type of object that is passed in, this displays the object's name, type, value, signature, docstring, and member variables, methods — as well as the values/docstring of members and methods. Parameters ---------- obj : any The object whose information should be displayed. If left unspecified, this call will display help for Streamlit itself. width : "stretch" or int The width of the help element. This can be one of the following: - ``"stretch"`` (default): The width of the element matches the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. Example ------- Don't remember how to initialize a dataframe? Try this: >>> import streamlit as st >>> import pandas >>> >>> st.help(pandas.DataFrame) .. output:: https://doc-string.streamlit.app/ height: 700px Want to quickly check what data type is output by a certain function? Try: >>> import streamlit as st >>> >>> x = my_poorly_documented_function() >>> st.help(x) Want to quickly inspect an object? No sweat: >>> class Dog: >>> '''A typical dog.''' >>> >>> def __init__(self, breed, color): >>> self.breed = breed >>> self.color = color >>> >>> def bark(self): >>> return 'Woof!' >>> >>> >>> fido = Dog("poodle", "white") >>> >>> st.help(fido) .. output:: https://doc-string1.streamlit.app/ height: 300px And if you're using Magic, you can get help for functions, classes, and modules without even typing ``st.help``: >>> import streamlit as st >>> import pandas >>> >>> # Get help for Pandas read_csv: >>> pandas.read_csv >>> >>> # Get help for Streamlit itself: >>> st .. output:: https://doc-string2.streamlit.app/ height: 700px F) allow_contentr doc_string) layout_config)DocStringProtor r _marshalldg_enqueue)selfobjrdoc_string_protors c/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/doc_string.pyrzHelpMixin.help/sQh*+uE2$51 "C(ww *-   ctd|S)zGet our DeltaGenerator.r)r)r"s r%r z HelpMixin.dgs$d++r&N)r#rrrreturnr)r(r)__name__ __module__ __qualname__r streamlitrpropertyr r&r%rr.sWF"[ DM[ [ .A[ [ [ z,,r&rct}|||_t|}||_t |}|||_t ||}|||_|jjt|y)zIConstruct a DocString object. See DeltaGenerator.help for docs. N) _get_variable_namename_get_type_as_strtype_get_docstringr _get_valuevaluemembersextend _get_members)r$r#var_nameobj_typeobj_docs obj_values r%rrs{ "#H ($H$c"H&.#3)I!*##L$56r&cft|dd}|r td|Stdt|ddS)Nr+str str | Noner))getattrr)r#r1s r% _get_namerBs: 3 -D E4   gc:t< ==r&ct|ddS)Nr*)rAr#s r% _get_modulerEs 3 d ++r&ctj|s t|syd} ttj|}d}tjt5|jdk(}ddd|r1tD](}|j|s|j|d}|S|S#t $rd}Yut $rYywxYw#1swYYxYw)Nz(...)Fzstreamlit.delta_generator()inspectisclasscallabler? signature ValueError TypeError contextlibsuppressAttributeErrorr*r startswithreplace)r#sig is_delta_genprefixs r%_get_signaturerWs ??3   C'##C() L   ^ ,E~~)DD E 6 F~~f%kk&#. J   J%  EEs#B+C+ C8CCCc.tj|}|lt|}|turY|tjurGtj |s2tj |s|turtj|}|r|jSyN) rIgetdocr3types ModuleType isfunctionismethodr strip)r#rr;s r%r4r4s$J9 D  0 00&&s+$$S) * 1J!! r&c2t}|yt|S)zTry to get the name of the variable in the current line, as set by the user. For example: foo = bar.Baz(123) st.help(foo) The name is "foo" N) _get_current_line_of_code_as_str _get_variable_name_from_code_str)codes r%r0r0s , -D | +D 11r&c8tj|}t|dst|ds|jdSt |}|syt |tj ur;t |jtjur2|jjSt |tjury|jd}t|dkD}|j}|r|jdz }||}d}n|d}t|dd }|||S) Nr) command_namewrite, rend_col_offset)astparse _is_stcommand removesuffix_get_stcommand_argr3 NamedExprtargetNameidConstantsplitlen col_offsetlinenorA) rctreearg_node code_lines is_multiline start_offset first_lineno first_line end_offsets r%rbrbs  99T?D* F 3M 7=   %%!$'H  H~&  CHH ,??%% % h3<< ' D!Jz?Q&L&&L*  -   ] X'7< l: ..r&z[\n\r]+ct}|y|j}|sydj|}tjt d|j S)NrG)_get_scriptrunner_frame code_contextjoinresub _NEWLINESr_)scriptrunner_framercode_as_strings r%raraKsS02! %22L  WW\*N 66)R!5!5!7 88r&cd}d}tjD]*}|jy|jtk(r|}|S|},|SrY)rIstackrfilenameSCRIPTRUNNER_FILENAME) prev_framerframes r%rrbsbJ      % >>2 2!+      r&c|jdj}t|tjsyt |j dd|k(xst |j dd|k(S)z:Checks whether the AST in tree is a call for command_name.rFrtNattr)bodyr6 isinstancerlCallrAfunc)rzre root_nodes r%rnrnys^ ! ""I i *  d+|; >  -= r&c|jdj}|jrtd|jdSy)z8Gets the argument node for the st command in tree (AST).rzast.exprN)rr6argsr)rzrs r%rprps7 ! ""I~~J q 122 r&cjtj|rytt|jS)Nclass)rIrJr?r3r)rDs r%r2r2s&s tCy!! ""r&c6|sy|jd\}}}|S)NrGrh) partition)textleft_s r%_get_first_liners! %JD!Q Kr&cttj|rytj|ryt|ryy)Nrir)rIismodulerJrK)r6s r% _get_weightrs/u r&ct|}||St|}|r|}nt|}t|}t|}t |xsd}|r|r |d||n||}||k(rd}|S)NrG.)_get_human_readable_valuerBr3rErW)r#r:r=r1name_objmodulerTs r%r5r5s)#.I S>D 9"  "F  " (bC /5vhavcU+dVC5> H r&c t|trytj|s tj|s t |ryt |}t|tr t|St|ryt|SrY) rrrIrJrrKreprr?_shortenr)r6 value_strs r%rrsi%!u!1!1%!8HUOU I% "")$ I r&cR|j}t||kDr|d|dzS|S)Nz...)r_rw)slengths r%rrs-  A!$Q&1Wf: 7a7r&ct|dd}|sytj|D]9}t||d}|t|tstj |s9yy)N __class__FT)rArIgetmrorr-isgetsetdescriptor)r# attr_name obj_class parent_class class_attrs r%_is_computed_propertyrsh[$/I  y1 \9d;    j( +w/I/I*/U r&cLg}t|D]}|jdr t||}|r(t|j|}d}d}t |}d}nAt||} t | }t| } t| }| t | }d}nd}| }|dk(rt} || _ || _ |t|| _||| _|j!|| f|r#t#|d} | D cgc]\} }| c}} SgS#t$rYwxYwcc}} w)Nrr-rrc*|d|djfS)Nrri)r1)xs r%z_get_members..4sAaD!A$))CTr&)key)dirrRrrArr4rrr2rQ MemberProtor1r3rrr6appendsorted)r#members_for_sortingris_computed_value parent_attr member_typeweight member_docs member_value attr_valuehuman_readable_valuemembersorted_membersrms r%r9r9sRX05    $   5c9 E  %cmmY? ( ,[9 # $S)4 $Z0'@'L$.z: '/"0" D  DD)r$rr#rr(None)r#objectr(r@)r(r@)rcr?r(r@)r(zinspect.FrameInfo | None)rzrrer?r(bool)rzz ast.Moduler(zast.expr | None)r#rr(r?)rr?r(r?)r6rr(int)r#rr:r@r(r@)r6rr(r@)i,)rr?rrr(r?)r#rrr?r(r)r#rr(zlist[MemberProto])<__doc__ __future__rrlrOrIrr[typingrrrrr,#streamlit.elements.lib.layout_utilsrr streamlit.proto.DocString_pb2r rr r%streamlit.runtime.caching.cache_utilsr streamlit.runtime.metrics_utilr ,streamlit.runtime.scriptrunner.script_runnerrrstreamlit.runtime.secretsrstreamlit.string_utilrstreamlit.delta_generatorrrr__annotations__rrrBrErWr4r0rbcompilerrarrnrpr2rrr5rrrr9r.r&r%rsG"  22LE?<9.48G+: %9b,b,J7. >,:42"A/H BJJz " 9..  # @.8 *9r&