markdownizer 0.4.2__tar.gz → 0.4.4__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.
Files changed (45) hide show
  1. {markdownizer-0.4.2 → markdownizer-0.4.4}/PKG-INFO +131 -1
  2. markdownizer-0.4.4/README.md +333 -0
  3. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/__init__.py +1 -1
  4. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer.egg-info/PKG-INFO +131 -1
  5. markdownizer-0.4.2/README.md +0 -203
  6. {markdownizer-0.4.2 → markdownizer-0.4.4}/LICENSE +0 -0
  7. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/__main__.py +0 -0
  8. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/backends/__init__.py +0 -0
  9. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/backends/base.py +0 -0
  10. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/backends/compact.py +0 -0
  11. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/backends/json.py +0 -0
  12. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/backends/markdown.py +0 -0
  13. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/classifier.py +0 -0
  14. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/cli.py +0 -0
  15. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/extractor.py +0 -0
  16. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/imports.py +0 -0
  17. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/ir.py +0 -0
  18. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/optimizer/__init__.py +0 -0
  19. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/optimizer/profiles.py +0 -0
  20. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/optimizer/rank.py +0 -0
  21. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/optimizer/slice.py +0 -0
  22. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/optimizer/tokens.py +0 -0
  23. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/parser.py +0 -0
  24. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/py.typed +0 -0
  25. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/renderer.py +0 -0
  26. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer/scanner.py +0 -0
  27. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer.egg-info/SOURCES.txt +0 -0
  28. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer.egg-info/dependency_links.txt +0 -0
  29. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer.egg-info/entry_points.txt +0 -0
  30. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer.egg-info/requires.txt +0 -0
  31. {markdownizer-0.4.2 → markdownizer-0.4.4}/markdownizer.egg-info/top_level.txt +0 -0
  32. {markdownizer-0.4.2 → markdownizer-0.4.4}/pyproject.toml +0 -0
  33. {markdownizer-0.4.2 → markdownizer-0.4.4}/setup.cfg +0 -0
  34. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_backends.py +0 -0
  35. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_classifier.py +0 -0
  36. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_cli.py +0 -0
  37. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_extractor.py +0 -0
  38. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_imports.py +0 -0
  39. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_ir.py +0 -0
  40. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_optimizer.py +0 -0
  41. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_packaging.py +0 -0
  42. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_parser.py +0 -0
  43. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_ranking.py +0 -0
  44. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_renderer.py +0 -0
  45. {markdownizer-0.4.2 → markdownizer-0.4.4}/tests/test_scanner.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdownizer
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Extract documentation from Python projects into Markdown without rewriting it
5
5
  Author-email: Mohammad Hasan Khoddami <mohammadh.khoddami@gmail.com>
6
6
  License: MIT License
@@ -257,3 +257,133 @@ Changes are recorded in [CHANGELOG.md](CHANGELOG.md).
257
257
  ## License
258
258
 
259
259
  MIT — see [LICENSE](LICENSE).
260
+
261
+ ---
262
+
263
+ # راهنمای فارسی — Markdownizer برای توسعه‌دهندگان ایرانی
264
+
265
+ ## مارک‌داونایزر چیست؟
266
+
267
+ مارک‌داونایزر (Markdownizer) یک ابزار خط‌فرمان پایتونی و کاملاً رایگان و متن‌باز است که کدهای پروژه‌ی شما را تحلیل می‌کند و آن‌ها را به یک **نمای تمیز، ساختارمند و کم‌حجم** از پروژه تبدیل می‌کند؛ خروجی‌ای که هم برای انسان‌ها قابل خواندن است و هم برای مدل‌های هوش مصنوعی (مثل Claude، ChatGPT، Gemini و ابزارهایی مثل Cursor یا Claude Code) آماده‌ی استفاده است.
268
+
269
+ نکته‌ی کلیدی این است که مارک‌داونایزر **هیچ‌چیز جدیدی تولید نمی‌کند**. نه مستندسازی می‌نویسد، نه خلاصه‌سازی می‌کند و نه کدی را تغییر می‌دهد. فقط چیزهایی که از قبل در کد شما هست — داک‌استرینگ‌ها، کامنت‌ها، دکوریتورها و خود کد — را به‌صورت دقیق و بدون کم‌وکاست استخراج می‌کند و مرتب تحویل می‌دهد.
270
+
271
+ > **چرا این مهم است؟** وقتی پروژه‌ای را به یک مدل هوش مصنوعی می‌دهید، هر توکن (کلمه‌ی پردازش‌شده) هزینه دارد و هرچه ورودی شلوغ‌تر باشد، نتیجه ضعیف‌تر می‌شود. مارک‌داونایزر مثل یک «کامپایلر» عمل می‌کند: پروژه‌ی خام را می‌گیرد و بهترین نسخه‌ی ممکن را در محدوده‌ی بودجه‌ی توکنی که شما تعیین می‌کنید تحویل می‌دهد.
272
+
273
+ ## نصب
274
+
275
+ فقط پایتون ۳.۹ یا بالاتر لازم دارید؛ بدون هیچ وابستگی اضافه:
276
+
277
+ ```bash
278
+ pip install markdownizer
279
+ ```
280
+
281
+ یا اگر ترجیح می‌دهید ایزوله نصب کنید:
282
+
283
+ ```bash
284
+ pipx install markdownizer
285
+ ```
286
+
287
+ برای بررسی نصب:
288
+
289
+ ```bash
290
+ markdownizer --version
291
+ ```
292
+
293
+ ## استفاده‌ی سریع
294
+
295
+ ساده‌ترین حالت — اسکن پروژه و تولید یک فایل مارک‌داون برای هر پکیج:
296
+
297
+ ```bash
298
+ markdownizer /path/to/project -o ./docs
299
+ ```
300
+
301
+ بعد از اجرا، داخل پوشه‌ی `docs` برای هر پکیج یک فایل `.md` می‌بینید که شامل داک‌استرینگ‌ها، کامنت‌ها، دکوریتورها و سورس‌کد هر کلاس و تابع است.
302
+
303
+ ### انتخاب فرمت خروجی
304
+
305
+ ```bash
306
+ # مارک‌داون (پیش‌فرض) — مناسب انسان و هوش مصنوعی
307
+ markdownizer build . -o ./docs --format markdown
308
+
309
+ # JSON — نمای کامل و ماشینی پروژه (مناسب ابزارها و سیستم‌ها)
310
+ markdownizer build . -o ./docs --format json
311
+
312
+ # فشرده — ساختار، امضاها و داک‌استرینگ‌ها بدون بدنه‌ی کد
313
+ markdownizer build . -o ./docs --format compact
314
+ ```
315
+
316
+ ### تولید کانتکست با بودجه‌ی توکنی
317
+
318
+ اگر می‌خواهید دقیقاً مشخص کنید چند توکن صرف شود:
319
+
320
+ ```bash
321
+ markdownizer context . --max-tokens 20000 --profile api
322
+ ```
323
+
324
+ این دستور فایل `context.md` می‌سازد؛ بهترین نمای پروژه در محدوده‌ی ۲۰ هزار توکن. برای پروژه‌های جنگویی:
325
+
326
+ ```bash
327
+ markdownizer context . --profile django --query "user model"
328
+ ```
329
+
330
+ پروفایل‌های آماده: `architecture` (پیش‌فرض)، `api`، `debugging`، `refactor`، `django` و `onboarding`.
331
+
332
+ ### آمار پروژه
333
+
334
+ ```bash
335
+ markdownizer stats .
336
+ markdownizer stats . --json
337
+ ```
338
+
339
+ تعداد فایل‌ها، سمبل‌ها، پکیج‌ها و مهم‌ترین فایل‌های پروژه را بر اساس گراف ایمپورت‌ها (PageRank) نشان می‌دهد.
340
+
341
+ ### نمونه‌ی کامل
342
+
343
+ ```bash
344
+ # ۱. نصب
345
+ pip install markdownizer
346
+
347
+ # ۲. ساخت کانتکست فشرده برای هوش مصنوعی
348
+ markdownizer context . --max-tokens 20000 --profile architecture -o ./docs
349
+
350
+ # ۳. استفاده از خروجی — مثلاً ارسال به Claude Code
351
+ cat docs/context.md | claude -p "توضیح بده معماری این پروژه چطور است"
352
+ ```
353
+
354
+ ## نکته‌های کاربردی
355
+
356
+ - اگر پوشه‌ی پروژه‌ی شما `build`، `context` یا `stats` نام دارد، حتماً با `./` صدا بزنید: `markdownizer ./build`.
357
+ - برای رد کردن پوشه‌هایی مثل تست‌ها یا مایگریشن‌ها: `--exclude "tests/*" --exclude "migrations"`
358
+ - خروجی کاملاً قطعی است: با همان کد، همیشه همان خروجی تولید می‌شود؛ یعنی می‌توانید فایل‌های تولیدشده را داخل گیت ذخیره کنید و از تغییرات ناخواسته باخبر شوید.
359
+ - مارک‌داونایزر کد شما را اجرا نمی‌کند و به اینترنت وصل نمی‌شود؛ کاملاً امن و آفلاین است.
360
+
361
+ ## استفاده در کد پایتون
362
+
363
+ ```python
364
+ from pathlib import Path
365
+ from markdownizer import build_project_ir, optimize_context
366
+
367
+ ir = build_project_ir(Path("."))
368
+ print(ir.hash) # هش قطعی پروژه
369
+ print(ir.stats.symbol_count) # تعداد سمبل‌ها
370
+
371
+ ctx = optimize_context(ir, max_tokens=20000, profile="api")
372
+ print(ctx.text)
373
+ ```
374
+
375
+ ## محدودیت‌ها
376
+
377
+ - در حال حاضر فقط پروژه‌های پایتون پشتیبانی می‌شوند (پشتیبانی از زبان‌های دیگر در برنامه‌ی آینده است).
378
+ - گراف ایمپورت فقط ایمپورت‌های سطح ماژول را می‌بیند؛ ایمپورت‌های داخل توابع عمداً در نظر گرفته نمی‌شوند.
379
+ - اگر پرسش‌وجو (جست‌وجوی کلمه‌ای) نیاز دارید، فعلاً یک فیلتر ساده و قطعی است؛ جست‌وجوی معنایی در نسخه‌های بعدی اضافه می‌شود.
380
+
381
+ ## مستندات بیشتر
382
+
383
+ - مستندات کامل فنی پروژه: [docs/PROJECT.md](docs/PROJECT.md)
384
+ - تاریخچه‌ی تغییرات: [CHANGELOG.md](CHANGELOG.md)
385
+ - راهنمای مشارکت: [CONTRIBUTING.md](CONTRIBUTING.md)
386
+
387
+ ---
388
+
389
+ *این راهنما برای توسعه‌دهندگان فارسی‌زبان نوشته شده است. اگر سؤال یا پیشنهادی دارید، از طریق [GitHub Issues](https://github.com/mohammadkhoddami/Markdownizer/issues) در میان بگذارید.*
@@ -0,0 +1,333 @@
1
+ # Markdownizer
2
+
3
+ Extract existing documentation from Python projects into Markdown.
4
+
5
+ ![CI](https://github.com/mohammadkhoddami/Markdownizer/actions/workflows/ci.yml/badge.svg)
6
+ [![PyPI](https://img.shields.io/pypi/v/markdownizer)](https://pypi.org/project/markdownizer/)
7
+ ![Python](https://img.shields.io/pypi/pyversions/markdownizer)
8
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
9
+
10
+ Markdownizer **never** generates, rewrites, summarizes, or improves documentation.
11
+ It only extracts what is already present in your source code: docstrings,
12
+ comments, decorators, and source.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install markdownizer
18
+ ```
19
+
20
+ Or with [pipx](https://pipx.pypa.io/) for an isolated CLI:
21
+
22
+ ```bash
23
+ pipx install markdownizer
24
+ ```
25
+
26
+ Requires Python 3.9+. No runtime dependencies.
27
+
28
+ ## Usage
29
+
30
+ ### CLI
31
+
32
+ ```bash
33
+ markdownizer /path/to/project -o ./docs
34
+ ```
35
+
36
+ This recursively scans the project, parses every Python file with the AST,
37
+ builds a deterministic Project IR, and writes one Markdown file per package
38
+ into `./docs`.
39
+
40
+ The compiler-style form is equivalent and supports format selection:
41
+
42
+ ```bash
43
+ markdownizer build /path/to/project -o ./docs --format markdown
44
+ markdownizer build /path/to/project -o ./docs --format json
45
+ markdownizer build /path/to/project -o ./docs --format compact
46
+ ```
47
+
48
+ ### Budgeted context
49
+
50
+ Produce the best possible representation of a project within a token budget:
51
+
52
+ ```bash
53
+ markdownizer context . --max-tokens 20000 --profile api
54
+ markdownizer context . --profile django --query "user model"
55
+ ```
56
+
57
+ Writes `context.md`. Options: `--max-tokens` (default 20000), `--profile`
58
+ (`architecture` default, `api`, `debugging`, `refactor`, `django`,
59
+ `onboarding`), `--rank` (`pagerank` default, `fanout`, `simple`), and
60
+ `--query` (deterministic keyword prefilter).
61
+
62
+ ### Statistics
63
+
64
+ ```bash
65
+ markdownizer stats . --rank pagerank
66
+ markdownizer stats . --json
67
+ ```
68
+
69
+ Shows project counts, a token estimate, and top-ranked files/symbols.
70
+ Ranking is deterministic: PageRank over the import graph with
71
+ framework-aware boosts (Django models, URL configs, management commands),
72
+ combined with public/documented factors per symbol.
73
+
74
+ Common options:
75
+
76
+ ```bash
77
+ markdownizer . -o ./docs \
78
+ --exclude "tests/*" --exclude "migrations" \
79
+ --only-documented --no-source
80
+ ```
81
+
82
+ | Option | Description |
83
+ | --- | --- |
84
+ | `-o, --output DIR` | Output directory (default: `./docs`) |
85
+ | `--root-name NAME` | Filename for files at the project root (default: `_root`) |
86
+ | `--exclude GLOB` | Skip matching paths; may be repeated |
87
+ | `--format FMT` | Output backend: `markdown`, `json`, or `compact` |
88
+ | `--no-source` | Omit the `## Source Code` section |
89
+ | `--no-comments` | Omit the `## Comments` section |
90
+ | `--only-documented` | Only include objects with a docstring |
91
+ | `-v, --verbose` | Increase logging verbosity |
92
+ | `-q, --quiet` | Suppress non-error output |
93
+ | `--version` | Show the version |
94
+
95
+ Run `markdownizer --help` for the full list.
96
+
97
+ ### Python API
98
+
99
+ ```python
100
+ from pathlib import Path
101
+ from markdownizer import extract_project, build_project_ir, optimize_context
102
+
103
+ written = extract_project(
104
+ Path("."),
105
+ Path("docs"),
106
+ exclude=["tests/*"],
107
+ include_source=False,
108
+ )
109
+ print(written) # list of written output files
110
+
111
+ # Or build the Project IR directly:
112
+ ir = build_project_ir(Path("."), exclude=["tests/*"])
113
+ print(ir.ir_version, ir.hash, ir.stats.symbol_count)
114
+
115
+ # Or generate a budgeted, ranked context artifact:
116
+ ctx = optimize_context(ir, max_tokens=20000, profile="api", query="auth")
117
+ print(ctx.estimated_tokens, ctx.included_symbols)
118
+ print(ctx.text)
119
+ ```
120
+
121
+ ### Output formats
122
+
123
+ The pipeline builds a deterministic **Project IR** (packages → modules →
124
+ symbols, plus import/inherit/define edges) and renders it through a backend:
125
+
126
+ | Format | Command | Output |
127
+ | --- | --- | --- |
128
+ | `markdown` (default) | `markdownizer build . -o ./docs` | One `.md` file per package |
129
+ | `json` | `markdownizer build . -o ./docs --format json` | `project.json` — full IR serialization |
130
+ | `compact` | `markdownizer build . -o ./docs --format compact` | `context.compact.md` — signatures, docstrings, inheritance, decorators (no bodies) |
131
+
132
+ The legacy invocation `markdownizer <project> -o <out>` is kept as a
133
+ compatibility alias for `markdownizer build <project> --format markdown`.
134
+
135
+ ### Signature mode
136
+
137
+ Instead of full source or no source, `extract_project()` accepts
138
+ `include_source="signature"` to emit only declaration lines:
139
+
140
+ ```python
141
+ extract_project(Path("."), Path("docs"), include_source="signature")
142
+ ```
143
+
144
+ Functions render as `def foo(x: int = 1) -> str:`, async functions as
145
+ `async def ...`, classes as `class User(models.Model):` (with base classes),
146
+ and methods with their parameters. Modules render without source. The
147
+ boolean modes (`True`/`False`) are unchanged.
148
+
149
+ ### Project IR
150
+
151
+ `build_project_ir(project_root, exclude=None)` returns a `ProjectIR` with:
152
+
153
+ - `ir_version` — schema version (currently `1`), independent of the package version
154
+ - `packages`, `modules`, `symbols` — the project hierarchy
155
+ - `imports`, `inherits`, `defines` — relationship edges
156
+ - `stats` — file/module/symbol counts
157
+ - `hash` — deterministic `blake2b` of the canonical IR content
158
+
159
+ The hash and JSON serialization are deterministic: the same repository
160
+ content always produces the same hash and the same `project.json`, making
161
+ the output suitable for version control and caching. Machine-specific
162
+ metadata (`root`, `python_version`, `git`) is excluded from the hash.
163
+
164
+ Import resolution is conservative and fully static: project code is never
165
+ imported or executed. Imports that cannot be resolved to a project module
166
+ are marked `external`.
167
+
168
+ ## What is extracted
169
+
170
+ For every documented object (modules, packages, classes, dataclasses, enums,
171
+ functions, async functions, methods, properties, Django models, Django forms,
172
+ Django admin classes, DRF serializers, DRF viewsets, signals, middleware,
173
+ management commands, URL configuration, and any other object with a docstring):
174
+
175
+ - The docstring, verbatim
176
+ - Comments that belong to the object (preceding and inline)
177
+ - Decorators
178
+ - The complete source code
179
+
180
+ ## Output format
181
+
182
+ Each generated Markdown file groups all modules inside a single package and
183
+ uses specialized headers such as:
184
+
185
+ ```
186
+ # Django Model: User
187
+ # DRF Serializer: UserSerializer
188
+ # DRF ViewSet: UserViewSet
189
+ # Enum: Status
190
+ # Dataclass: Point
191
+ # Async Function: fetch_data
192
+ ```
193
+
194
+ Every section preserves the original formatting of the source documentation.
195
+
196
+ ## Development
197
+
198
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, checks, and release steps.
199
+ Changes are recorded in [CHANGELOG.md](CHANGELOG.md).
200
+
201
+ ## License
202
+
203
+ MIT — see [LICENSE](LICENSE).
204
+
205
+ ---
206
+
207
+ # راهنمای فارسی — Markdownizer برای توسعه‌دهندگان ایرانی
208
+
209
+ ## مارک‌داونایزر چیست؟
210
+
211
+ مارک‌داونایزر (Markdownizer) یک ابزار خط‌فرمان پایتونی و کاملاً رایگان و متن‌باز است که کدهای پروژه‌ی شما را تحلیل می‌کند و آن‌ها را به یک **نمای تمیز، ساختارمند و کم‌حجم** از پروژه تبدیل می‌کند؛ خروجی‌ای که هم برای انسان‌ها قابل خواندن است و هم برای مدل‌های هوش مصنوعی (مثل Claude، ChatGPT، Gemini و ابزارهایی مثل Cursor یا Claude Code) آماده‌ی استفاده است.
212
+
213
+ نکته‌ی کلیدی این است که مارک‌داونایزر **هیچ‌چیز جدیدی تولید نمی‌کند**. نه مستندسازی می‌نویسد، نه خلاصه‌سازی می‌کند و نه کدی را تغییر می‌دهد. فقط چیزهایی که از قبل در کد شما هست — داک‌استرینگ‌ها، کامنت‌ها، دکوریتورها و خود کد — را به‌صورت دقیق و بدون کم‌وکاست استخراج می‌کند و مرتب تحویل می‌دهد.
214
+
215
+ > **چرا این مهم است؟** وقتی پروژه‌ای را به یک مدل هوش مصنوعی می‌دهید، هر توکن (کلمه‌ی پردازش‌شده) هزینه دارد و هرچه ورودی شلوغ‌تر باشد، نتیجه ضعیف‌تر می‌شود. مارک‌داونایزر مثل یک «کامپایلر» عمل می‌کند: پروژه‌ی خام را می‌گیرد و بهترین نسخه‌ی ممکن را در محدوده‌ی بودجه‌ی توکنی که شما تعیین می‌کنید تحویل می‌دهد.
216
+
217
+ ## نصب
218
+
219
+ فقط پایتون ۳.۹ یا بالاتر لازم دارید؛ بدون هیچ وابستگی اضافه:
220
+
221
+ ```bash
222
+ pip install markdownizer
223
+ ```
224
+
225
+ یا اگر ترجیح می‌دهید ایزوله نصب کنید:
226
+
227
+ ```bash
228
+ pipx install markdownizer
229
+ ```
230
+
231
+ برای بررسی نصب:
232
+
233
+ ```bash
234
+ markdownizer --version
235
+ ```
236
+
237
+ ## استفاده‌ی سریع
238
+
239
+ ساده‌ترین حالت — اسکن پروژه و تولید یک فایل مارک‌داون برای هر پکیج:
240
+
241
+ ```bash
242
+ markdownizer /path/to/project -o ./docs
243
+ ```
244
+
245
+ بعد از اجرا، داخل پوشه‌ی `docs` برای هر پکیج یک فایل `.md` می‌بینید که شامل داک‌استرینگ‌ها، کامنت‌ها، دکوریتورها و سورس‌کد هر کلاس و تابع است.
246
+
247
+ ### انتخاب فرمت خروجی
248
+
249
+ ```bash
250
+ # مارک‌داون (پیش‌فرض) — مناسب انسان و هوش مصنوعی
251
+ markdownizer build . -o ./docs --format markdown
252
+
253
+ # JSON — نمای کامل و ماشینی پروژه (مناسب ابزارها و سیستم‌ها)
254
+ markdownizer build . -o ./docs --format json
255
+
256
+ # فشرده — ساختار، امضاها و داک‌استرینگ‌ها بدون بدنه‌ی کد
257
+ markdownizer build . -o ./docs --format compact
258
+ ```
259
+
260
+ ### تولید کانتکست با بودجه‌ی توکنی
261
+
262
+ اگر می‌خواهید دقیقاً مشخص کنید چند توکن صرف شود:
263
+
264
+ ```bash
265
+ markdownizer context . --max-tokens 20000 --profile api
266
+ ```
267
+
268
+ این دستور فایل `context.md` می‌سازد؛ بهترین نمای پروژه در محدوده‌ی ۲۰ هزار توکن. برای پروژه‌های جنگویی:
269
+
270
+ ```bash
271
+ markdownizer context . --profile django --query "user model"
272
+ ```
273
+
274
+ پروفایل‌های آماده: `architecture` (پیش‌فرض)، `api`، `debugging`، `refactor`، `django` و `onboarding`.
275
+
276
+ ### آمار پروژه
277
+
278
+ ```bash
279
+ markdownizer stats .
280
+ markdownizer stats . --json
281
+ ```
282
+
283
+ تعداد فایل‌ها، سمبل‌ها، پکیج‌ها و مهم‌ترین فایل‌های پروژه را بر اساس گراف ایمپورت‌ها (PageRank) نشان می‌دهد.
284
+
285
+ ### نمونه‌ی کامل
286
+
287
+ ```bash
288
+ # ۱. نصب
289
+ pip install markdownizer
290
+
291
+ # ۲. ساخت کانتکست فشرده برای هوش مصنوعی
292
+ markdownizer context . --max-tokens 20000 --profile architecture -o ./docs
293
+
294
+ # ۳. استفاده از خروجی — مثلاً ارسال به Claude Code
295
+ cat docs/context.md | claude -p "توضیح بده معماری این پروژه چطور است"
296
+ ```
297
+
298
+ ## نکته‌های کاربردی
299
+
300
+ - اگر پوشه‌ی پروژه‌ی شما `build`، `context` یا `stats` نام دارد، حتماً با `./` صدا بزنید: `markdownizer ./build`.
301
+ - برای رد کردن پوشه‌هایی مثل تست‌ها یا مایگریشن‌ها: `--exclude "tests/*" --exclude "migrations"`
302
+ - خروجی کاملاً قطعی است: با همان کد، همیشه همان خروجی تولید می‌شود؛ یعنی می‌توانید فایل‌های تولیدشده را داخل گیت ذخیره کنید و از تغییرات ناخواسته باخبر شوید.
303
+ - مارک‌داونایزر کد شما را اجرا نمی‌کند و به اینترنت وصل نمی‌شود؛ کاملاً امن و آفلاین است.
304
+
305
+ ## استفاده در کد پایتون
306
+
307
+ ```python
308
+ from pathlib import Path
309
+ from markdownizer import build_project_ir, optimize_context
310
+
311
+ ir = build_project_ir(Path("."))
312
+ print(ir.hash) # هش قطعی پروژه
313
+ print(ir.stats.symbol_count) # تعداد سمبل‌ها
314
+
315
+ ctx = optimize_context(ir, max_tokens=20000, profile="api")
316
+ print(ctx.text)
317
+ ```
318
+
319
+ ## محدودیت‌ها
320
+
321
+ - در حال حاضر فقط پروژه‌های پایتون پشتیبانی می‌شوند (پشتیبانی از زبان‌های دیگر در برنامه‌ی آینده است).
322
+ - گراف ایمپورت فقط ایمپورت‌های سطح ماژول را می‌بیند؛ ایمپورت‌های داخل توابع عمداً در نظر گرفته نمی‌شوند.
323
+ - اگر پرسش‌وجو (جست‌وجوی کلمه‌ای) نیاز دارید، فعلاً یک فیلتر ساده و قطعی است؛ جست‌وجوی معنایی در نسخه‌های بعدی اضافه می‌شود.
324
+
325
+ ## مستندات بیشتر
326
+
327
+ - مستندات کامل فنی پروژه: [docs/PROJECT.md](docs/PROJECT.md)
328
+ - تاریخچه‌ی تغییرات: [CHANGELOG.md](CHANGELOG.md)
329
+ - راهنمای مشارکت: [CONTRIBUTING.md](CONTRIBUTING.md)
330
+
331
+ ---
332
+
333
+ *این راهنما برای توسعه‌دهندگان فارسی‌زبان نوشته شده است. اگر سؤال یا پیشنهادی دارید، از طریق [GitHub Issues](https://github.com/mohammadkhoddami/Markdownizer/issues) در میان بگذارید.*
@@ -8,7 +8,7 @@ from markdownizer.extractor import extract_project
8
8
  from markdownizer.ir import IR_VERSION, ProjectIR, build_project_ir
9
9
  from markdownizer.optimizer import OptimizedContext, optimize_context
10
10
 
11
- __version__ = "0.4.2"
11
+ __version__ = "0.4.4"
12
12
  __all__ = [
13
13
  "extract_project",
14
14
  "build_project_ir",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdownizer
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Extract documentation from Python projects into Markdown without rewriting it
5
5
  Author-email: Mohammad Hasan Khoddami <mohammadh.khoddami@gmail.com>
6
6
  License: MIT License
@@ -257,3 +257,133 @@ Changes are recorded in [CHANGELOG.md](CHANGELOG.md).
257
257
  ## License
258
258
 
259
259
  MIT — see [LICENSE](LICENSE).
260
+
261
+ ---
262
+
263
+ # راهنمای فارسی — Markdownizer برای توسعه‌دهندگان ایرانی
264
+
265
+ ## مارک‌داونایزر چیست؟
266
+
267
+ مارک‌داونایزر (Markdownizer) یک ابزار خط‌فرمان پایتونی و کاملاً رایگان و متن‌باز است که کدهای پروژه‌ی شما را تحلیل می‌کند و آن‌ها را به یک **نمای تمیز، ساختارمند و کم‌حجم** از پروژه تبدیل می‌کند؛ خروجی‌ای که هم برای انسان‌ها قابل خواندن است و هم برای مدل‌های هوش مصنوعی (مثل Claude، ChatGPT، Gemini و ابزارهایی مثل Cursor یا Claude Code) آماده‌ی استفاده است.
268
+
269
+ نکته‌ی کلیدی این است که مارک‌داونایزر **هیچ‌چیز جدیدی تولید نمی‌کند**. نه مستندسازی می‌نویسد، نه خلاصه‌سازی می‌کند و نه کدی را تغییر می‌دهد. فقط چیزهایی که از قبل در کد شما هست — داک‌استرینگ‌ها، کامنت‌ها، دکوریتورها و خود کد — را به‌صورت دقیق و بدون کم‌وکاست استخراج می‌کند و مرتب تحویل می‌دهد.
270
+
271
+ > **چرا این مهم است؟** وقتی پروژه‌ای را به یک مدل هوش مصنوعی می‌دهید، هر توکن (کلمه‌ی پردازش‌شده) هزینه دارد و هرچه ورودی شلوغ‌تر باشد، نتیجه ضعیف‌تر می‌شود. مارک‌داونایزر مثل یک «کامپایلر» عمل می‌کند: پروژه‌ی خام را می‌گیرد و بهترین نسخه‌ی ممکن را در محدوده‌ی بودجه‌ی توکنی که شما تعیین می‌کنید تحویل می‌دهد.
272
+
273
+ ## نصب
274
+
275
+ فقط پایتون ۳.۹ یا بالاتر لازم دارید؛ بدون هیچ وابستگی اضافه:
276
+
277
+ ```bash
278
+ pip install markdownizer
279
+ ```
280
+
281
+ یا اگر ترجیح می‌دهید ایزوله نصب کنید:
282
+
283
+ ```bash
284
+ pipx install markdownizer
285
+ ```
286
+
287
+ برای بررسی نصب:
288
+
289
+ ```bash
290
+ markdownizer --version
291
+ ```
292
+
293
+ ## استفاده‌ی سریع
294
+
295
+ ساده‌ترین حالت — اسکن پروژه و تولید یک فایل مارک‌داون برای هر پکیج:
296
+
297
+ ```bash
298
+ markdownizer /path/to/project -o ./docs
299
+ ```
300
+
301
+ بعد از اجرا، داخل پوشه‌ی `docs` برای هر پکیج یک فایل `.md` می‌بینید که شامل داک‌استرینگ‌ها، کامنت‌ها، دکوریتورها و سورس‌کد هر کلاس و تابع است.
302
+
303
+ ### انتخاب فرمت خروجی
304
+
305
+ ```bash
306
+ # مارک‌داون (پیش‌فرض) — مناسب انسان و هوش مصنوعی
307
+ markdownizer build . -o ./docs --format markdown
308
+
309
+ # JSON — نمای کامل و ماشینی پروژه (مناسب ابزارها و سیستم‌ها)
310
+ markdownizer build . -o ./docs --format json
311
+
312
+ # فشرده — ساختار، امضاها و داک‌استرینگ‌ها بدون بدنه‌ی کد
313
+ markdownizer build . -o ./docs --format compact
314
+ ```
315
+
316
+ ### تولید کانتکست با بودجه‌ی توکنی
317
+
318
+ اگر می‌خواهید دقیقاً مشخص کنید چند توکن صرف شود:
319
+
320
+ ```bash
321
+ markdownizer context . --max-tokens 20000 --profile api
322
+ ```
323
+
324
+ این دستور فایل `context.md` می‌سازد؛ بهترین نمای پروژه در محدوده‌ی ۲۰ هزار توکن. برای پروژه‌های جنگویی:
325
+
326
+ ```bash
327
+ markdownizer context . --profile django --query "user model"
328
+ ```
329
+
330
+ پروفایل‌های آماده: `architecture` (پیش‌فرض)، `api`، `debugging`، `refactor`، `django` و `onboarding`.
331
+
332
+ ### آمار پروژه
333
+
334
+ ```bash
335
+ markdownizer stats .
336
+ markdownizer stats . --json
337
+ ```
338
+
339
+ تعداد فایل‌ها، سمبل‌ها، پکیج‌ها و مهم‌ترین فایل‌های پروژه را بر اساس گراف ایمپورت‌ها (PageRank) نشان می‌دهد.
340
+
341
+ ### نمونه‌ی کامل
342
+
343
+ ```bash
344
+ # ۱. نصب
345
+ pip install markdownizer
346
+
347
+ # ۲. ساخت کانتکست فشرده برای هوش مصنوعی
348
+ markdownizer context . --max-tokens 20000 --profile architecture -o ./docs
349
+
350
+ # ۳. استفاده از خروجی — مثلاً ارسال به Claude Code
351
+ cat docs/context.md | claude -p "توضیح بده معماری این پروژه چطور است"
352
+ ```
353
+
354
+ ## نکته‌های کاربردی
355
+
356
+ - اگر پوشه‌ی پروژه‌ی شما `build`، `context` یا `stats` نام دارد، حتماً با `./` صدا بزنید: `markdownizer ./build`.
357
+ - برای رد کردن پوشه‌هایی مثل تست‌ها یا مایگریشن‌ها: `--exclude "tests/*" --exclude "migrations"`
358
+ - خروجی کاملاً قطعی است: با همان کد، همیشه همان خروجی تولید می‌شود؛ یعنی می‌توانید فایل‌های تولیدشده را داخل گیت ذخیره کنید و از تغییرات ناخواسته باخبر شوید.
359
+ - مارک‌داونایزر کد شما را اجرا نمی‌کند و به اینترنت وصل نمی‌شود؛ کاملاً امن و آفلاین است.
360
+
361
+ ## استفاده در کد پایتون
362
+
363
+ ```python
364
+ from pathlib import Path
365
+ from markdownizer import build_project_ir, optimize_context
366
+
367
+ ir = build_project_ir(Path("."))
368
+ print(ir.hash) # هش قطعی پروژه
369
+ print(ir.stats.symbol_count) # تعداد سمبل‌ها
370
+
371
+ ctx = optimize_context(ir, max_tokens=20000, profile="api")
372
+ print(ctx.text)
373
+ ```
374
+
375
+ ## محدودیت‌ها
376
+
377
+ - در حال حاضر فقط پروژه‌های پایتون پشتیبانی می‌شوند (پشتیبانی از زبان‌های دیگر در برنامه‌ی آینده است).
378
+ - گراف ایمپورت فقط ایمپورت‌های سطح ماژول را می‌بیند؛ ایمپورت‌های داخل توابع عمداً در نظر گرفته نمی‌شوند.
379
+ - اگر پرسش‌وجو (جست‌وجوی کلمه‌ای) نیاز دارید، فعلاً یک فیلتر ساده و قطعی است؛ جست‌وجوی معنایی در نسخه‌های بعدی اضافه می‌شود.
380
+
381
+ ## مستندات بیشتر
382
+
383
+ - مستندات کامل فنی پروژه: [docs/PROJECT.md](docs/PROJECT.md)
384
+ - تاریخچه‌ی تغییرات: [CHANGELOG.md](CHANGELOG.md)
385
+ - راهنمای مشارکت: [CONTRIBUTING.md](CONTRIBUTING.md)
386
+
387
+ ---
388
+
389
+ *این راهنما برای توسعه‌دهندگان فارسی‌زبان نوشته شده است. اگر سؤال یا پیشنهادی دارید، از طریق [GitHub Issues](https://github.com/mohammadkhoddami/Markdownizer/issues) در میان بگذارید.*
@@ -1,203 +0,0 @@
1
- # Markdownizer
2
-
3
- Extract existing documentation from Python projects into Markdown.
4
-
5
- ![CI](https://github.com/mohammadkhoddami/Markdownizer/actions/workflows/ci.yml/badge.svg)
6
- [![PyPI](https://img.shields.io/pypi/v/markdownizer)](https://pypi.org/project/markdownizer/)
7
- ![Python](https://img.shields.io/pypi/pyversions/markdownizer)
8
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
9
-
10
- Markdownizer **never** generates, rewrites, summarizes, or improves documentation.
11
- It only extracts what is already present in your source code: docstrings,
12
- comments, decorators, and source.
13
-
14
- ## Installation
15
-
16
- ```bash
17
- pip install markdownizer
18
- ```
19
-
20
- Or with [pipx](https://pipx.pypa.io/) for an isolated CLI:
21
-
22
- ```bash
23
- pipx install markdownizer
24
- ```
25
-
26
- Requires Python 3.9+. No runtime dependencies.
27
-
28
- ## Usage
29
-
30
- ### CLI
31
-
32
- ```bash
33
- markdownizer /path/to/project -o ./docs
34
- ```
35
-
36
- This recursively scans the project, parses every Python file with the AST,
37
- builds a deterministic Project IR, and writes one Markdown file per package
38
- into `./docs`.
39
-
40
- The compiler-style form is equivalent and supports format selection:
41
-
42
- ```bash
43
- markdownizer build /path/to/project -o ./docs --format markdown
44
- markdownizer build /path/to/project -o ./docs --format json
45
- markdownizer build /path/to/project -o ./docs --format compact
46
- ```
47
-
48
- ### Budgeted context
49
-
50
- Produce the best possible representation of a project within a token budget:
51
-
52
- ```bash
53
- markdownizer context . --max-tokens 20000 --profile api
54
- markdownizer context . --profile django --query "user model"
55
- ```
56
-
57
- Writes `context.md`. Options: `--max-tokens` (default 20000), `--profile`
58
- (`architecture` default, `api`, `debugging`, `refactor`, `django`,
59
- `onboarding`), `--rank` (`pagerank` default, `fanout`, `simple`), and
60
- `--query` (deterministic keyword prefilter).
61
-
62
- ### Statistics
63
-
64
- ```bash
65
- markdownizer stats . --rank pagerank
66
- markdownizer stats . --json
67
- ```
68
-
69
- Shows project counts, a token estimate, and top-ranked files/symbols.
70
- Ranking is deterministic: PageRank over the import graph with
71
- framework-aware boosts (Django models, URL configs, management commands),
72
- combined with public/documented factors per symbol.
73
-
74
- Common options:
75
-
76
- ```bash
77
- markdownizer . -o ./docs \
78
- --exclude "tests/*" --exclude "migrations" \
79
- --only-documented --no-source
80
- ```
81
-
82
- | Option | Description |
83
- | --- | --- |
84
- | `-o, --output DIR` | Output directory (default: `./docs`) |
85
- | `--root-name NAME` | Filename for files at the project root (default: `_root`) |
86
- | `--exclude GLOB` | Skip matching paths; may be repeated |
87
- | `--format FMT` | Output backend: `markdown`, `json`, or `compact` |
88
- | `--no-source` | Omit the `## Source Code` section |
89
- | `--no-comments` | Omit the `## Comments` section |
90
- | `--only-documented` | Only include objects with a docstring |
91
- | `-v, --verbose` | Increase logging verbosity |
92
- | `-q, --quiet` | Suppress non-error output |
93
- | `--version` | Show the version |
94
-
95
- Run `markdownizer --help` for the full list.
96
-
97
- ### Python API
98
-
99
- ```python
100
- from pathlib import Path
101
- from markdownizer import extract_project, build_project_ir, optimize_context
102
-
103
- written = extract_project(
104
- Path("."),
105
- Path("docs"),
106
- exclude=["tests/*"],
107
- include_source=False,
108
- )
109
- print(written) # list of written output files
110
-
111
- # Or build the Project IR directly:
112
- ir = build_project_ir(Path("."), exclude=["tests/*"])
113
- print(ir.ir_version, ir.hash, ir.stats.symbol_count)
114
-
115
- # Or generate a budgeted, ranked context artifact:
116
- ctx = optimize_context(ir, max_tokens=20000, profile="api", query="auth")
117
- print(ctx.estimated_tokens, ctx.included_symbols)
118
- print(ctx.text)
119
- ```
120
-
121
- ### Output formats
122
-
123
- The pipeline builds a deterministic **Project IR** (packages → modules →
124
- symbols, plus import/inherit/define edges) and renders it through a backend:
125
-
126
- | Format | Command | Output |
127
- | --- | --- | --- |
128
- | `markdown` (default) | `markdownizer build . -o ./docs` | One `.md` file per package |
129
- | `json` | `markdownizer build . -o ./docs --format json` | `project.json` — full IR serialization |
130
- | `compact` | `markdownizer build . -o ./docs --format compact` | `context.compact.md` — signatures, docstrings, inheritance, decorators (no bodies) |
131
-
132
- The legacy invocation `markdownizer <project> -o <out>` is kept as a
133
- compatibility alias for `markdownizer build <project> --format markdown`.
134
-
135
- ### Signature mode
136
-
137
- Instead of full source or no source, `extract_project()` accepts
138
- `include_source="signature"` to emit only declaration lines:
139
-
140
- ```python
141
- extract_project(Path("."), Path("docs"), include_source="signature")
142
- ```
143
-
144
- Functions render as `def foo(x: int = 1) -> str:`, async functions as
145
- `async def ...`, classes as `class User(models.Model):` (with base classes),
146
- and methods with their parameters. Modules render without source. The
147
- boolean modes (`True`/`False`) are unchanged.
148
-
149
- ### Project IR
150
-
151
- `build_project_ir(project_root, exclude=None)` returns a `ProjectIR` with:
152
-
153
- - `ir_version` — schema version (currently `1`), independent of the package version
154
- - `packages`, `modules`, `symbols` — the project hierarchy
155
- - `imports`, `inherits`, `defines` — relationship edges
156
- - `stats` — file/module/symbol counts
157
- - `hash` — deterministic `blake2b` of the canonical IR content
158
-
159
- The hash and JSON serialization are deterministic: the same repository
160
- content always produces the same hash and the same `project.json`, making
161
- the output suitable for version control and caching. Machine-specific
162
- metadata (`root`, `python_version`, `git`) is excluded from the hash.
163
-
164
- Import resolution is conservative and fully static: project code is never
165
- imported or executed. Imports that cannot be resolved to a project module
166
- are marked `external`.
167
-
168
- ## What is extracted
169
-
170
- For every documented object (modules, packages, classes, dataclasses, enums,
171
- functions, async functions, methods, properties, Django models, Django forms,
172
- Django admin classes, DRF serializers, DRF viewsets, signals, middleware,
173
- management commands, URL configuration, and any other object with a docstring):
174
-
175
- - The docstring, verbatim
176
- - Comments that belong to the object (preceding and inline)
177
- - Decorators
178
- - The complete source code
179
-
180
- ## Output format
181
-
182
- Each generated Markdown file groups all modules inside a single package and
183
- uses specialized headers such as:
184
-
185
- ```
186
- # Django Model: User
187
- # DRF Serializer: UserSerializer
188
- # DRF ViewSet: UserViewSet
189
- # Enum: Status
190
- # Dataclass: Point
191
- # Async Function: fetch_data
192
- ```
193
-
194
- Every section preserves the original formatting of the source documentation.
195
-
196
- ## Development
197
-
198
- See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, checks, and release steps.
199
- Changes are recorded in [CHANGELOG.md](CHANGELOG.md).
200
-
201
- ## License
202
-
203
- MIT — see [LICENSE](LICENSE).
File without changes
File without changes