| 1 |
"""Creates a version of traceback_it.rst to insert in the documentation. |
| 2 |
""" |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
import os |
| 13 |
import sys |
| 14 |
import platform |
| 15 |
this_dir = os.path.dirname(__file__) |
| 16 |
sys.path.append(os.path.join(this_dir, "..")) |
| 17 |
import friendly_traceback |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
docs_root_dir = os.path.abspath( |
| 22 |
os.path.join(this_dir, "..", "..", "friendly-docs") |
| 23 |
) |
| 24 |
assert os.path.isdir(docs_root_dir), "Separate docs repo need to exist" |
| 25 |
sys.path.append(os.path.join(this_dir, "..")) |
| 26 |
|
| 27 |
LANG = "it" |
| 28 |
friendly_traceback.install() |
| 29 |
friendly_traceback.set_lang(LANG) |
| 30 |
friendly_traceback.set_formatter("docs") |
| 31 |
|
| 32 |
sys.path.insert(0, this_dir) |
| 33 |
py_version = f"{sys.version_info.major}.{sys.version_info.minor}" |
| 34 |
|
| 35 |
import trb_common |
| 36 |
|
| 37 |
target = os.path.normpath( |
| 38 |
os.path.join(docs_root_dir, f"source/tracebacks_{LANG}.rst") |
| 39 |
) |
| 40 |
|
| 41 |
intro_text = """ |
| 42 |
Friendly tracebacks - in italiano |
| 43 |
====================================== |
| 44 |
|
| 45 |
Friendly aims to provide friendlier feedback when an exception |
| 46 |
is raised than what is done by Python. |
| 47 |
|
| 48 |
Below, we can find some examples. SyntaxError cases, as well as TabError and |
| 49 |
IndentationError cases, are shown in a separate page. |
| 50 |
Not all cases handled by friendly are included here. |
| 51 |
|
| 52 |
.. note:: |
| 53 |
|
| 54 |
The content of this page is generated by running |
| 55 |
`{name}` located in the ``tests/`` directory. |
| 56 |
This needs to be done explicitly, independently of updating the |
| 57 |
documentation using Sphinx. |
| 58 |
|
| 59 |
Friendly-traceback version: {friendly} |
| 60 |
Python version: {python} |
| 61 |
|
| 62 |
""".format( |
| 63 |
friendly=friendly_traceback.__version__, |
| 64 |
python=platform.python_version(), |
| 65 |
name=sys.argv[0], |
| 66 |
) |
| 67 |
|
| 68 |
print(f"Python version: {platform.python_version()}; Italian") |
| 69 |
|
| 70 |
trb_common.create_tracebacks(target, intro_text) |