MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / write_docstringdict

Function write_docstringdict

tools/python-3.11.9-amd64/Lib/turtle.py:3838–3870  ·  view source on GitHub ↗

Create and write docstring-dictionary to file. Optional argument: filename -- a string, used as filename default value is turtle_docstringdict Has to be called explicitly, (not used by the turtle-graphics classes) The docstring dictionary will be written to t

(filename="turtle_docstringdict")

Source from the content-addressed store, hash-verified

3836Pen = Turtle
3837
3838def write_docstringdict(filename="turtle_docstringdict"):
3839 """Create and write docstring-dictionary to file.
3840
3841 Optional argument:
3842 filename -- a string, used as filename
3843 default value is turtle_docstringdict
3844
3845 Has to be called explicitly, (not used by the turtle-graphics classes)
3846 The docstring dictionary will be written to the Python script <filename>.py
3847 It is intended to serve as a template for translation of the docstrings
3848 into different languages.
3849 """
3850 docsdict = {}
3851
3852 for methodname in _tg_screen_functions:
3853 key = "_Screen."+methodname
3854 docsdict[key] = eval(key).__doc__
3855 for methodname in _tg_turtle_functions:
3856 key = "Turtle."+methodname
3857 docsdict[key] = eval(key).__doc__
3858
3859 with open("%s.py" % filename,"w") as f:
3860 keys = sorted(x for x in docsdict
3861 if x.split('.')[1] not in _alias_list)
3862 f.write('docsdict = {\n\n')
3863 for key in keys[:-1]:
3864 f.write('%s :\n' % repr(key))
3865 f.write(' """%s\n""",\n\n' % docsdict[key])
3866 key = keys[-1]
3867 f.write('%s :\n' % repr(key))
3868 f.write(' """%s\n"""\n\n' % docsdict[key])
3869 f.write("}\n")
3870 f.close()
3871
3872def read_docstrings(lang):
3873 """Read in docstrings from lang-specific docstring dictionary.

Callers

nothing calls this directly

Calls 5

sortedFunction · 0.85
openFunction · 0.70
splitMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected