doc-code 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,138 @@
1
+ Metadata-Version: 2.4
2
+ Name: doc-code
3
+ Version: 0.1.0
4
+ Summary: Generate and safely apply AI-assisted source documentation.
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://argolo.dev
7
+ Project-URL: Documentation, https://argolo.dev
8
+ Keywords: documentation,docstrings,developer-tools,generative-ai
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Documentation
20
+ Classifier: Topic :: Software Development :: Quality Assurance
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: tree-sitter<0.26,>=0.25
26
+ Requires-Dist: tree-sitter-javascript<0.24,>=0.23
27
+ Requires-Dist: tree-sitter-typescript<0.24,>=0.23
28
+ Requires-Dist: typer<1,>=0.12
29
+ Provides-Extra: dev
30
+ Requires-Dist: build<2,>=1.2; extra == "dev"
31
+ Requires-Dist: mypy<2,>=1.11; extra == "dev"
32
+ Requires-Dist: pip-audit<3,>=2.7; extra == "dev"
33
+ Requires-Dist: pytest<10,>=8; extra == "dev"
34
+ Requires-Dist: pytest-cov<8,>=5; extra == "dev"
35
+ Requires-Dist: ruff<1,>=0.6; extra == "dev"
36
+ Requires-Dist: commitar<2,>=1.0.0; extra == "dev"
37
+ Requires-Dist: setuptools<84,>=83; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # Doc Code
41
+
42
+ [Leia em português](README-PTBR.md)
43
+
44
+ `doc-code` generates documentation for Python, JavaScript, and TypeScript files using OpenAI, Gemini, or Ollama.
45
+
46
+ By default, it displays a reviewable diff of the generated documentation. Use `--no-show-diff` to keep only the compact summary. To write the changes, run:
47
+
48
+ ```shell
49
+ doc-code --output apply
50
+ ```
51
+
52
+ For automation, combine `--yes` with `--output apply`. Each file is written as soon as its generation and validation complete; a later failure does not roll back files that were already applied. Immediately before writing, the file is compared with the preview. If it changed, `doc-code` does not overwrite it. With `confirm = true`, Doc Code shows and confirms each formatted docstring before applying it; with `confirm = false`, it reviews the complete generated file diff before applying it.
53
+
54
+ ## Installation and requirements
55
+
56
+ `doc-code` requires Python 3.11 or later and Git on your `PATH`. To process JavaScript, install Node.js. For TypeScript/TSX, also install the `tsc` compiler (for example, `npm install --global typescript`). These executables validate generated syntax before any file is changed.
57
+
58
+ For development, run `uv sync --locked --all-extras`. To install the published package, run `pip install doc-code`.
59
+
60
+ ## Usage
61
+
62
+ ```shell
63
+ doc-code # Git changes: staged, unstaged, and untracked files
64
+ doc-code src/a.py src/b.ts # one or more specific files or directories
65
+ doc-code --selection repository # every eligible file
66
+ doc-code --coverage all --format numpy
67
+ doc-code --language Portuguese
68
+ doc-code --request-scope symbol
69
+ doc-code --no-show-diff # compact preview without the unified diff
70
+ doc-code --check # fail CI when symbols are undocumented
71
+ doc-code --continue-on-error # return status 0 when a file is skipped
72
+ doc-code config init
73
+ doc-code config show
74
+ ```
75
+
76
+ Configuration uses this precedence: flags, `--config`, `DOC_CODE_*` environment variables, `.doc-code.toml`, user configuration, and defaults. Set `language = "Portuguese"` in `[documentation]`, use `DOC_CODE_LANGUAGE`, or pass `--language Portuguese` to control the generated language. Credentials use `OPENAI_API_KEY` or `GEMINI_API_KEY`; Ollama needs no credential.
77
+
78
+ ## Configuration (`.doc-code.toml`)
79
+
80
+ Create a starter file with `doc-code config init`. The `[ai]`, `[documentation]`, and `[limits]` sections are merged into one configuration. The following are all accepted keys.
81
+
82
+ ### `[ai]`
83
+
84
+ | Option | Values / default | Purpose |
85
+ | --- | --- | --- |
86
+ | `provider` | `openai`, `gemini`, or `ollama` · `ollama` | Selects the provider that generates descriptions. |
87
+ | `model` | string · provider-dependent | Single model used when `models` is empty: `qwen2.5-coder:14b`, `gpt-5.6-sol`, or `gemini-3.6-flash`. |
88
+ | `models` | list of up to 3 strings · `qwen2.5-coder:14b`, `gemma4:e4b` | Candidates rotated across attempts; takes precedence over `model`. An empty list uses only `model`. |
89
+ | `endpoint` | URL or absent · provider default endpoint | Overrides the provider endpoint. Authenticated providers require HTTPS outside loopback. |
90
+ | `max_input_tokens` | positive integer · `12000` | Estimated limit for the prompt sent to the model. |
91
+ | `context_window_tokens` | positive integer · `32768` | Total model context window; must fit input and output. |
92
+ | `max_output_tokens` | positive integer · `800` | Limit for generated response tokens. |
93
+ | `temperature` | number · `0.2` | Controls variation; must be non-negative and is between 0 and 2 for OpenAI and Gemini. |
94
+ | `timeout_seconds` | positive integer · `60` | Maximum duration of each provider call. |
95
+
96
+ `max_input_tokens + max_output_tokens` cannot exceed `context_window_tokens`.
97
+
98
+ ### `[documentation]`
99
+
100
+ | Option | Values / default | Purpose |
101
+ | --- | --- | --- |
102
+ | `selection` | `changes`, `repository` · `changes` | Chooses Git changes or every eligible file. |
103
+ | `coverage` | `missing`, `minimal`, `all` · `missing` | `missing` includes every undocumented symbol; `minimal` includes only undocumented modules and top-level public APIs; `all` generates or replaces documentation for every symbol. |
104
+ | `request_scope` | `file`, `symbol` · `file` | Chooses the context for each call: a complete file or one symbol. It does not change which symbols are eligible. |
105
+ | `language` | non-empty string · `English` | Language requested for generated descriptions. |
106
+ | `python_format` | `google`, `numpy`, `sphinx` · `google` | Parameter-section style for Python docstrings. |
107
+ | `javascript_format` | `jsdoc` · `jsdoc` | Annotation style for JavaScript and TypeScript. |
108
+ | `output` | `preview`, `apply` · `preview` | Shows a preview or writes changes. |
109
+ | `confirm` | boolean · `true` | `true` shows and confirms each formatted docstring before applying it; `false` shows the generated file diff and confirms it before applying it. |
110
+
111
+ ### `[limits]`
112
+
113
+ | Option | Values / default | Purpose |
114
+ | --- | --- | --- |
115
+ | `max_files_per_request` | positive integer · `50` | Maximum number of files in a scope. |
116
+ | `max_file_bytes` | positive integer · `100000` | Maximum size of each processed file. |
117
+ | `exclude` | list of glob patterns | Removes files from scope. Defaults exclude dependencies, build artifacts, minified files, and `package-lock.json`. |
118
+ | `include` | list of glob patterns · empty list | When provided, keeps only files matching at least one pattern. |
119
+
120
+ ## Python docstring style
121
+
122
+ Generated Python docstrings follow PEP 257: summaries end in a period; multiline docstrings have a blank line before and after sections, with closing quotes on their own line. Module and class docstrings are separated from the next declaration by one blank line. Empty lines have no indentation whitespace.
123
+
124
+ Line length also follows the target project. For Python, `doc-code` uses `tool.ruff.line-length` and `tool.ruff.lint.pydocstyle.convention` from the nearest `pyproject.toml` (or 88 and the configured `doc-code` format when absent). Long summaries are separated from the description by a blank line according to D205. For JavaScript and TypeScript, it uses `max-len` from the nearest `eslint.config.js`, `eslint.config.mjs`, or `eslint.config.cjs` (or 100 when no rule exists). Descriptions and JSDoc lines are wrapped while accounting for indentation and delimiters.
125
+
126
+ The `google`, `numpy`, and `sphinx` styles affect only the parameter section. To rewrite existing docstrings using one of these styles, run:
127
+
128
+ ```shell
129
+ doc-code --coverage all --output apply --yes
130
+ ```
131
+
132
+ For functions and methods, `doc-code` asks the model for a distinct description for every parameter and inserts it in the corresponding parameter section. The structured response must include every requested symbol and parameter; incomplete responses are rejected and generated again. Legacy integrations retain a fallback text for compatibility.
133
+
134
+ By default, `request_scope = "file"` sends the file and all symbols that require generation in a single request. Use `request_scope = "symbol"` (or `--request-scope symbol`) to send each symbol in a separate request with only its code scope. This reduces context in large files but can increase latency and the number of calls. For modules, it sends a structural index — opening docstring, imports, constants, and public signatures — without bodies. With `output = "apply"` and `confirm = true`, each formatted docstring is reviewed and confirmed individually; a rejected docstring is reported and skipped while the remaining symbols continue. `--yes` applies without prompts. With `confirm = false`, the full file diff is reviewed before any of its changes are written.
135
+
136
+ Regardless of `request_scope`, `coverage` decides which symbols are eligible and `request_scope` only changes the context unit sent to the model. Use `coverage = "all"` to rewrite existing documentation.
137
+
138
+ Partial failures return status 1 after all remaining eligible files have been processed. Use `--continue-on-error` only when automation explicitly accepts partial results.
@@ -0,0 +1,16 @@
1
+ doc_code/__init__.py,sha256=Le2nLJbYCiQkRHNz_cxOibgIWmVEJIn8kAB614jzJQ8,101
2
+ doc_code/ai.py,sha256=bJWfgSI5jSlPoG3CYBwEKYYFYzD5RPOeE18PjWzC9JE,9026
3
+ doc_code/cli.py,sha256=9ThRu76MrK-GnXvs-5d26pyQB6KzyVNrajQAZjYOIsY,22383
4
+ doc_code/config.py,sha256=1lqkkL1ZtoZ7v683s1eqwjwTpH9zLzde6oATz_fn1Vo,12502
5
+ doc_code/editor.py,sha256=xPMaNlfbssoMIXlXFLAOwY7S0JHfeXBLbJNGf8bB6AY,18060
6
+ doc_code/errors.py,sha256=wx9jcsUQ9ValR4G1anQ1X6mwYoAn2VK2p9h_p30FqTE,603
7
+ doc_code/git.py,sha256=1jvdI4alHj-Ntp5OziWWYsHhiw2HNSiqXWFh9Lex168,3077
8
+ doc_code/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
+ doc_code/scope.py,sha256=JJb0j3SjDl5ryWi-xH-Z9HPxWJSvqZMGXBPzlG8LFEg,4072
10
+ doc_code/symbols.py,sha256=B1hOgN8GqpGud0YZnYPR8Dtk_SIykq3YV6hd76UFWpc,24006
11
+ doc_code-0.1.0.dist-info/licenses/LICENSE,sha256=vmqyc5Yy-tKx7me3iWqd6-xTGx8D69JcCd9WJcqrMu4,1084
12
+ doc_code-0.1.0.dist-info/METADATA,sha256=Sqf1rqaklyPxfpx_mNa-ZRqmU4jrE6ghvL3pydcMXSs,9641
13
+ doc_code-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
14
+ doc_code-0.1.0.dist-info/entry_points.txt,sha256=i7bxfl75gejcqGwialk_vT18XxcPb96N7FYT78Lbi70,47
15
+ doc_code-0.1.0.dist-info/top_level.txt,sha256=zPxoC9HnlFTvtVW7TgflbND8JzCGPHYIF7tFaNbJYcA,9
16
+ doc_code-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ doc-code = doc_code.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 André Argôlo (argolo.dev)
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 @@
1
+ doc_code