MCPcopy Index your code
hub / github.com/python/cpython / write_docstringdict

Function write_docstringdict

Lib/turtle.py:3967–3999  ·  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 the Pyth

(filename="turtle_docstringdict")

Source from the content-addressed store, hash-verified

3965Pen = Turtle
3966
3967def write_docstringdict(filename="turtle_docstringdict"):
3968 """Create and write docstring-dictionary to file.
3969
3970 Optional argument:
3971 filename -- a string, used as filename
3972 default value is turtle_docstringdict
3973
3974 Has to be called explicitly, (not used by the turtle-graphics classes)
3975 The docstring dictionary will be written to the Python script <filename>.py
3976 It is intended to serve as a template for translation of the docstrings
3977 into different languages.
3978 """
3979 docsdict = {}
3980
3981 for methodname in _tg_screen_functions:
3982 key = "_Screen."+methodname
3983 docsdict[key] = eval(key).__doc__
3984 for methodname in _tg_turtle_functions:
3985 key = "Turtle."+methodname
3986 docsdict[key] = eval(key).__doc__
3987
3988 with open("%s.py" % filename,"w") as f:
3989 keys = sorted(x for x in docsdict
3990 if x.split('.')[1] not in _alias_list)
3991 f.write('docsdict = {\n\n')
3992 for key in keys[:-1]:
3993 f.write('%s :\n' % repr(key))
3994 f.write(' """%s\n""",\n\n' % docsdict[key])
3995 key = keys[-1]
3996 f.write('%s :\n' % repr(key))
3997 f.write(' """%s\n"""\n\n' % docsdict[key])
3998 f.write("}\n")
3999 f.close()
4000
4001def read_docstrings(lang):
4002 """Read in docstrings from lang-specific docstring dictionary.

Callers

nothing calls this directly

Calls 4

openFunction · 0.70
splitMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…