Debian Codegraph @

tests/trb_syntax_french.py

raw symbols SCIP
1 """Creates a version of traceback_fr.rst to insert in the documentation.
2 """
3
4 # When creating a new translation, you need to:
5 # 1. Make a copy of this file
6 # 2. Change the value of LANG as well as 'intro_text' so that they reflect the
7 # appropriate language
8 # 3. Change the first line of this file so that the name of the rst file
9 # is correct!
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 # Make it possible to find docs and tests source
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
26 LANG = "fr"
27 friendly_traceback.install()
28 friendly_traceback.set_lang(LANG)
29 friendly_traceback.set_formatter("docs")
30
31 sys.path.insert(0, this_dir)
32
33
34 import trb_syntax_common
35
36 target = os.path.normpath(
37 os.path.join(docs_root_dir, f"source/syntax_tracebacks_{LANG}.rst")
38 )
39
40 intro_text = """
41 |france| Friendly SyntaxError tracebacks - en Français
42 ======================================================
43
44 Le but principal de friendly est de fournir des rétroactions plus
45 conviviales que les fameux **tracebacks** de Python lorsqu'une exception survient.
46 Ci-dessous, on peut voir plusieurs exemples, uniquement pour les
47 exceptions de type SyntaxError et des classes dérivées;
48 les autres sont couvertes dans une autre page.
49 Le but est de documenter ici tous les exemples possibles
50 tels qu'interprétés par friendly_traceback.
51
52 .. note::
53
54 Le contenu de cette page a été généré par l'exécution de
55 {name} situé dans le répertoire ``tests/``.
56 Ceci a besoin d'être fait de manière explicite lorsqu'on veut
57 faire des corrections ou des ajouts, avant de faire la mise
58 à jour du reste de la documentation avec Sphinx.
59 Sous Windows, si Sphinx est installé sur votre ordinateur, il est
60 plutôt suggéré d'exécuter make_trb.bat qui est au premier niveau
61 du répertoire de fichier. Si vous faites ceci, la documentation pour
62 toutes les langues sera automatiquement mise à jour.
63
64 Friendly version: {friendly}
65 Python version: {python}
66
67 """.format(
68 friendly=friendly_traceback.__version__,
69 python=platform.python_version(),
70 name=sys.argv[0],
71 )
72
73 print(f"Python version: {platform.python_version()}; French")
74
75 trb_syntax_common.create_tracebacks(target, intro_text)