@@ -11,11 +11,13 @@ A simplest translation can be processed with the code below.
1111
1212.. literalinclude :: simple.demo.py
1313 :language: python
14+ :linenos:
1415
1516The output result should be
1617
1718.. literalinclude :: simple.demo.py.txt
1819 :language: text
20+ :linenos:
1921
2022Most of the primitive data types supported by python can be \
2123turned back to runnable source code with ``potc ``.
@@ -28,11 +30,13 @@ result to a runnable ``.py`` script, we can do like this
2830
2931.. literalinclude :: vars.demo.py
3032 :language: python
33+ :linenos:
3134
3235The output result (as well as the dumped script) should be
3336
3437.. literalinclude :: vars.demo.py.txt
3538 :language: python
39+ :linenos:
3640
3741It is runnable, you can take a try.
3842
@@ -49,14 +53,84 @@ You can define your own rule like the example below.
4953
5054.. literalinclude :: diy_rule.demo.py
5155 :language: python
56+ :linenos:
5257
5358The output result (as well as the dumped script) should be
5459
5560.. literalinclude :: diy_rule.demo.py.txt
5661 :language: python
62+ :linenos:
5763
5864Now you can see the dictionaries will be expressed with \
5965``dict `` form when the keys is allowed to do so, \
6066the ``np.ndarray `` objects will be expressed with the \
6167visible format as well.
6268
69+
70+ Use CLI For Translating
71+ -------------------------------
72+
73+ In ``potc ``, cli is provided to quickly generate python code. \
74+ For example, you can translate an object with ``potc trans `` \
75+ command. Firstly, here is the content of python source \
76+ file ``data.py ``
77+
78+ .. literalinclude :: data.py
79+ :language: shell
80+ :linenos:
81+
82+ based on this, we can translate ``v_a `` from ``data.py `` by \
83+ this command
84+
85+ .. literalinclude :: cli_obj_1.demo.sh
86+ :language: shell
87+ :linenos:
88+
89+ The output should be
90+
91+ .. literalinclude :: cli_obj_1.demo.sh.txt
92+ :language: text
93+ :linenos:
94+
95+ Also, if you need to take a look at the full information of \
96+ this translation, you can use ``-I `` option to display them, \
97+ like this
98+
99+ .. literalinclude :: cli_obj_2.demo.sh
100+ :language: shell
101+ :linenos:
102+
103+ The output (including information) should be
104+
105+ .. literalinclude :: cli_obj_2.demo.sh.txt
106+ :language: text
107+ :linenos:
108+
109+
110+ In further cases, we may need to directly dump a runnable \
111+ python source code and then maybe execute it. You can dump \
112+ the variables from ``data.py `` by this command
113+
114+ .. literalinclude :: cli_vars_1.demo.sh
115+ :language: shell
116+ :linenos:
117+
118+ The dumped code should be
119+
120+ .. literalinclude :: cli_vars_1.demo.sh.txt
121+ :language: shell
122+ :linenos:
123+
124+
125+ Besides, you can use your self-defined rules to change the \
126+ dumping result, like this
127+
128+ .. literalinclude :: cli_vars_2.demo.sh
129+ :language: shell
130+ :linenos:
131+
132+ The new dumped code should be
133+
134+ .. literalinclude :: cli_vars_2.demo.sh.txt
135+ :language: shell
136+ :linenos:
0 commit comments