| 6 | |
| 7 | |
| 8 | def normalize_doc(docstring): |
| 9 | docstring = textwrap.dedent(docstring).strip() |
| 10 | docstring = docstring.encode('unicode-escape').decode('ascii') |
| 11 | docstring = docstring.replace(r'"', r'\"') |
| 12 | docstring = docstring.replace(r"'", r"\'") |
| 13 | # Split the docstring because some compilers (like MS) do not like big |
| 14 | # string literal in C code. We split at endlines because textwrap.wrap |
| 15 | # do not play well with \n |
| 16 | docstring = '\\n\"\"'.join(docstring.split(r"\n")) |
| 17 | return docstring |
| 18 | |
| 19 | def write_code(target): |
| 20 | with open(target, 'w') as fid: |