autodocgenerator 0.9.0.4__tar.gz → 0.9.2.5__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.
- autodocgenerator-0.9.2.5/PKG-INFO +786 -0
- autodocgenerator-0.9.2.5/README.md +706 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/auto_runner/run_file.py +4 -1
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/config/config.py +2 -1
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/engine/config/config.py +31 -18
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/manage.py +16 -3
- autodocgenerator-0.9.2.5/autodocgenerator/preprocessor/compressor.py +65 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/preprocessor/spliter.py +9 -71
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/pyproject.toml +1 -1
- autodocgenerator-0.9.0.4/PKG-INFO +0 -983
- autodocgenerator-0.9.0.4/README.md +0 -903
- autodocgenerator-0.9.0.4/autodocgenerator/preprocessor/compressor.py +0 -138
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/__init__.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/auto_runner/config_reader.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/engine/__init__.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/engine/exceptions.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/engine/models/gpt_model.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/engine/models/model.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/factory/__init__.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/factory/base_factory.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/factory/modules/general_modules.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/factory/modules/intro.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/postprocessor/custom_intro.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/postprocessor/sorting.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/preprocessor/code_mix.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/preprocessor/settings.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/ui/__init__.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/ui/logging.py +0 -0
- {autodocgenerator-0.9.0.4 → autodocgenerator-0.9.2.5}/autodocgenerator/ui/progress_base.py +0 -0
|
@@ -0,0 +1,786 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autodocgenerator
|
|
3
|
+
Version: 0.9.2.5
|
|
4
|
+
Summary: This Project helps you to create docs for your projects
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: dima-on
|
|
7
|
+
Author-email: sinica911@gmail.com
|
|
8
|
+
Requires-Python: >=3.11,<4.0
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Requires-Dist: CacheControl (==0.14.4)
|
|
16
|
+
Requires-Dist: Pygments (==2.19.2)
|
|
17
|
+
Requires-Dist: RapidFuzz (==3.14.3)
|
|
18
|
+
Requires-Dist: annotated-types (==0.7.0)
|
|
19
|
+
Requires-Dist: anyio (==4.12.1)
|
|
20
|
+
Requires-Dist: certifi (==2026.1.4)
|
|
21
|
+
Requires-Dist: charset-normalizer (==3.4.4)
|
|
22
|
+
Requires-Dist: cleo (==2.1.0)
|
|
23
|
+
Requires-Dist: colorama (==0.4.6)
|
|
24
|
+
Requires-Dist: crashtest (==0.4.1)
|
|
25
|
+
Requires-Dist: distlib (==0.4.0)
|
|
26
|
+
Requires-Dist: distro (==1.9.0)
|
|
27
|
+
Requires-Dist: dulwich (==0.25.2)
|
|
28
|
+
Requires-Dist: fastjsonschema (==2.21.2)
|
|
29
|
+
Requires-Dist: filelock (==3.20.3)
|
|
30
|
+
Requires-Dist: findpython (==0.7.1)
|
|
31
|
+
Requires-Dist: google-auth (==2.47.0)
|
|
32
|
+
Requires-Dist: google-genai (==1.56.0)
|
|
33
|
+
Requires-Dist: groq (==1.0.0)
|
|
34
|
+
Requires-Dist: h11 (==0.16.0)
|
|
35
|
+
Requires-Dist: httpcore (==1.0.9)
|
|
36
|
+
Requires-Dist: httpx (==0.28.1)
|
|
37
|
+
Requires-Dist: idna (==3.11)
|
|
38
|
+
Requires-Dist: installer (==0.7.0)
|
|
39
|
+
Requires-Dist: jaraco.classes (==3.4.0)
|
|
40
|
+
Requires-Dist: jaraco.context (==6.1.0)
|
|
41
|
+
Requires-Dist: jaraco.functools (==4.4.0)
|
|
42
|
+
Requires-Dist: jiter (==0.12.0)
|
|
43
|
+
Requires-Dist: keyring (==25.7.0)
|
|
44
|
+
Requires-Dist: markdown-it-py (==4.0.0)
|
|
45
|
+
Requires-Dist: mdurl (==0.1.2)
|
|
46
|
+
Requires-Dist: more-itertools (==10.8.0)
|
|
47
|
+
Requires-Dist: msgpack (==1.1.2)
|
|
48
|
+
Requires-Dist: openai (==2.14.0)
|
|
49
|
+
Requires-Dist: packaging (==25.0)
|
|
50
|
+
Requires-Dist: pbs-installer (==2026.1.14)
|
|
51
|
+
Requires-Dist: pkginfo (==1.12.1.2)
|
|
52
|
+
Requires-Dist: platformdirs (==4.5.1)
|
|
53
|
+
Requires-Dist: pyasn1 (==0.6.1)
|
|
54
|
+
Requires-Dist: pyasn1_modules (==0.4.2)
|
|
55
|
+
Requires-Dist: pydantic (==2.12.5)
|
|
56
|
+
Requires-Dist: pydantic_core (==2.41.5)
|
|
57
|
+
Requires-Dist: pyproject_hooks (==1.2.0)
|
|
58
|
+
Requires-Dist: python-dotenv (==1.2.1)
|
|
59
|
+
Requires-Dist: pywin32-ctypes (==0.2.3)
|
|
60
|
+
Requires-Dist: pyyaml (==6.0.3)
|
|
61
|
+
Requires-Dist: requests (==2.32.5)
|
|
62
|
+
Requires-Dist: requests-toolbelt (==1.0.0)
|
|
63
|
+
Requires-Dist: rich (==14.2.0)
|
|
64
|
+
Requires-Dist: rich_progress (==0.4.0)
|
|
65
|
+
Requires-Dist: rsa (==4.9.1)
|
|
66
|
+
Requires-Dist: shellingham (==1.5.4)
|
|
67
|
+
Requires-Dist: sniffio (==1.3.1)
|
|
68
|
+
Requires-Dist: tenacity (==9.1.2)
|
|
69
|
+
Requires-Dist: tomlkit (==0.14.0)
|
|
70
|
+
Requires-Dist: tqdm (==4.67.1)
|
|
71
|
+
Requires-Dist: trove-classifiers (==2026.1.14.14)
|
|
72
|
+
Requires-Dist: typing-inspection (==0.4.2)
|
|
73
|
+
Requires-Dist: typing_extensions (==4.15.0)
|
|
74
|
+
Requires-Dist: urllib3 (==2.6.2)
|
|
75
|
+
Requires-Dist: virtualenv (==20.36.1)
|
|
76
|
+
Requires-Dist: websockets (==15.0.1)
|
|
77
|
+
Requires-Dist: zstandard (==0.25.0)
|
|
78
|
+
Description-Content-Type: text/markdown
|
|
79
|
+
|
|
80
|
+
## Executive Navigation Tree
|
|
81
|
+
- 📘 Introduction
|
|
82
|
+
- [Basic Introduction](#basic-introduction)
|
|
83
|
+
- [Intro Text](#intro-text)
|
|
84
|
+
- [Intro Links](#intro-links)
|
|
85
|
+
- [Intro With Links](#intro-with-links)
|
|
86
|
+
- [CONTENT DESCRIPTION](#CONTENT_DESCRIPTION)
|
|
87
|
+
- ⚙️ Setup & Configuration
|
|
88
|
+
- [Install Workflow Setup](#install-workflow-setup)
|
|
89
|
+
- [Autodoc Yml Structure](#autodoc-yml-structure)
|
|
90
|
+
- [Read Config](#read-config)
|
|
91
|
+
- 🛠️ Core Functions
|
|
92
|
+
- [_Print Welcome Function](#_print_welcome-function)
|
|
93
|
+
- [Logger Initialization](#logger-initialization)
|
|
94
|
+
- [Logging Infrastructure](#logging-infrastructure)
|
|
95
|
+
- [Base Progress](#base-progress)
|
|
96
|
+
- [Lib Progress](#lib-progress)
|
|
97
|
+
- [Console Github Progress](#console-github-progress)
|
|
98
|
+
- 📦 Manager
|
|
99
|
+
- [Manager Class](#manager-class)
|
|
100
|
+
- [Manager Class Usage](#manager-class-usage)
|
|
101
|
+
- 🧩 Modules
|
|
102
|
+
- [Base Module Abstract](#base-module-abstract)
|
|
103
|
+
- [Custom Module](#custom-module)
|
|
104
|
+
- [Custom Module Without Context](#custom-module-without-context)
|
|
105
|
+
- [Docfactory Orchestrator](#docfactory-orchestrator)
|
|
106
|
+
- 🤖 Models
|
|
107
|
+
- [Parent Model](#parent-model)
|
|
108
|
+
- [Gpt Model](#gpt-model)
|
|
109
|
+
- [Async Gpt Model](#async-gpt-model)
|
|
110
|
+
- [Semantic Ordering Llm](#semantic-ordering-llm)
|
|
111
|
+
- 📡 Extraction & Processing
|
|
112
|
+
- [Html Link Extraction](#html-link-extraction)
|
|
113
|
+
- [Anchor Extraction Chunk Splitting](#anchor-extraction-chunk-splitting)
|
|
114
|
+
- [Regex Pattern](#["\\\']?(.*?)["\\\']?)
|
|
115
|
+
- 📝 Documentation Generation
|
|
116
|
+
- [Gen Doc](#gen-doc)
|
|
117
|
+
- [Gen Doc Parts](#gen-doc-parts)
|
|
118
|
+
- [Write Docs By Parts](#write-docs-by-parts)
|
|
119
|
+
- [Custom Description Template](#custom-description-template)
|
|
120
|
+
- [Custom Description Iterative](#custom-description-iterative)
|
|
121
|
+
- 📚 Repository & Mixing
|
|
122
|
+
- [Repository Mixer](#repository-mixer)
|
|
123
|
+
- 📦 Compression
|
|
124
|
+
- [Compressor Core Function](#compressor-core-function)
|
|
125
|
+
- [Batch Compression Compare](#batch-compression-compare)
|
|
126
|
+
- [Iterative Full Compression](#iterative-full-compression)
|
|
127
|
+
- 🔄 Data Loop
|
|
128
|
+
- [Split Data Loop](#split-data-loop)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
<a name="basic-introduction"></a>
|
|
133
|
+
## Basic Introduction Generation (`get_introdaction`)
|
|
134
|
+
|
|
135
|
+
| Entity | Type | Role | Notes |
|
|
136
|
+
|--------|------|------|-------|
|
|
137
|
+
| `global_data` | `str` | Input | Full documentation content. |
|
|
138
|
+
| `model` | `Model` | Input | LLM interface. |
|
|
139
|
+
| `language` | `str` | Input (default `"en"`) | Language hint. |
|
|
140
|
+
| `intro` | `str` | Output | Generated introduction. |
|
|
141
|
+
|
|
142
|
+
Builds a prompt with `BASE_INTRO_CREATE` and `global_data`, then returns the LLM answer.
|
|
143
|
+
<a name="intro-text"></a>
|
|
144
|
+
## `IntroText` – Global Data Intro Builder
|
|
145
|
+
**Responsibility** – Generates a textual introduction from `global_data`.
|
|
146
|
+
**Visible Interactions** – Calls `get_introdaction`.
|
|
147
|
+
**Logic Flow** –
|
|
148
|
+
1. `generate(info, model)` →
|
|
149
|
+
- `intro = get_introdaction(info.get("global_data"), model, info.get("language"))`.
|
|
150
|
+
- Return `intro`.
|
|
151
|
+
|
|
152
|
+
> **Warning:** All modules assume the presence of specific keys (`code_mix`, `full_data`, `global_data`, `language`). Absence results in `None` being passed to downstream functions, which may raise runtime errors if those functions lack internal checks.
|
|
153
|
+
<a name="intro-links"></a>
|
|
154
|
+
## `IntroLinks` – HTML Link Intro Builder
|
|
155
|
+
**Responsibility** – Extracts HTML links from `full_data` and builds an introductory paragraph.
|
|
156
|
+
**Visible Interactions** – Calls `get_all_html_links`, `get_links_intro`.
|
|
157
|
+
**Logic Flow** –
|
|
158
|
+
1. `generate(info, model)` →
|
|
159
|
+
- `links = get_all_html_links(info.get("full_data"))`.
|
|
160
|
+
- `intro_links = get_links_intro(links, model, info.get("language"))`.
|
|
161
|
+
- Return `intro_links`.
|
|
162
|
+
<a name="intro-with-links"></a>
|
|
163
|
+
## Introduction Generation with Links (`get_links_intro`)
|
|
164
|
+
|
|
165
|
+
| Entity | Type | Role | Notes |
|
|
166
|
+
|--------|------|------|-------|
|
|
167
|
+
| `links` | `list[str]` | Input | Anchor list from `get_all_html_links`. |
|
|
168
|
+
| `model` | `Model` | Input | Provides `get_answer_without_history`. |
|
|
169
|
+
| `language` | `str` | Input (default `"en"`) | Language hint for the LLM. |
|
|
170
|
+
| `intro_links` | `str` | Output | Generated introductory text. |
|
|
171
|
+
| `logger` | `BaseLogger` | Side‑effect | Logs start, completion, and result. |
|
|
172
|
+
|
|
173
|
+
Creates a prompt containing the language directive, `BASE_INTRODACTION_CREATE_LINKS`, and the stringified `links`. Calls `model.get_answer_without_history` and returns the LLM’s response.
|
|
174
|
+
<a name="CONTENT_DESCRIPTION"></a>` tag with strict naming constraints, then returns the LLM’s response.
|
|
175
|
+
|
|
176
|
+
> **Warning** – All functions assume the provided `Model` instance implements `get_answer_without_history`. Missing methods will raise `AttributeError`. The logger must be operational; otherwise logging calls will fail.
|
|
177
|
+
<a name="install-workflow-setup"></a>
|
|
178
|
+
|
|
179
|
+
**PowerShell installation (Windows)**
|
|
180
|
+
Execute the following command in an elevated PowerShell window to fetch and execute the installation script directly from the repository:
|
|
181
|
+
|
|
182
|
+
```powershell
|
|
183
|
+
irm raw.githubusercontent.com/Drag-GameStudio/ADG/main/install | iex
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
- `irm` (Invoke‑WebRequest) downloads the script content.
|
|
187
|
+
- The pipeline to `iex` (Invoke‑Expression) runs the script in the current session.
|
|
188
|
+
|
|
189
|
+
**Shell installation (Linux/macOS)**
|
|
190
|
+
Run this one‑liner in a terminal to retrieve and execute the Linux installer:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
curl -sSL raw.githubusercontent.com/Drag-GameStudio/ADG/main/install | bash
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
- `curl -sSL` silently follows redirects and outputs the script.
|
|
197
|
+
- The output is piped to `bash` for immediate execution.
|
|
198
|
+
|
|
199
|
+
**GitHub Actions secret configuration**
|
|
200
|
+
To enable the workflow to interact with the Grock service, add a secret named `GROCK_API_KEY` to the repository’s GitHub Actions secrets:
|
|
201
|
+
|
|
202
|
+
1. Navigate to the repository’s **Settings → Secrets and variables → Actions**.
|
|
203
|
+
2. Click **New repository secret**.
|
|
204
|
+
3. Enter **Name**: `GROCK_API_KEY`.
|
|
205
|
+
4. Paste the API key obtained from the Grock documentation.
|
|
206
|
+
5. Save the secret.
|
|
207
|
+
|
|
208
|
+
The workflow will automatically read `GROCK_API_KEY` from the environment, allowing authenticated calls to the Grock API during execution.
|
|
209
|
+
<a name="autodoc-yml-structure"></a>
|
|
210
|
+
The configuration file is a YAML document that defines several top‑level sections:
|
|
211
|
+
|
|
212
|
+
**Project metadata**
|
|
213
|
+
- `project_name`: a string that specifies the name of the project.
|
|
214
|
+
- `language`: the language code (e.g., `"en"`).
|
|
215
|
+
|
|
216
|
+
**Files to ignore**
|
|
217
|
+
- `ignore_files`: a list of directory or file names that should be excluded from documentation generation (e.g., `"dist"`).
|
|
218
|
+
|
|
219
|
+
**Build settings** (`build_settings` block)
|
|
220
|
+
- `save_logs`: boolean, when `true` the generation process stores logs.
|
|
221
|
+
- `log_level`: integer controlling verbosity (e.g., `2`).
|
|
222
|
+
|
|
223
|
+
**Structure settings** (`structure_settings` block)
|
|
224
|
+
- `include_intro_links`: boolean, adds introductory links if `true`.
|
|
225
|
+
- `include_order`: boolean, keeps the original order of sections when `true`.
|
|
226
|
+
- `max_doc_part_size`: integer, maximum size (in characters) for each documentation part.
|
|
227
|
+
|
|
228
|
+
**Additional project information** (`project_additional_info` block)
|
|
229
|
+
- Custom key/value pairs, such as `global idea`, provide free‑form description of the project’s purpose.
|
|
230
|
+
|
|
231
|
+
**Custom descriptions** (`custom_descriptions` block)
|
|
232
|
+
- A list of strings that can contain special instructions or explanatory text. These strings are processed by the generator to enrich the final documentation (e.g., how to install the workflow, how to write the configuration file, how to use the Manager class).
|
|
233
|
+
|
|
234
|
+
When creating the file, follow standard YAML syntax: use indentation (two spaces) for nested sections, place lists under a dash (`-`), and ensure string values are quoted if they contain special characters. This structure enables the documentation generator to read all required options and produce the desired output.
|
|
235
|
+
<a name="read-config"></a>
|
|
236
|
+
## `read_config` – YAML Configuration Parsing
|
|
237
|
+
|
|
238
|
+
| Entity | Type | Role | Notes |
|
|
239
|
+
|--------|------|------|-------|
|
|
240
|
+
| `file_data` | `str` | Raw YAML content | Passed by caller |
|
|
241
|
+
| `data` | `dict` | Parsed YAML tree | Result of `yaml.safe_load` |
|
|
242
|
+
| `config` | `Config` | Central project configuration | Instantiated locally |
|
|
243
|
+
| `ignore_files` | `list[str]` | Files/patterns to skip | Defaults from YAML or empty |
|
|
244
|
+
| `language` | `str` | Documentation language | Defaults to `"en"` |
|
|
245
|
+
| `project_name` | `str` | Identifier for the project | May be `None` |
|
|
246
|
+
| `project_additional_info` | `dict` | Arbitrary key‑value pairs | Empty dict if omitted |
|
|
247
|
+
| `pcs` | `ProjectBuildConfig` | Build‑time settings container | Populated via `load_settings` |
|
|
248
|
+
| `custom_modules` | `list[CustomModule|CustomModuleWithOutContext]` | User‑defined processing hooks | Constructed from `custom_descriptions` |
|
|
249
|
+
| `structure_settings_object` | `StructureSettings` | Runtime doc‑structure flags | Loaded from `structure_settings` |
|
|
250
|
+
|
|
251
|
+
**Logic Flow**
|
|
252
|
+
1. Parse `file_data` with `yaml.safe_load`.
|
|
253
|
+
2. Instantiate a fresh `Config`.
|
|
254
|
+
3. Extract top‑level keys (`ignore_files`, `language`, `project_name`, `project_additional_info`, `build_settings`).
|
|
255
|
+
4. Load build settings into a `ProjectBuildConfig` and attach to `config` via `set_pcs`.
|
|
256
|
+
5. Populate ignore patterns and additional info on `config`.
|
|
257
|
+
6. Build `custom_modules` list, choosing `CustomModuleWithOutContext` when a description starts with `"%"`.
|
|
258
|
+
7. Initialise `StructureSettings`, apply any overrides from YAML.
|
|
259
|
+
8. Return tuple `(config, custom_modules, structure_settings_object)`.
|
|
260
|
+
|
|
261
|
+
> **Assumption** – All expected YAML sections exist; missing sections yield defaults as coded.
|
|
262
|
+
<a name="_print_welcome-function"></a>
|
|
263
|
+
## `_print_welcome` Function Execution
|
|
264
|
+
|
|
265
|
+
| Entity | Type | Role | Notes |
|
|
266
|
+
|--------|------|------|-------|
|
|
267
|
+
| `BLUE`, `BOLD`, `CYAN`, `RESET` | `str` | ANSI colour codes | Used only within this function |
|
|
268
|
+
| `ascii_logo` | `str` | Formatted ASCII art | Combines colour codes for visual header |
|
|
269
|
+
| `print` (built‑in) | callable | Output side‑effect | Sends logo and status lines to **stdout** |
|
|
270
|
+
|
|
271
|
+
**Purpose** – Render a coloured ASCII banner and a one‑line status message when the package is imported.
|
|
272
|
+
|
|
273
|
+
**Logic Flow**
|
|
274
|
+
1. Define colour constants (`BLUE`, `BOLD`, `CYAN`, `RESET`).
|
|
275
|
+
2. Build `ascii_logo` using an f‑string that inserts the colour constants.
|
|
276
|
+
3. Print the logo, then a line showing *“ADG Library | Status: Ready to work”* with cyan text.
|
|
277
|
+
4. Print a separator line (`'—' * 35`).
|
|
278
|
+
|
|
279
|
+
> **Warning** – This function executes at import time, causing I/O side‑effects even if the consumer only needs the library’s API.
|
|
280
|
+
<a name="logger-initialization"></a>
|
|
281
|
+
## Logger Initialization
|
|
282
|
+
|
|
283
|
+
| Entity | Type | Role | Notes |
|
|
284
|
+
|--------|------|------|-------|
|
|
285
|
+
| `BaseLogger` | class | Core logger object | Instantiated as `logger` |
|
|
286
|
+
| `BaseLoggerTemplate` | class | Formatting/template provider | Passed to `logger.set_logger` |
|
|
287
|
+
| `InfoLog`, `ErrorLog`, `WarningLog` | classes | Log‑level helpers (imported but not used here) | Exported for downstream modules |
|
|
288
|
+
|
|
289
|
+
**Purpose** – Prepare a singleton‑style logger ready for use throughout the package.
|
|
290
|
+
|
|
291
|
+
**Logic Flow**
|
|
292
|
+
1. Import logger classes from `.ui.logging`.
|
|
293
|
+
2. Create `logger = BaseLogger()`.
|
|
294
|
+
3. Apply a default template via `logger.set_logger(BaseLoggerTemplate())`.
|
|
295
|
+
|
|
296
|
+
**Interactions** – Subsequent modules import `logger` from this package; they rely on the pre‑configured template for consistent output formatting. No external configuration files are consulted in this fragment.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
*All information is derived exclusively from the provided `autodocgenerator/__init__.py` source.*
|
|
301
|
+
<a name="logging-infrastructure"></a>
|
|
302
|
+
## Logging Infrastructure – `BaseLog` Hierarchy & Singleton `BaseLogger`
|
|
303
|
+
|
|
304
|
+
| Entity | Type | Role | Notes |
|
|
305
|
+
|--------|------|------|-------|
|
|
306
|
+
| `BaseLog` | class | Abstract | Stores `message` and `level`; provides `_log_prefix`. |
|
|
307
|
+
| `ErrorLog`, `WarningLog`, `InfoLog` | subclasses | Concrete | Override `format()` with severity tag. |
|
|
308
|
+
| `BaseLoggerTemplate` | class | Abstract logger | Holds `log_level`; routes via `global_log`. |
|
|
309
|
+
| `FileLoggerTemplate` | subclass | File‑output logger | Writes formatted logs to a file. |
|
|
310
|
+
| `BaseLogger` | singleton class | Proxy | Delegates `log()` to assigned `logger_template`. |
|
|
311
|
+
|
|
312
|
+
**Logic Flow**
|
|
313
|
+
1. `BaseLogger.__new__` ensures a single instance.
|
|
314
|
+
2. `set_logger()` injects a concrete `BaseLoggerTemplate`.
|
|
315
|
+
3. `log()` forwards the `BaseLog` object to `logger_template.global_log`, which respects `log_level`.
|
|
316
|
+
|
|
317
|
+
> **Assumption** – A logger template is set before any `BaseLogger.log` call; otherwise an `AttributeError` would occur.
|
|
318
|
+
<a name="base-progress"></a>
|
|
319
|
+
## `BaseProgress` – Abstract Progress Interface
|
|
320
|
+
|
|
321
|
+
| Entity | Type | Role | Notes |
|
|
322
|
+
|--------|------|------|-------|
|
|
323
|
+
| `BaseProgress` | class | Abstract base | Defines the progress API used by the documentation generator. |
|
|
324
|
+
| `create_new_subtask` | `method(name: str, total_len: int) → None` | Abstract | Intended to start a child progress track. |
|
|
325
|
+
| `update_task` | `method() → None` | Abstract | Advances either the current sub‑task or the base task. |
|
|
326
|
+
| `remove_subtask` | `method() → None` | Abstract | Clears the active sub‑task reference. |
|
|
327
|
+
|
|
328
|
+
**Component Responsibility**
|
|
329
|
+
Provides a minimal contract that concrete progress reporters must implement, allowing the generator to switch between rich‑terminal, console, or other visual back‑ends without code changes.
|
|
330
|
+
|
|
331
|
+
**Visible Interactions**
|
|
332
|
+
`LibProgress` and `ConsoleGtiHubProgress` inherit from it and are passed to higher‑level functions (e.g., `gen_doc_parts`) as the `progress_bar` argument.
|
|
333
|
+
|
|
334
|
+
**Technical Logic Flow**
|
|
335
|
+
1. Instantiation does nothing (`__init__` is empty).
|
|
336
|
+
2. Sub‑classes override the three abstract methods to manipulate their own state.
|
|
337
|
+
|
|
338
|
+
**Data Contract**
|
|
339
|
+
|
|
340
|
+
| Entity | Type | Role | Notes |
|
|
341
|
+
|--------|------|------|-------|
|
|
342
|
+
| `name` | `str` | Input to `create_new_subtask` | Human‑readable identifier of the sub‑task. |
|
|
343
|
+
| `total_len` | `int` | Input to `create_new_subtask` | Expected number of `update_task` calls. |
|
|
344
|
+
| `current progress` | internal | Side‑effect | Updated via `update_task`; no external return. |
|
|
345
|
+
|
|
346
|
+
> **Assumption** – The base class is never used directly; calling its methods without a concrete implementation would raise `NotImplementedError`.
|
|
347
|
+
<a name="lib-progress"></a>
|
|
348
|
+
## `LibProgress` – Rich‑Library Progress Implementation
|
|
349
|
+
|
|
350
|
+
| Entity | Type | Role | Notes |
|
|
351
|
+
|--------|------|------|-------|
|
|
352
|
+
| `LibProgress` | class | Concrete `BaseProgress` | Wraps `rich.progress.Progress`. |
|
|
353
|
+
| `progress` | `Progress` | Dependency | Provided by the `rich` library. |
|
|
354
|
+
| `_base_task` | `int` | Internal | ID of the top‑level “General progress” task. |
|
|
355
|
+
| `_cur_sub_task` | `int | None` | Internal | ID of the active sub‑task, if any. |
|
|
356
|
+
|
|
357
|
+
**Component Responsibility**
|
|
358
|
+
Renders hierarchical progress bars in terminals that support ANSI graphics, tracking overall and per‑chunk documentation generation.
|
|
359
|
+
|
|
360
|
+
**Visible Interactions**
|
|
361
|
+
- `create_new_subtask(name, total_len)` registers a new rich task and stores its ID.
|
|
362
|
+
- `update_task()` advances either `_cur_sub_task` or `_base_task`.
|
|
363
|
+
- `remove_subtask()` discards the current sub‑task reference, leaving the base task alive.
|
|
364
|
+
|
|
365
|
+
**Technical Logic Flow**
|
|
366
|
+
1. Constructor receives a `Progress` instance and creates the base task (`total` defaults to 4).
|
|
367
|
+
2. `create_new_subtask` calls `self.progress.add_task(name, total=total_len)` and caches the ID.
|
|
368
|
+
3. `update_task` checks `_cur_sub_task`; if set, updates it, otherwise updates the base task.
|
|
369
|
+
4. `remove_subtask` simply null‑ifies `_cur_sub_task`.
|
|
370
|
+
|
|
371
|
+
**Data Contract** – same as abstract plus the internal task IDs.
|
|
372
|
+
<a name="console-github-progress"></a>
|
|
373
|
+
## `ConsoleGtiHubProgress` – Simple Console Fallback
|
|
374
|
+
|
|
375
|
+
| Entity | Type | Role | Notes |
|
|
376
|
+
|--------|------|------|-------|
|
|
377
|
+
| `ConsoleGtiHubProgress` | class | Concrete `BaseProgress` | Prints textual progress to stdout. |
|
|
378
|
+
| `gen_task` | `ConsoleTask` | Internal | Represents the overall “General Progress”. |
|
|
379
|
+
| `curr_task` | `ConsoleTask | None` | Internal | Active per‑chunk task. |
|
|
380
|
+
|
|
381
|
+
**Component Responsibility**
|
|
382
|
+
Provides a lightweight, environment‑agnostic progress indicator when the rich library cannot be used (e.g., CI logs).
|
|
383
|
+
|
|
384
|
+
**Visible Interactions**
|
|
385
|
+
- Mirrors the abstract API: `create_new_subtask`, `update_task`, `remove_subtask`.
|
|
386
|
+
- Delegates actual printing to `ConsoleTask.progress()`.
|
|
387
|
+
|
|
388
|
+
**Technical Logic Flow**
|
|
389
|
+
1. Instantiation creates a `ConsoleTask` named “General Progress” with 4 steps.
|
|
390
|
+
2. `create_new_subtask` replaces `curr_task` with a new `ConsoleTask`.
|
|
391
|
+
3. `update_task` calls `curr_task.progress()` if a sub‑task exists; otherwise updates `gen_task`.
|
|
392
|
+
4. `remove_subtask` clears `curr_task`, causing subsequent updates to affect the general task again.
|
|
393
|
+
|
|
394
|
+
**Data Contract** – identical to the abstract contract; progress is emitted via `print`.
|
|
395
|
+
|
|
396
|
+
> **Warning** – This implementation does not persist state beyond the current process; restarting the script will reset all counters.
|
|
397
|
+
<a name="manager-class"></a>
|
|
398
|
+
## `Manager` – Orchestrator for Documentation Pipeline
|
|
399
|
+
|
|
400
|
+
**Responsibility** – Coordinates preprocessing, LLM‑driven generation, post‑processing and caching for a single project directory.
|
|
401
|
+
|
|
402
|
+
**Visible Interactions** –
|
|
403
|
+
- Imports from **preprocessor**, **postprocessor**, **engine.models**, **ui**, **factory**.
|
|
404
|
+
- Uses `BaseProgress`/`LibProgress` for task updates, `BaseLogger` for log emission, `DocFactory` for modular doc assembly.
|
|
405
|
+
|
|
406
|
+
**Logic Flow** –
|
|
407
|
+
1. `__init__` stores paths, config, models, logger and ensures a cache folder exists.
|
|
408
|
+
2. `read_file_by_file_key` → open cached file → return its contents.
|
|
409
|
+
3. `get_file_path` → compose absolute path under `CACHE_FOLDER_NAME`.
|
|
410
|
+
4. `generate_code_file` → instantiate `CodeMix`, build repository content into `code_mix.txt`, log start/finish, update progress.
|
|
411
|
+
5. `generate_global_info` → read `code_mix.txt`, split via `split_data`, compress with `compress_to_one`, write `global_info.md`, update progress.
|
|
412
|
+
6. `generete_doc_parts` → optionally read `global_info.md`, call `gen_doc_parts` with sync model & settings, write `output_doc.md`, update progress.
|
|
413
|
+
7. `factory_generate_doc` → read current doc & code mix, build `info` dict, log module list & key sizes, invoke `doc_factory.generate_doc`, prepend result to existing doc, update progress.
|
|
414
|
+
8. `order_doc` → split current doc by anchors, reorder sections via `get_order`, overwrite `output_doc.md`.
|
|
415
|
+
9. `clear_cache` → delete log file if `save_logs` is false.
|
|
416
|
+
|
|
417
|
+
**Data Contract**
|
|
418
|
+
|
|
419
|
+
| Entity | Type | Role | Notes |
|
|
420
|
+
|--------|------|------|-------|
|
|
421
|
+
| `project_directory` | `str` | Input | Root of the target code base. |
|
|
422
|
+
| `config` | `Config` | Input | Supplies `ignore_files`, `language`, `pbc.log_level`, `pbc.save_logs`, `get_project_settings()`. |
|
|
423
|
+
| `sync_model` / `async_model` | `Model` / `AsyncModel` | Input | LLM interface passed to preprocessors/post‑processors. |
|
|
424
|
+
| `progress_bar` | `BaseProgress` | Input/Side‑effect | Must implement `update_task()`. |
|
|
425
|
+
| `self.logger` | `BaseLogger` | Side‑effect | Writes to `report.txt` via `FileLoggerTemplate`. |
|
|
426
|
+
| Cached files (`code_mix.txt`, `global_info.md`, `output_doc.md`, `report.txt`) | on‑disk | Persistent storage | Created/overwritten by manager methods. |
|
|
427
|
+
| `info` (in `factory_generate_doc`) | `dict` | Input to `DocFactory.generate_doc` | Keys: `language`, `full_data`, `code_mix`. |
|
|
428
|
+
| Return values | `None` (except `read_file_by_file_key`) | Side‑effects | Methods write files or update progress; only `read_file_by_file_key` returns file contents. |
|
|
429
|
+
|
|
430
|
+
> **Warning** – The manager assumes all configured keys exist; missing files raise `FileNotFoundError`, and absent config attributes cause `AttributeError`.
|
|
431
|
+
<a name="manager-class-usage"></a>!noinfo
|
|
432
|
+
<a name="base-module-abstract"></a>
|
|
433
|
+
## `BaseModule` Abstract Interface
|
|
434
|
+
**Responsibility** – Defines the contract for all documentation generation modules.
|
|
435
|
+
**Visible Interactions** – Sub‑classes inherit from this ABC and are invoked by `DocFactory`.
|
|
436
|
+
**Logic Flow** –
|
|
437
|
+
1. Constructor (`__init__`) does nothing (`pass`).
|
|
438
|
+
2. Declares abstract `generate(info: dict, model: Model)` method.
|
|
439
|
+
<a name="custom-module"></a>
|
|
440
|
+
## `CustomModule` – Context‑Aware Description Generator
|
|
441
|
+
**Responsibility** – Generates a custom description using the supplied `discription` and a code split.
|
|
442
|
+
**Visible Interactions** – Calls `generete_custom_discription`, `split_data`.
|
|
443
|
+
**Logic Flow** –
|
|
444
|
+
1. Store `discription` at init.
|
|
445
|
+
2. `generate(info, model)` →
|
|
446
|
+
- Retrieve `code_mix` via `info.get("code_mix")`.
|
|
447
|
+
- Split with `split_data(..., max_symbols=5000)`.
|
|
448
|
+
- Invoke `generete_custom_discription(split_result, model, self.discription, info.get("language"))`.
|
|
449
|
+
- Return the resulting string.
|
|
450
|
+
<a name="custom-module-without-context"></a>
|
|
451
|
+
## `CustomModuleWithOutContext` – Description‑Only Generator
|
|
452
|
+
**Responsibility** – Produces a description without processing source code.
|
|
453
|
+
**Visible Interactions** – Calls `generete_custom_discription_without`.
|
|
454
|
+
**Logic Flow** –
|
|
455
|
+
1. Store `discription`.
|
|
456
|
+
2. `generate(info, model)` →
|
|
457
|
+
- Invoke `generete_custom_discription_without(model, self.discription, info.get("language"))`.
|
|
458
|
+
- Return the result.
|
|
459
|
+
<a name="docfactory-orchestrator"></a>
|
|
460
|
+
## `DocFactory` Orchestrator
|
|
461
|
+
**Responsibility** – Executes a sequence of `BaseModule` instances, aggregates their outputs, and logs progress.
|
|
462
|
+
**Visible Interactions** – Receives a list of module instances, a `Model`, a `BaseProgress` reporter, and uses `BaseLogger`.
|
|
463
|
+
**Logic Flow** –
|
|
464
|
+
1. Store `modules` tuple as list; instantiate `BaseLogger`.
|
|
465
|
+
2. `generate_doc(info, model, progress)`
|
|
466
|
+
- Initialise `output = ""`.
|
|
467
|
+
- `progress.create_new_subtask("Generate parts", len(self.modules))`.
|
|
468
|
+
- Iterate `module` in `self.modules`:
|
|
469
|
+
- Call `module.generate(info, model)` → `module_result`.
|
|
470
|
+
- Append `module_result + "\n\n"` to `output`.
|
|
471
|
+
- Log informational messages with `InfoLog`.
|
|
472
|
+
- `progress.update_task()`.
|
|
473
|
+
- End loop → `progress.remove_subtask()`.
|
|
474
|
+
- Return aggregated `output`.
|
|
475
|
+
|
|
476
|
+
**Data Contract**
|
|
477
|
+
|
|
478
|
+
| Entity | Type | Role | Notes |
|
|
479
|
+
|--------|------|------|-------|
|
|
480
|
+
| `info` | `dict` | Input data (code snippets, language, etc.) | Keys accessed via `info.get(...)` in modules. |
|
|
481
|
+
| `model` | `Model` | LLM interface used by modules | Passed unchanged to post‑processor calls. |
|
|
482
|
+
| `progress` | `BaseProgress` | Progress tracking object | Must implement `create_new_subtask`, `update_task`, `remove_subtask`. |
|
|
483
|
+
| `module_result` | `str` | Partial documentation fragment | Concatenated into final `output`. |
|
|
484
|
+
| `self.logger` | `BaseLogger` | Logging sink | Emits `InfoLog` entries. |
|
|
485
|
+
|
|
486
|
+
> **Note:** `DocFactory` does not perform any validation of `info` keys; missing keys may cause `None` to be passed downstream.
|
|
487
|
+
<a name="parent-model"></a>
|
|
488
|
+
## `ParentModel` – Shared configuration & model rotation
|
|
489
|
+
|
|
490
|
+
| Entity | Type | Role | Notes |
|
|
491
|
+
|--------|------|------|-------|
|
|
492
|
+
| `api_key` | `str` | API credential | Defaults to `API_KEY` from `autodocgenerator.engine.config.config` |
|
|
493
|
+
| `history` | `History` | Message buffer | Injected or created on‑demand |
|
|
494
|
+
| `use_random` | `bool` | Randomise model order | `True` enables `random.shuffle` |
|
|
495
|
+
| `regen_models_name` | `list[str]` | Rotation list | Copied from `MODELS_NAME` then shuffled if `use_random` |
|
|
496
|
+
| `current_model_index` | `int` | Cursor in `regen_models_name` | Starts at 0 |
|
|
497
|
+
|
|
498
|
+
> **Assumption** – `MODELS_NAME` and `API_KEY` are defined in the imported config module.
|
|
499
|
+
|
|
500
|
+
The class stores credentials, a shared `History`, and prepares a shuffled list of model identifiers for fail‑over usage.
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
<a name="gpt-model"></a>
|
|
504
|
+
## `GPTModel` – Synchronous Groq client wrapper
|
|
505
|
+
|
|
506
|
+
| Entity | Type | Role | Notes |
|
|
507
|
+
|--------|------|------|-------|
|
|
508
|
+
| `client` | `Groq` | Sends sync chat requests | Instantiated with `self.api_key` |
|
|
509
|
+
| `logger` | `BaseLogger` | Emits runtime logs | Same log types as async variant |
|
|
510
|
+
| `generate_answer` | `def` | Returns LLM reply | Same signature as async version |
|
|
511
|
+
|
|
512
|
+
**Logic Flow** mirrors `AsyncGPTModel` but uses the synchronous `self.client.chat.completions.create` call and returns the extracted `result` directly.
|
|
513
|
+
|
|
514
|
+
Both wrappers expose the same public contract, differing only in async vs sync execution.
|
|
515
|
+
<a name="async-gpt-model"></a>
|
|
516
|
+
## `AsyncGPTModel` – Asynchronous Groq client wrapper
|
|
517
|
+
|
|
518
|
+
| Entity | Type | Role | Notes |
|
|
519
|
+
|--------|------|------|-------|
|
|
520
|
+
| `client` | `AsyncGroq` | Sends async chat requests | Instantiated with `self.api_key` |
|
|
521
|
+
| `logger` | `BaseLogger` | Emits runtime logs | Uses `InfoLog`, `WarningLog`, `ErrorLog` |
|
|
522
|
+
| `generate_answer` | `async def` | Returns LLM reply | Parameters: `with_history: bool = True`, `prompt: str = None` |
|
|
523
|
+
|
|
524
|
+
**Logic Flow**
|
|
525
|
+
1. Log start of generation.
|
|
526
|
+
2. Select `messages` from `self.history.history` or the supplied `prompt`.
|
|
527
|
+
3. Loop until a model succeeds:
|
|
528
|
+
- If `regen_models_name` empty → log error & raise `ModelExhaustedException`.
|
|
529
|
+
- Pick `model_name` from `regen_models_name[current_model_index]`.
|
|
530
|
+
- Call `await self.client.chat.completions.create(messages=messages, model=model_name)`.
|
|
531
|
+
- On exception → log warning, advance `current_model_index` (wrap‑around).
|
|
532
|
+
4. Extract `result = chat_completion.choices[0].message.content`.
|
|
533
|
+
5. Log the selected model and the answer (level 2).
|
|
534
|
+
6. Return `result`.
|
|
535
|
+
|
|
536
|
+
**Interactions** – Relies on `AsyncGroq` for network I/O, `History` for context, and the shared logger. No file I/O.
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
<a name="semantic-ordering-llm"></a>
|
|
540
|
+
## Semantic Title Ordering (LLM Interaction)
|
|
541
|
+
|
|
542
|
+
| Entity | Type | Role | Notes |
|
|
543
|
+
|--------|------|------|-------|
|
|
544
|
+
| `model` | `Model` | Input | Must expose `get_answer_without_history`. |
|
|
545
|
+
| `chanks` | `dict[str,str]` | Input | Mapping from anchor links to text chunks. |
|
|
546
|
+
| `logger` | `BaseLogger` | Side‑effect | Emits `InfoLog` entries at various levels. |
|
|
547
|
+
| `prompt` | `list[dict]` | Local | Single user‑role message requesting a comma‑separated ordering. |
|
|
548
|
+
| `result` | `str` | Output (raw LLM reply) | Expected list of `#anchor` titles. |
|
|
549
|
+
| `new_result` | `list[str]` | Local | Stripped titles from `result`. |
|
|
550
|
+
| `order_output` | `str` | Return | Concatenated chunk texts in LLM‑provided order. |
|
|
551
|
+
|
|
552
|
+
**Logic Flow**
|
|
553
|
+
1. Initialise `BaseLogger`; log start and input keys/values.
|
|
554
|
+
2. Build `prompt` containing the titles (`list(chanks.keys())`).
|
|
555
|
+
3. Call `model.get_answer_without_history(prompt)`; capture raw string.
|
|
556
|
+
4. Split on commas, strip whitespace → `new_result`.
|
|
557
|
+
5. Iterate `new_result`; for each anchor retrieve its chunk via `chanks.get(el)` and append to `order_output` (newline‑separated).
|
|
558
|
+
6. Log each addition; return the assembled `order_output`.
|
|
559
|
+
|
|
560
|
+
> **Warning** – If the model returns a malformed list (missing titles or extra commas), mismatches may lead to `None` values in the final output.
|
|
561
|
+
<a name="html-link-extraction"></a>
|
|
562
|
+
## HTML Link Extraction (`get_all_html_links`)
|
|
563
|
+
|
|
564
|
+
| Entity | Type | Role | Notes |
|
|
565
|
+
|--------|------|------|-------|
|
|
566
|
+
| `data` | `str` | Input | Raw documentation text. |
|
|
567
|
+
| `links` | `list[str]` | Output | Anchor links prefixed with `#`. |
|
|
568
|
+
| `logger` | `BaseLogger` | Side‑effect | Logs progress at INFO level. |
|
|
569
|
+
| `pattern` | `str` | Internal | Regex `\<a name=["']?(.*?)["']?\>\</a\>` . |
|
|
570
|
+
|
|
571
|
+
The function scans `data` for `<a name=…></a>` anchors, captures the name when longer than five characters, prefixes it with `#`, logs the count and the list, then returns `links`. No file I/O occurs.
|
|
572
|
+
<a name="anchor-extraction-chunk-splitting"></a>
|
|
573
|
+
## Anchor Extraction & Chunk Splitting
|
|
574
|
+
|
|
575
|
+
| Entity | Type | Role | Notes |
|
|
576
|
+
|--------|------|------|-------|
|
|
577
|
+
| `chunks` | `list[str]` | Input (raw HTML fragments) | Passed to **extract_links_from_start**. |
|
|
578
|
+
| `pattern` (in `extract_links_from_start`) | `str` | Constant | `r'^<a name=["\']?(.*?)["\']?></a>'` matches a leading anchor. |
|
|
579
|
+
| `anchor_name` | `str` | Local | Captured name; processed only if `len > 5`. |
|
|
580
|
+
| `links` | `list[str]` | Output (prefixed anchors) | Each stored as `#` + name. |
|
|
581
|
+
| `text` | `str` | Input (full doc) | Split by **split_text_by_anchors**. |
|
|
582
|
+
| `result_chanks` | `list[str]` | Output | Trimmed, non‑empty chunks after `re.split`. |
|
|
583
|
+
| `all_links` | `list[str]` | Output | Result of **extract_links_from_start** on the chunks. |
|
|
584
|
+
| `result` | `dict[str,str]` | Output | Mapping `#anchor → chunk`. Returns `None` on size mismatch. |
|
|
585
|
+
|
|
586
|
+
**Logic Flow**
|
|
587
|
+
1. `extract_links_from_start` iterates `chunks`; regex anchors at start are captured.
|
|
588
|
+
2. If an anchor’s name exceeds five characters, `"#"+name` is appended to `links`.
|
|
589
|
+
3. `split_text_by_anchors` builds a look‑ahead pattern (`(?=<a name=…>)`) to split the full text into `chunks`.
|
|
590
|
+
4. Whitespace‑trimmed chunks become `result_chanks`.
|
|
591
|
+
5. `extract_links_from_start` processes these chunks; if the count of anchors ≠ chunks, the function aborts (`None`).
|
|
592
|
+
6. Otherwise a dict `result` maps each `#anchor` to its associated chunk.
|
|
593
|
+
|
|
594
|
+
> **Assumption** – No file I/O occurs; the functions only transform in‑memory strings.
|
|
595
|
+
<a name="gen-doc"></a>
|
|
596
|
+
## `gen_doc` – End‑to‑End Documentation Generation Pipeline
|
|
597
|
+
|
|
598
|
+
| Entity | Type | Role | Notes |
|
|
599
|
+
|--------|------|------|-------|
|
|
600
|
+
| `project_path` | `str` | Root of the source project | Supplied by caller |
|
|
601
|
+
| `config` | `Config` | Project‑wide settings | From `read_config` |
|
|
602
|
+
| `custom_modules` | `list[...]` | Extension hooks for doc factories | Passed to `DocFactory` |
|
|
603
|
+
| `structure_settings` | `StructureSettings` | Controls ordering & intro links | Determines size & optional steps |
|
|
604
|
+
| `sync_model` / `async_model` | `GPTModel` / `AsyncGPTModel` | Language model back‑ends | Instantiated with global `API_KEY` |
|
|
605
|
+
| `manager` | `Manager` | Orchestrates parsing, generation, caching | Core engine object |
|
|
606
|
+
| Return value | `str` | Final assembled documentation | Read from manager’s output cache |
|
|
607
|
+
|
|
608
|
+
**Logic Flow**
|
|
609
|
+
1. Create `GPTModel` and `AsyncGPTModel` using the shared `API_KEY`.
|
|
610
|
+
2. Initialise `Manager` with `project_path`, `config`, both models, and a console progress bar.
|
|
611
|
+
3. Invoke `manager.generate_code_file()` → extracts source code.
|
|
612
|
+
4. Call `manager.generete_doc_parts(...)` → splits docs per `structure_settings.max_doc_part_size`.
|
|
613
|
+
5. Run `manager.factory_generate_doc(DocFactory(*custom_modules))` → applies user‑defined modules.
|
|
614
|
+
6. If `include_order` is true, `manager.order_doc()` reorders sections.
|
|
615
|
+
7. If `include_intro_links` is true, generate intro links via `IntroLinks()` factory.
|
|
616
|
+
8. Clear temporary caches with `manager.clear_cache()`.
|
|
617
|
+
9. Return the assembled document read by `manager.read_file_by_file_key("output_doc")`.
|
|
618
|
+
|
|
619
|
+
**Interactions** – `gen_doc` ties together configuration (`Config`), custom processing (`CustomModule*`), the GPT backend, and the `Manager` orchestration. No external I/O occurs beyond the initial YAML read (handled elsewhere).
|
|
620
|
+
|
|
621
|
+
> **Warning** – The function assumes `API_KEY` is defined in `autodocgenerator.engine.config.config`; absence raises an import error.
|
|
622
|
+
<a name="gen-doc-parts"></a>
|
|
623
|
+
## `gen_doc_parts` – Orchestrated Multi‑Chunk Documentation
|
|
624
|
+
|
|
625
|
+
| Entity | Type | Role | Notes |
|
|
626
|
+
|--------|------|------|-------|
|
|
627
|
+
| `full_code_mix` | `str` | Input | Complete source to be documented. |
|
|
628
|
+
| `max_symbols` | `int` | Input | Symbol limit passed to `split_data`. |
|
|
629
|
+
| `model` | `Model` | Input | Same contract as above. |
|
|
630
|
+
| `project_settings` | `ProjectSettings` | Input | Supplies global prompts. |
|
|
631
|
+
| `language` | `str` | Input | Target language for docs. |
|
|
632
|
+
| `progress_bar` | `BaseProgress` | Side‑effect | Tracks per‑chunk progress. |
|
|
633
|
+
| `global_info` | `str` / `None` | Optional | Extra project context. |
|
|
634
|
+
| `all_result` | `str` | Output | Concatenated documentation. |
|
|
635
|
+
| `logger` | `BaseLogger` | Side‑effect | Logs orchestration milestones. |
|
|
636
|
+
|
|
637
|
+
**Logic Flow**
|
|
638
|
+
1. Split source via `split_data`.
|
|
639
|
+
2. Create a sub‑task on `progress_bar` for the number of chunks.
|
|
640
|
+
3. For each chunk `el`:
|
|
641
|
+
- Call `write_docs_by_parts` passing the previous result as `prev_info`.
|
|
642
|
+
- Append returned text and two newlines to `all_result`.
|
|
643
|
+
- Retain only the last 3000 characters of `result` for the next iteration (context window).
|
|
644
|
+
- Update progress bar.
|
|
645
|
+
4. Remove sub‑task, log final length, and return `all_result`.
|
|
646
|
+
<a name="write-docs-by-parts"></a>
|
|
647
|
+
## `write_docs_by_parts` – Per‑Chunk Documentation Generation
|
|
648
|
+
|
|
649
|
+
| Entity | Type | Role | Notes |
|
|
650
|
+
|--------|------|------|-------|
|
|
651
|
+
| `part` | `str` | Input | Text fragment to document. |
|
|
652
|
+
| `model` | `Model` | Input | Must implement `get_answer_without_history(prompt)`. |
|
|
653
|
+
| `project_settings` | `ProjectSettings` | Input | Provides `prompt` for system context. |
|
|
654
|
+
| `prev_info` | `str` / `None` | Optional | Previously generated doc fragment. |
|
|
655
|
+
| `language` | `str` | Input | Language code (default `"en"`). |
|
|
656
|
+
| `global_info` | `str` / `None` | Optional | Additional project‑wide context. |
|
|
657
|
+
| `answer` | `str` | Output | Raw LLM response, possibly wrapped in markdown fences. |
|
|
658
|
+
| `logger` | `BaseLogger` | Side‑effect | Logs generation steps. |
|
|
659
|
+
|
|
660
|
+
**Logic Flow**
|
|
661
|
+
1. Initialise logger and base system prompts (language, global project info, static `BASE_PART_COMPLITE_TEXT`).
|
|
662
|
+
2. Append optional `global_info` and `prev_info` prompts.
|
|
663
|
+
3. Append user prompt containing `part`.
|
|
664
|
+
4. Call `model.get_answer_without_history(prompt=prompt)`.
|
|
665
|
+
5. Strip leading/trailing ````` fences if present and return cleaned text.
|
|
666
|
+
|
|
667
|
+
> **Warning** – The function assumes the LLM returns a string; non‑string answers would raise a type error.
|
|
668
|
+
<a name="custom-description-template"></a>
|
|
669
|
+
## Template‑Based Custom Description Generation (`generete_custom_discription_without`)
|
|
670
|
+
|
|
671
|
+
| Entity | Type | Role | Notes |
|
|
672
|
+
|--------|------|------|-------|
|
|
673
|
+
| `model` | `Model` | Input | LLM interface. |
|
|
674
|
+
| `custom_description` | `str` | Input | Desired description task. |
|
|
675
|
+
| `language` | `str` | Input (default `"en"`) | Language hint. |
|
|
676
|
+
| `result` | `str` | Output | LLM answer respecting strict tag rules. |
|
|
677
|
+
|
|
678
|
+
Constructs a prompt that enforces a single opening `
|
|
679
|
+
<a name="custom-description-iterative"></a>
|
|
680
|
+
## Iterative Custom Description Generation (`generete_custom_discription`)
|
|
681
|
+
|
|
682
|
+
| Entity | Type | Role | Notes |
|
|
683
|
+
|--------|------|------|-------|
|
|
684
|
+
| `splited_data` | `str` (iterable) | Input | Segments of documentation. |
|
|
685
|
+
| `model` | `Model` | Input | LLM interface. |
|
|
686
|
+
| `custom_description` | `str` | Input | Task description for the LLM. |
|
|
687
|
+
| `language` | `str` | Input (default `"en"`) | Language hint. |
|
|
688
|
+
| `result` | `str` | Output | First non‑error description. |
|
|
689
|
+
|
|
690
|
+
Iterates over `splited_data`, sending a prompt that includes the segment, `BASE_CUSTOM_DISCRIPTIONS`, and the task. Breaks when the LLM response does **not** contain `"!noinfo"` or `"No information found"` early in the text; otherwise continues. Returns the final `result`.
|
|
691
|
+
<a name="repository-mixer"></a>
|
|
692
|
+
## Repository Structure Packing (CodeMix)
|
|
693
|
+
|
|
694
|
+
| Entity | Type | Role | Notes |
|
|
695
|
+
|--------|------|------|-------|
|
|
696
|
+
| `root_dir` | `Path` | Input | Base directory for scanning. |
|
|
697
|
+
| `ignore_patterns` | `list[str]` | Input | Glob patterns to exclude files/dirs. |
|
|
698
|
+
| `logger` | `BaseLogger` | Side‑effect | Logs ignored paths. |
|
|
699
|
+
| `should_ignore` | `method` | Local | Returns `True` if a path matches any ignore pattern. |
|
|
700
|
+
| `output_file` | `str` | Input | Destination text file for the mix. |
|
|
701
|
+
| `out` | file handle | Side‑effect | Receives repository tree and file contents. |
|
|
702
|
+
|
|
703
|
+
**Logic Flow**
|
|
704
|
+
1. Resolve `root_dir`; instantiate `BaseLogger`.
|
|
705
|
+
2. `should_ignore` converts a `Path` to a relative string, then checks against each glob pattern (full path, basename, and any path part).
|
|
706
|
+
3. `build_repo_content` opens `output_file` for writing.
|
|
707
|
+
4. First pass: iterate sorted `rglob("*")`; for each non‑ignored path write an indented tree line (`dir/` or `file`).
|
|
708
|
+
5. Write a separator line (`"="*20`).
|
|
709
|
+
6. Second pass: iterate again; for each non‑ignored **file**, write a `<file path="…">` tag, then the file’s text (read with UTF‑8, errors ignored). Errors are captured and written as plain text.
|
|
710
|
+
|
|
711
|
+
> **Critical** – No network or external service calls; all operations are local filesystem reads/writes.
|
|
712
|
+
<a name="compressor-core-function"></a>
|
|
713
|
+
## `compress` – Core LLM‑driven Compression
|
|
714
|
+
|
|
715
|
+
| Entity | Type | Role | Notes |
|
|
716
|
+
|--------|------|------|-------|
|
|
717
|
+
| `data` | `str` | Input | Raw source text to be compressed. |
|
|
718
|
+
| `project_settings` | `ProjectSettings` | Input | Supplies system prompt via its **`prompt`** property. |
|
|
719
|
+
| `model` | `Model` | Input | Must implement `get_answer_without_history(prompt)`. |
|
|
720
|
+
| `compress_power` | `int` | Input | Determines compression intensity; passed to helper text. |
|
|
721
|
+
| `prompt` | `list[dict]` | Local | System‑user message stack fed to the LLM. |
|
|
722
|
+
| `answer` | `str` | Output | LLM’s compressed response. |
|
|
723
|
+
|
|
724
|
+
**Logic Flow**
|
|
725
|
+
1. Assemble a three‑message `prompt`: project‑level system prompt, a dynamically built “base compress” text (`get_BASE_COMPRESS_TEXT`), and the user‑provided `data`.
|
|
726
|
+
2. Invoke `model.get_answer_without_history(prompt=prompt)`.
|
|
727
|
+
3. Return the LLM’s reply unchanged.
|
|
728
|
+
|
|
729
|
+
> **Assumption** – No file I/O; transformation occurs entirely in‑memory.
|
|
730
|
+
<a name="batch-compression-compare"></a>
|
|
731
|
+
## `compress_and_compare` – Batch Compression with Progress
|
|
732
|
+
|
|
733
|
+
| Entity | Type | Role | Notes |
|
|
734
|
+
|--------|------|------|-------|
|
|
735
|
+
| `data` | `list[str]` | Input | Collection of text fragments. |
|
|
736
|
+
| `model` | `Model` | Input | Same requirements as above. |
|
|
737
|
+
| `project_settings` | `ProjectSettings` | Input | Shared prompt source. |
|
|
738
|
+
| `compress_power` | `int` | Input (default 4) | Max fragments per batch. |
|
|
739
|
+
| `progress_bar` | `BaseProgress` | Side‑effect | Visual sub‑task tracking. |
|
|
740
|
+
| `compress_and_compare_data` | `list[str]` | Local | Holds concatenated compressed batches. |
|
|
741
|
+
|
|
742
|
+
**Logic Flow**
|
|
743
|
+
1. Initialise `compress_and_compare_data` sized to `ceil(len(data)/compress_power)`.
|
|
744
|
+
2. Create a sub‑task on `progress_bar` for the full length of `data`.
|
|
745
|
+
3. Iterate `data` with index `i`; compute batch index `curr_index = i // compress_power`.
|
|
746
|
+
4. Call `compress` on each element, appending the result plus a newline to the appropriate batch slot.
|
|
747
|
+
5. Update the progress bar after each element; finally remove the sub‑task.
|
|
748
|
+
6. Return the list of batched compressed strings.
|
|
749
|
+
<a name="iterative-full-compression"></a>
|
|
750
|
+
## `compress_to_one` – Recursive Full‑Document Collapse
|
|
751
|
+
|
|
752
|
+
| Entity | Type | Role | Notes |
|
|
753
|
+
|--------|------|------|-------|
|
|
754
|
+
| `data` | `list[str]` | Input/Output | Shrinks each iteration until a single string remains. |
|
|
755
|
+
| `model` | `Model` | Input | Same LLM contract. |
|
|
756
|
+
| `project_settings` | `ProjectSettings` | Input | Provides prompt context. |
|
|
757
|
+
| `compress_power` | `int` | Input (default 4) | Base batch size; may be reduced to 2 for small tails. |
|
|
758
|
+
| `progress_bar` | `BaseProgress` | Side‑effect | Propagated to inner calls. |
|
|
759
|
+
| `count_of_iter` | `int` | Local | Iteration counter (for potential logging). |
|
|
760
|
+
|
|
761
|
+
**Logic Flow**
|
|
762
|
+
1. Loop while `len(data) > 1`.
|
|
763
|
+
2. Adjust `new_compress_power`: if remaining items are fewer than `compress_power + 1`, set to 2 to avoid a final singleton batch.
|
|
764
|
+
3. Replace `data` with the result of `compress_and_compare(data, …, new_compress_power, progress_bar)`.
|
|
765
|
+
4. Increment `count_of_iter`.
|
|
766
|
+
5. Once reduced to a single element, return `data[0]`.
|
|
767
|
+
|
|
768
|
+
> **Warning** – The function assumes `compress_and_compare` always returns a non‑empty list; an empty return would raise an `IndexError`.
|
|
769
|
+
<a name="split-data-loop"></a>
|
|
770
|
+
## `split_data` – Symbol‑Based Chunking Loop
|
|
771
|
+
|
|
772
|
+
| Entity | Type | Role | Notes |
|
|
773
|
+
|--------|------|------|-------|
|
|
774
|
+
| `splited_by_files` | `list[str]` | Local | Initial list of file‑level fragments (source not shown). |
|
|
775
|
+
| `max_symbols` | `int` | Input | Upper bound for symbols per chunk. |
|
|
776
|
+
| `split_objects` | `list[str]` | Local | Accumulates final chunks respecting `max_symbols`. |
|
|
777
|
+
| `logger` | `BaseLogger` | Side‑effect | Emits progress messages. |
|
|
778
|
+
|
|
779
|
+
**Logic Flow**
|
|
780
|
+
1. Log start.
|
|
781
|
+
2. **Refinement loop** – while any element exceeds `1.5 × max_symbols`, split it at `max_symbols/2` and insert the second half right after the original.
|
|
782
|
+
3. **Packing loop** – iterate `splited_by_files`; create a new `split_objects` entry when adding the element would breach `1.25 × max_symbols`. Otherwise, concatenate with a newline.
|
|
783
|
+
4. Log final chunk count and return `split_objects`.
|
|
784
|
+
|
|
785
|
+
> **Assumption** – `splited_by_files` is pre‑populated; no I/O occurs here.
|
|
786
|
+
|