traceback-id 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- traceback_id-0.1.0/LICENSE +21 -0
- traceback_id-0.1.0/PKG-INFO +191 -0
- traceback_id-0.1.0/README.md +160 -0
- traceback_id-0.1.0/pyproject.toml +57 -0
- traceback_id-0.1.0/setup.cfg +4 -0
- traceback_id-0.1.0/tests/test_contract.py +58 -0
- traceback_id-0.1.0/traceback_id/__init__.py +19 -0
- traceback_id-0.1.0/traceback_id/__main__.py +8 -0
- traceback_id-0.1.0/traceback_id/adapters/__init__.py +1 -0
- traceback_id-0.1.0/traceback_id/adapters/base.py +36 -0
- traceback_id-0.1.0/traceback_id/adapters/python/__init__.py +1 -0
- traceback_id-0.1.0/traceback_id/adapters/python/adapter.py +140 -0
- traceback_id-0.1.0/traceback_id/adapters/python/rules.yaml +174 -0
- traceback_id-0.1.0/traceback_id/cli.py +78 -0
- traceback_id-0.1.0/traceback_id/core/__init__.py +1 -0
- traceback_id-0.1.0/traceback_id/core/explainer.py +108 -0
- traceback_id-0.1.0/traceback_id/core/formatter.py +54 -0
- traceback_id-0.1.0/traceback_id/core/models.py +52 -0
- traceback_id-0.1.0/traceback_id/core/registry.py +81 -0
- traceback_id-0.1.0/traceback_id/hook.py +53 -0
- traceback_id-0.1.0/traceback_id/rules/universal_categories.yaml +99 -0
- traceback_id-0.1.0/traceback_id.egg-info/PKG-INFO +191 -0
- traceback_id-0.1.0/traceback_id.egg-info/SOURCES.txt +25 -0
- traceback_id-0.1.0/traceback_id.egg-info/dependency_links.txt +1 -0
- traceback_id-0.1.0/traceback_id.egg-info/entry_points.txt +2 -0
- traceback_id-0.1.0/traceback_id.egg-info/requires.txt +8 -0
- traceback_id-0.1.0/traceback_id.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 traceback_id contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: traceback-id
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Penjelasan error/traceback pemrograman dalam Bahasa Indonesia, untuk pemula.
|
|
5
|
+
Author: traceback_id contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/traceback-id/traceback_id
|
|
8
|
+
Project-URL: Issues, https://github.com/traceback-id/traceback_id/issues
|
|
9
|
+
Keywords: error,traceback,bahasa indonesia,belajar coding,education,debugging
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Intended Audience :: Education
|
|
18
|
+
Classifier: Natural Language :: Indonesian
|
|
19
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
20
|
+
Classifier: Topic :: Education
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: PyYAML>=6.0
|
|
25
|
+
Provides-Extra: color
|
|
26
|
+
Requires-Dist: rich>=13.0; extra == "color"
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
|
+
Requires-Dist: rich>=13.0; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# traceback_id
|
|
33
|
+
|
|
34
|
+
Penjelasan error/traceback pemrograman dalam **Bahasa Indonesia**, untuk
|
|
35
|
+
pemula — dimulai dari Python.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## Kenapa traceback_id?
|
|
39
|
+
|
|
40
|
+
Traceback Python (atau stack trace/compiler error di bahasa lain) ditulis
|
|
41
|
+
dalam bahasa Inggris teknis yang sering bikin pemula mentok. traceback_id
|
|
42
|
+
tetap menampilkan error aslinya (developer berpengalaman tetap butuh itu),
|
|
43
|
+
lalu menambahkan penjelasan singkat dalam Bahasa Indonesia: **kenapa** error
|
|
44
|
+
ini terjadi, dan **apa** yang bisa dicoba untuk memperbaikinya.
|
|
45
|
+
|
|
46
|
+
## Instalasi
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install -e ".[color]"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`rich` (untuk output berwarna) sifatnya opsional — tanpa `[color]`,
|
|
53
|
+
traceback_id tetap berfungsi penuh dengan output teks polos.
|
|
54
|
+
|
|
55
|
+
## Pemakaian
|
|
56
|
+
|
|
57
|
+
### Mode in-process (khusus Python — DX terbaik)
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
import traceback_id
|
|
61
|
+
traceback_id.activate()
|
|
62
|
+
|
|
63
|
+
print(nilai_yang_tidak_ada)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Traceback (most recent call last):
|
|
68
|
+
File "contoh.py", line 4, in <module>
|
|
69
|
+
print(nilai_yang_tidak_ada)
|
|
70
|
+
NameError: name 'nilai_yang_tidak_ada' is not defined
|
|
71
|
+
------------------------------------------------------------
|
|
72
|
+
penjelasan traceback_id (Bahasa Indonesia):
|
|
73
|
+
Kode kamu mencoba memakai nama `nilai_yang_tidak_ada`, tapi Python belum
|
|
74
|
+
pernah melihat nama itu didefinisikan sebelumnya di titik ini.
|
|
75
|
+
|
|
76
|
+
Saran: Periksa apakah `nilai_yang_tidak_ada` sudah kamu isi nilainya
|
|
77
|
+
sebelum baris ini, atau cek kemungkinan salah ketik nama variabel/fungsi.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Nonaktifkan kapan saja dengan `traceback_id.deactivate()` — traceback
|
|
81
|
+
kembali ke behavior default Python, dan exit code program tidak berubah.
|
|
82
|
+
|
|
83
|
+
### Mode CLI (universal — dipakai bahasa apa pun yang punya adapter)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
traceback_id run script.py
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Ekstensi file (`.py`, nanti `.js`, `.java`, dst) dipakai untuk memilih
|
|
90
|
+
adapter secara otomatis, atau paksa lewat `--lang`:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
traceback_id run script.mjs --lang javascript
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Contoh untuk dicoba
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
traceback_id run examples/demo_errors.py name_error
|
|
100
|
+
traceback_id run examples/syntax_error_demo.py
|
|
101
|
+
traceback_id run examples/indentation_error_demo.py
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Lihat `examples/demo_errors.py` untuk daftar lengkap 15 jenis error yang
|
|
105
|
+
di-cover di v0.1 (`name_error`, `type_error`, `index_error`, `key_error`,
|
|
106
|
+
`attribute_error`, `zero_division_error`, `import_error`,
|
|
107
|
+
`module_not_found_error`, `value_error`, `file_not_found_error`,
|
|
108
|
+
`recursion_error`, `stop_iteration`, `unbound_local_error`, plus
|
|
109
|
+
`syntax_error_demo.py` & `indentation_error_demo.py` yang terpisah).
|
|
110
|
+
|
|
111
|
+
## Struktur Proyek
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
traceback_id/
|
|
115
|
+
├── traceback_id/ # package yang diinstall
|
|
116
|
+
│ ├── __init__.py # activate() / deactivate() publik
|
|
117
|
+
│ ├── hook.py # sys.excepthook, mode in-process
|
|
118
|
+
│ ├── cli.py # `traceback_id run <file>`
|
|
119
|
+
│ ├── core/ # mesin inti — language-agnostic
|
|
120
|
+
│ │ ├── models.py # StructuredError, ErrorCategory
|
|
121
|
+
│ │ ├── explainer.py # cocokkan rule, render template
|
|
122
|
+
│ │ ├── formatter.py # gabung traceback asli + penjelasan
|
|
123
|
+
│ │ └── registry.py # daftar adapter (built-in + plugin)
|
|
124
|
+
│ ├── adapters/
|
|
125
|
+
│ │ ├── base.py # LanguageAdapter (kontrak)
|
|
126
|
+
│ │ └── python/
|
|
127
|
+
│ │ ├── adapter.py # capture (hook + subprocess), parser
|
|
128
|
+
│ │ └── rules.yaml # 15 error type Python v0.1
|
|
129
|
+
│ └── rules/
|
|
130
|
+
│ └── universal_categories.yaml # fallback lintas bahasa
|
|
131
|
+
├── tests/
|
|
132
|
+
│ ├── test_core/
|
|
133
|
+
│ ├── test_adapters/
|
|
134
|
+
│ └── test_contract.py # semua adapter wajib lolos test ini
|
|
135
|
+
├── examples/
|
|
136
|
+
│ └── demo_errors.py
|
|
137
|
+
├── pyproject.toml
|
|
138
|
+
└── README.md
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Menambah bahasa baru = buat folder `traceback_id/adapters/<bahasa>/` berisi
|
|
142
|
+
`adapter.py` (implementasi `LanguageAdapter`) + `rules.yaml` — `core/` tidak
|
|
143
|
+
perlu disentuh sama sekali (lihat `ARCHITECTURE.md` §7).
|
|
144
|
+
|
|
145
|
+
## Menambah Rule Baru (Python)
|
|
146
|
+
|
|
147
|
+
Rule ada di `traceback_id/adapters/python/rules.yaml`, key-nya = nama
|
|
148
|
+
error native (mis. `NameError`). Tidak perlu ubah kode inti:
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
NamaErrorBaru:
|
|
152
|
+
category: KATEGORI_UNIVERSAL_YANG_SESUAI # lihat ErrorCategory di core/models.py
|
|
153
|
+
pattern: "regex opsional dengan (?P<nama_variabel>...)"
|
|
154
|
+
penjelasan: >
|
|
155
|
+
Penjelasan kenapa error ini terjadi. Bisa pakai {nama_variabel} yang
|
|
156
|
+
diambil dari `pattern` di atas.
|
|
157
|
+
saran: >
|
|
158
|
+
Saran konkret cara memperbaikinya.
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Kontribusi Adapter Bahasa Baru (fase komunitas)
|
|
162
|
+
|
|
163
|
+
Setelah kontrak `LanguageAdapter` dibuka untuk plugin (roadmap Fase 3 —
|
|
164
|
+
lihat `PRD.md` §10), adapter bahasa baru bisa didistribusikan sebagai
|
|
165
|
+
package Python terpisah dan otomatis terdeteksi lewat `entry_points`:
|
|
166
|
+
|
|
167
|
+
```toml
|
|
168
|
+
# pyproject.toml package plugin kamu, mis. traceback-id-javascript
|
|
169
|
+
[project.entry-points."traceback_id.adapters"]
|
|
170
|
+
javascript = "traceback_id_javascript.adapter:JavaScriptAdapter"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Semua adapter — built-in maupun plugin — wajib lolos `tests/test_contract.py`.
|
|
174
|
+
|
|
175
|
+
## Menjalankan Test
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install -e ".[dev]"
|
|
179
|
+
pytest
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Status & Roadmap
|
|
183
|
+
|
|
184
|
+
Draft v0.1 (MVP): arsitektur core + adapter diterapkan, adapter Python
|
|
185
|
+
matang (15 jenis error, mode in-process & CLI). Roadmap lengkap
|
|
186
|
+
(JavaScript di v0.3, Java + `entry_points` publik di v0.4, dst) ada di
|
|
187
|
+
`PRD.md` §10 dan `ARCHITECTURE.md` §10.
|
|
188
|
+
|
|
189
|
+
## Lisensi
|
|
190
|
+
|
|
191
|
+
MIT — lihat [`LICENSE`](LICENSE).
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# traceback_id
|
|
2
|
+
|
|
3
|
+
Penjelasan error/traceback pemrograman dalam **Bahasa Indonesia**, untuk
|
|
4
|
+
pemula — dimulai dari Python.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Kenapa traceback_id?
|
|
8
|
+
|
|
9
|
+
Traceback Python (atau stack trace/compiler error di bahasa lain) ditulis
|
|
10
|
+
dalam bahasa Inggris teknis yang sering bikin pemula mentok. traceback_id
|
|
11
|
+
tetap menampilkan error aslinya (developer berpengalaman tetap butuh itu),
|
|
12
|
+
lalu menambahkan penjelasan singkat dalam Bahasa Indonesia: **kenapa** error
|
|
13
|
+
ini terjadi, dan **apa** yang bisa dicoba untuk memperbaikinya.
|
|
14
|
+
|
|
15
|
+
## Instalasi
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install -e ".[color]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`rich` (untuk output berwarna) sifatnya opsional — tanpa `[color]`,
|
|
22
|
+
traceback_id tetap berfungsi penuh dengan output teks polos.
|
|
23
|
+
|
|
24
|
+
## Pemakaian
|
|
25
|
+
|
|
26
|
+
### Mode in-process (khusus Python — DX terbaik)
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import traceback_id
|
|
30
|
+
traceback_id.activate()
|
|
31
|
+
|
|
32
|
+
print(nilai_yang_tidak_ada)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Traceback (most recent call last):
|
|
37
|
+
File "contoh.py", line 4, in <module>
|
|
38
|
+
print(nilai_yang_tidak_ada)
|
|
39
|
+
NameError: name 'nilai_yang_tidak_ada' is not defined
|
|
40
|
+
------------------------------------------------------------
|
|
41
|
+
penjelasan traceback_id (Bahasa Indonesia):
|
|
42
|
+
Kode kamu mencoba memakai nama `nilai_yang_tidak_ada`, tapi Python belum
|
|
43
|
+
pernah melihat nama itu didefinisikan sebelumnya di titik ini.
|
|
44
|
+
|
|
45
|
+
Saran: Periksa apakah `nilai_yang_tidak_ada` sudah kamu isi nilainya
|
|
46
|
+
sebelum baris ini, atau cek kemungkinan salah ketik nama variabel/fungsi.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Nonaktifkan kapan saja dengan `traceback_id.deactivate()` — traceback
|
|
50
|
+
kembali ke behavior default Python, dan exit code program tidak berubah.
|
|
51
|
+
|
|
52
|
+
### Mode CLI (universal — dipakai bahasa apa pun yang punya adapter)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
traceback_id run script.py
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Ekstensi file (`.py`, nanti `.js`, `.java`, dst) dipakai untuk memilih
|
|
59
|
+
adapter secara otomatis, atau paksa lewat `--lang`:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
traceback_id run script.mjs --lang javascript
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Contoh untuk dicoba
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
traceback_id run examples/demo_errors.py name_error
|
|
69
|
+
traceback_id run examples/syntax_error_demo.py
|
|
70
|
+
traceback_id run examples/indentation_error_demo.py
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Lihat `examples/demo_errors.py` untuk daftar lengkap 15 jenis error yang
|
|
74
|
+
di-cover di v0.1 (`name_error`, `type_error`, `index_error`, `key_error`,
|
|
75
|
+
`attribute_error`, `zero_division_error`, `import_error`,
|
|
76
|
+
`module_not_found_error`, `value_error`, `file_not_found_error`,
|
|
77
|
+
`recursion_error`, `stop_iteration`, `unbound_local_error`, plus
|
|
78
|
+
`syntax_error_demo.py` & `indentation_error_demo.py` yang terpisah).
|
|
79
|
+
|
|
80
|
+
## Struktur Proyek
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
traceback_id/
|
|
84
|
+
├── traceback_id/ # package yang diinstall
|
|
85
|
+
│ ├── __init__.py # activate() / deactivate() publik
|
|
86
|
+
│ ├── hook.py # sys.excepthook, mode in-process
|
|
87
|
+
│ ├── cli.py # `traceback_id run <file>`
|
|
88
|
+
│ ├── core/ # mesin inti — language-agnostic
|
|
89
|
+
│ │ ├── models.py # StructuredError, ErrorCategory
|
|
90
|
+
│ │ ├── explainer.py # cocokkan rule, render template
|
|
91
|
+
│ │ ├── formatter.py # gabung traceback asli + penjelasan
|
|
92
|
+
│ │ └── registry.py # daftar adapter (built-in + plugin)
|
|
93
|
+
│ ├── adapters/
|
|
94
|
+
│ │ ├── base.py # LanguageAdapter (kontrak)
|
|
95
|
+
│ │ └── python/
|
|
96
|
+
│ │ ├── adapter.py # capture (hook + subprocess), parser
|
|
97
|
+
│ │ └── rules.yaml # 15 error type Python v0.1
|
|
98
|
+
│ └── rules/
|
|
99
|
+
│ └── universal_categories.yaml # fallback lintas bahasa
|
|
100
|
+
├── tests/
|
|
101
|
+
│ ├── test_core/
|
|
102
|
+
│ ├── test_adapters/
|
|
103
|
+
│ └── test_contract.py # semua adapter wajib lolos test ini
|
|
104
|
+
├── examples/
|
|
105
|
+
│ └── demo_errors.py
|
|
106
|
+
├── pyproject.toml
|
|
107
|
+
└── README.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Menambah bahasa baru = buat folder `traceback_id/adapters/<bahasa>/` berisi
|
|
111
|
+
`adapter.py` (implementasi `LanguageAdapter`) + `rules.yaml` — `core/` tidak
|
|
112
|
+
perlu disentuh sama sekali (lihat `ARCHITECTURE.md` §7).
|
|
113
|
+
|
|
114
|
+
## Menambah Rule Baru (Python)
|
|
115
|
+
|
|
116
|
+
Rule ada di `traceback_id/adapters/python/rules.yaml`, key-nya = nama
|
|
117
|
+
error native (mis. `NameError`). Tidak perlu ubah kode inti:
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
NamaErrorBaru:
|
|
121
|
+
category: KATEGORI_UNIVERSAL_YANG_SESUAI # lihat ErrorCategory di core/models.py
|
|
122
|
+
pattern: "regex opsional dengan (?P<nama_variabel>...)"
|
|
123
|
+
penjelasan: >
|
|
124
|
+
Penjelasan kenapa error ini terjadi. Bisa pakai {nama_variabel} yang
|
|
125
|
+
diambil dari `pattern` di atas.
|
|
126
|
+
saran: >
|
|
127
|
+
Saran konkret cara memperbaikinya.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Kontribusi Adapter Bahasa Baru (fase komunitas)
|
|
131
|
+
|
|
132
|
+
Setelah kontrak `LanguageAdapter` dibuka untuk plugin (roadmap Fase 3 —
|
|
133
|
+
lihat `PRD.md` §10), adapter bahasa baru bisa didistribusikan sebagai
|
|
134
|
+
package Python terpisah dan otomatis terdeteksi lewat `entry_points`:
|
|
135
|
+
|
|
136
|
+
```toml
|
|
137
|
+
# pyproject.toml package plugin kamu, mis. traceback-id-javascript
|
|
138
|
+
[project.entry-points."traceback_id.adapters"]
|
|
139
|
+
javascript = "traceback_id_javascript.adapter:JavaScriptAdapter"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Semua adapter — built-in maupun plugin — wajib lolos `tests/test_contract.py`.
|
|
143
|
+
|
|
144
|
+
## Menjalankan Test
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pip install -e ".[dev]"
|
|
148
|
+
pytest
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Status & Roadmap
|
|
152
|
+
|
|
153
|
+
Draft v0.1 (MVP): arsitektur core + adapter diterapkan, adapter Python
|
|
154
|
+
matang (15 jenis error, mode in-process & CLI). Roadmap lengkap
|
|
155
|
+
(JavaScript di v0.3, Java + `entry_points` publik di v0.4, dst) ada di
|
|
156
|
+
`PRD.md` §10 dan `ARCHITECTURE.md` §10.
|
|
157
|
+
|
|
158
|
+
## Lisensi
|
|
159
|
+
|
|
160
|
+
MIT — lihat [`LICENSE`](LICENSE).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "traceback-id"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Penjelasan error/traceback pemrograman dalam Bahasa Indonesia, untuk pemula."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "traceback_id contributors" }]
|
|
13
|
+
keywords = ["error", "traceback", "bahasa indonesia", "belajar coding", "education", "debugging"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.8",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Intended Audience :: Education",
|
|
23
|
+
"Natural Language :: Indonesian",
|
|
24
|
+
"Topic :: Software Development :: Debuggers",
|
|
25
|
+
"Topic :: Education",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"PyYAML>=6.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
color = ["rich>=13.0"]
|
|
33
|
+
dev = ["pytest>=7.0", "rich>=13.0"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/traceback-id/traceback_id"
|
|
37
|
+
Issues = "https://github.com/traceback-id/traceback_id/issues"
|
|
38
|
+
|
|
39
|
+
[project.scripts]
|
|
40
|
+
traceback_id = "traceback_id.cli:main"
|
|
41
|
+
|
|
42
|
+
# Community plugins register themselves here from their own package's
|
|
43
|
+
# pyproject.toml, e.g.:
|
|
44
|
+
#
|
|
45
|
+
# [project.entry-points."traceback_id.adapters"]
|
|
46
|
+
# javascript = "traceback_id_javascript.adapter:JavaScriptAdapter"
|
|
47
|
+
#
|
|
48
|
+
# See ARCHITECTURE.md §1 and §3 (core/registry.py).
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.packages.find]
|
|
51
|
+
include = ["traceback_id*"]
|
|
52
|
+
|
|
53
|
+
[tool.setuptools.package-data]
|
|
54
|
+
traceback_id = ["rules/*.yaml", "adapters/*/rules.yaml"]
|
|
55
|
+
|
|
56
|
+
[tool.pytest.ini_options]
|
|
57
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""Test kontrak (ARCHITECTURE.md §11): dijalankan terhadap *setiap* adapter
|
|
2
|
+
yang terdaftar di registry (built-in maupun plugin komunitas) untuk
|
|
3
|
+
memastikan capture() dan parse() selalu menghasilkan StructuredError yang
|
|
4
|
+
valid. Ini pengaman utama supaya adapter baru tidak diam-diam melanggar
|
|
5
|
+
kontrak `LanguageAdapter`.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from traceback_id.adapters.base import LanguageAdapter
|
|
12
|
+
from traceback_id.core.models import ErrorCategory, StructuredError
|
|
13
|
+
from traceback_id.core.registry import get_registry
|
|
14
|
+
|
|
15
|
+
# Setiap adapter builtin yang punya contoh error otomatis untuk dites di sini.
|
|
16
|
+
# Adapter baru (mis. javascript, java) tinggal menambah entri: nama adapter
|
|
17
|
+
# -> (isi file contoh yang pasti error, argumen tambahan untuk capture()).
|
|
18
|
+
_KNOWN_ERROR_SOURCES = {
|
|
19
|
+
"python": "nilai_yang_tidak_pernah_didefinisikan\n",
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _all_adapters() -> list:
|
|
24
|
+
registry = get_registry()
|
|
25
|
+
return [registry.get_by_name(name) for name in registry.available_languages()]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@pytest.mark.parametrize("adapter", _all_adapters(), ids=lambda a: a.name)
|
|
29
|
+
def test_adapter_declares_name_and_extensions(adapter: LanguageAdapter):
|
|
30
|
+
assert adapter.name
|
|
31
|
+
assert adapter.file_extensions
|
|
32
|
+
assert all(ext.startswith(".") for ext in adapter.file_extensions)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.mark.parametrize("adapter", _all_adapters(), ids=lambda a: a.name)
|
|
36
|
+
def test_adapter_rules_path_exists(adapter: LanguageAdapter):
|
|
37
|
+
assert adapter.rules_path.exists(), f"rules_path {adapter.rules_path} tidak ditemukan"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.mark.parametrize("adapter", _all_adapters(), ids=lambda a: a.name)
|
|
41
|
+
def test_adapter_capture_and_parse_produce_valid_structured_error(adapter: LanguageAdapter, tmp_path):
|
|
42
|
+
source = _KNOWN_ERROR_SOURCES.get(adapter.name)
|
|
43
|
+
if source is None:
|
|
44
|
+
pytest.skip(f"belum ada contoh error otomatis untuk adapter '{adapter.name}' di tests/test_contract.py")
|
|
45
|
+
|
|
46
|
+
script = tmp_path / f"contoh_error{adapter.file_extensions[0]}"
|
|
47
|
+
script.write_text(source)
|
|
48
|
+
|
|
49
|
+
raw_output = adapter.capture([str(script)])
|
|
50
|
+
assert raw_output.strip(), "capture() harus menghasilkan output saat program error"
|
|
51
|
+
|
|
52
|
+
structured = adapter.parse(raw_output)
|
|
53
|
+
|
|
54
|
+
assert isinstance(structured, StructuredError)
|
|
55
|
+
assert structured.language == adapter.name
|
|
56
|
+
assert structured.error_type
|
|
57
|
+
assert isinstance(structured.category, ErrorCategory)
|
|
58
|
+
assert structured.raw_output == raw_output
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""traceback_id — penjelasan error/traceback pemrograman dalam Bahasa
|
|
2
|
+
Indonesia, dimulai dari Python (lihat PRD.md).
|
|
3
|
+
|
|
4
|
+
Mode in-process (khusus Python, DX terbaik untuk kasus ini)::
|
|
5
|
+
|
|
6
|
+
import traceback_id
|
|
7
|
+
traceback_id.activate()
|
|
8
|
+
|
|
9
|
+
Mode CLI (universal, dipakai bahasa apa pun yang punya adapter)::
|
|
10
|
+
|
|
11
|
+
traceback_id run script.py
|
|
12
|
+
traceback_id run script.js
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from traceback_id.hook import activate, deactivate, is_active
|
|
17
|
+
|
|
18
|
+
__all__ = ["activate", "deactivate", "is_active", "__version__"]
|
|
19
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Paket adapter bahasa. Lihat adapters/base.py untuk kontraknya."""
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Kontrak adapter bahasa (ARCHITECTURE.md §4).
|
|
2
|
+
|
|
3
|
+
Setiap adapter — built-in maupun plugin komunitas yang didaftarkan lewat
|
|
4
|
+
entry_points `traceback_id.adapters` — wajib mengimplementasikan interface
|
|
5
|
+
ini. `core/` hanya bergantung pada `LanguageAdapter` + `StructuredError`,
|
|
6
|
+
tidak pernah mengimpor adapter bahasa tertentu secara langsung.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from abc import ABC, abstractmethod
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from traceback_id.core.models import StructuredError
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class LanguageAdapter(ABC):
|
|
17
|
+
"""Interface yang wajib dipenuhi setiap adapter bahasa."""
|
|
18
|
+
|
|
19
|
+
name: str
|
|
20
|
+
file_extensions: list[str]
|
|
21
|
+
|
|
22
|
+
@abstractmethod
|
|
23
|
+
def capture(self, command: list[str]) -> str:
|
|
24
|
+
"""Jalankan command, kembalikan raw stderr/output sebagai teks."""
|
|
25
|
+
raise NotImplementedError
|
|
26
|
+
|
|
27
|
+
@abstractmethod
|
|
28
|
+
def parse(self, raw_output: str) -> StructuredError:
|
|
29
|
+
"""Ubah teks error mentah jadi StructuredError."""
|
|
30
|
+
raise NotImplementedError
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
@abstractmethod
|
|
34
|
+
def rules_path(self) -> Path:
|
|
35
|
+
"""Lokasi file rule khusus bahasa ini."""
|
|
36
|
+
raise NotImplementedError
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Adapter Python. Lihat adapter.py untuk implementasi, rules.yaml untuk rule."""
|