MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / write_docstringdict

Function write_docstringdict

Python/Turtle.py:3719–3751  ·  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

3717Pen = Turtle
3718
3719def write_docstringdict(filename="turtle_docstringdict"):
3720 """Create and write docstring-dictionary to file.
3721
3722 Optional argument:
3723 filename -- a string, used as filename
3724 default value is turtle_docstringdict
3725
3726 Has to be called explicitly, (not used by the turtle-graphics classes)
3727 The docstring dictionary will be written to the Python script <filname>.py
3728 It is intended to serve as a template for translation of the docstrings
3729 into different languages.
3730 """
3731 docsdict = {}
3732
3733 for methodname in _tg_screen_functions:
3734 key = "_Screen."+methodname
3735 docsdict[key] = eval(key).__doc__
3736 for methodname in _tg_turtle_functions:
3737 key = "Turtle."+methodname
3738 docsdict[key] = eval(key).__doc__
3739
3740 with open("%s.py" % filename,"w") as f:
3741 keys = sorted(x for x in docsdict
3742 if x.split('.')[1] not in _alias_list)
3743 f.write('docsdict = {\n\n')
3744 for key in keys[:-1]:
3745 f.write('%s :\n' % repr(key))
3746 f.write(' """%s\n""",\n\n' % docsdict[key])
3747 key = keys[-1]
3748 f.write('%s :\n' % repr(key))
3749 f.write(' """%s\n"""\n\n' % docsdict[key])
3750 f.write("}\n")
3751 f.close()
3752
3753def read_docstrings(lang):
3754 """Read in docstrings from lang-specific docstring dictionary.

Callers

nothing calls this directly

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected