autodocgenerator 0.8.9.9__py3-none-any.whl → 0.9.0.1__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.
@@ -1,12 +1,20 @@
1
1
  import yaml
2
2
  from autodocgenerator.factory.modules.general_modules import CustomModule, CustomModuleWithOutContext
3
- from ..config.config import Config, ProjectConfigSettings
3
+ from ..config.config import Config, ProjectBuildConfig
4
4
 
5
5
 
6
+ class StructureSettings:
7
+ include_intro_links = True
8
+ include_order = True
9
+ max_doc_part_size = 5_000
10
+
11
+ def load_settings(self, data: dict[str, any]):
12
+ for key, el in data.items():
13
+ setattr(self, key, el)
6
14
 
7
- def read_config(file_data: str) -> tuple[Config, list[CustomModule]]:
8
- data = yaml.safe_load(file_data)
9
15
 
16
+ def read_config(file_data: str) -> tuple[Config, list[CustomModule], StructureSettings]:
17
+ data = yaml.safe_load(file_data)
10
18
  config : Config = Config()
11
19
 
12
20
  ignore_files = data.get("ignore_files", [])
@@ -15,8 +23,8 @@ def read_config(file_data: str) -> tuple[Config, list[CustomModule]]:
15
23
  project_name = data.get("project_name")
16
24
  project_additional_info = data.get("project_additional_info", {})
17
25
 
18
- project_settings = data.get("project_settings", {})
19
- pcs = ProjectConfigSettings()
26
+ project_settings = data.get("build_settings", {})
27
+ pcs = ProjectBuildConfig()
20
28
  pcs.load_settings(project_settings)
21
29
 
22
30
  config.set_language(language).set_project_name(project_name).set_pcs(pcs)
@@ -31,4 +39,8 @@ def read_config(file_data: str) -> tuple[Config, list[CustomModule]]:
31
39
 
32
40
  custom_modules = [CustomModuleWithOutContext(custom_discription[1:]) if custom_discription[0] == "%" else CustomModule(custom_discription) for custom_discription in custom_discriptions]
33
41
 
34
- return config, custom_modules
42
+ structure_settings = data.get("structure_settings", {})
43
+ structure_settings_object = StructureSettings()
44
+ structure_settings_object.load_settings(structure_settings)
45
+
46
+ return config, custom_modules, structure_settings_object
@@ -1,13 +1,17 @@
1
1
  from autodocgenerator.manage import Manager
2
2
  from autodocgenerator.factory.base_factory import DocFactory
3
+ from autodocgenerator.factory.modules.general_modules import CustomModule, CustomModuleWithOutContext
3
4
  from autodocgenerator.factory.modules.intro import IntroLinks
4
5
  from autodocgenerator.ui.progress_base import ConsoleGtiHubProgress
5
- from autodocgenerator.auto_runner.config_reader import Config, read_config
6
+ from autodocgenerator.auto_runner.config_reader import Config, read_config, StructureSettings
6
7
  from autodocgenerator.engine.models.gpt_model import GPTModel, AsyncGPTModel
7
8
  from autodocgenerator.engine.config.config import API_KEY
8
9
 
9
10
 
10
- def gen_doc(project_path: str, config: Config, custom_modules):
11
+ def gen_doc(project_path: str,
12
+ config: Config,
13
+ custom_modules: list[CustomModule | CustomModuleWithOutContext],
14
+ structure_settings: StructureSettings) -> str:
11
15
 
12
16
  sync_model = GPTModel(API_KEY, use_random=False)
13
17
  async_model = AsyncGPTModel(API_KEY)
@@ -22,10 +26,13 @@ def gen_doc(project_path: str, config: Config, custom_modules):
22
26
 
23
27
 
24
28
  manager.generate_code_file()
25
- manager.generete_doc_parts(max_symbols=5000)
29
+ manager.generete_doc_parts(max_symbols=structure_settings.max_doc_part_size)
26
30
  manager.factory_generate_doc(DocFactory(*custom_modules))
27
- manager.order_doc()
28
- manager.factory_generate_doc(DocFactory(IntroLinks()))
31
+ if structure_settings.include_order:
32
+ manager.order_doc()
33
+
34
+ if structure_settings.include_intro_links:
35
+ manager.factory_generate_doc(DocFactory(IntroLinks()))
29
36
  manager.clear_cache()
30
37
 
31
38
  return manager.read_file_by_file_key("output_doc")
@@ -33,12 +40,13 @@ def gen_doc(project_path: str, config: Config, custom_modules):
33
40
  if __name__ == "__main__":
34
41
  with open("autodocconfig.yml", "r", encoding="utf-8") as file:
35
42
  config_data = file.read()
36
- config, custom_modules = read_config(config_data)
43
+ config, custom_modules, structure_settings = read_config(config_data)
37
44
 
38
45
  output_doc = gen_doc(
39
46
  ".",
40
47
  config,
41
- custom_modules
48
+ custom_modules,
49
+ structure_settings
42
50
  )
43
51
 
44
52
 
@@ -4,7 +4,7 @@ from ..factory.base_factory import DocFactory
4
4
  from ..factory.modules.intro import IntroLinks
5
5
 
6
6
 
7
- class ProjectConfigSettings:
7
+ class ProjectBuildConfig:
8
8
  save_logs = False
9
9
  log_level = -1
10
10
  def load_settings(self, data: dict[str, any]):
@@ -22,14 +22,14 @@ class Config:
22
22
  self.language: str = "en"
23
23
  self.project_name: str = ""
24
24
  self.project_additional_info: dict = {}
25
- self.pcs: ProjectConfigSettings = ProjectConfigSettings()
25
+ self.pbc: ProjectBuildConfig = ProjectBuildConfig()
26
26
 
27
27
  def set_language(self, language: str):
28
28
  self.language = language
29
29
  return self
30
30
 
31
- def set_pcs(self, pcs: ProjectConfigSettings):
32
- self.pcs = pcs
31
+ def set_pcs(self, pcs: ProjectBuildConfig):
32
+ self.pbc = pcs
33
33
  return self
34
34
 
35
35
  def set_project_name(self, name: str):
@@ -9,28 +9,34 @@ You should understand, that it is not full code, it is just part
9
9
  Do NOT skip details; analyze everything that appears in the snippet.
10
10
  """
11
11
 
12
- BASE_PART_COMPLITE_TEXT = """Revised Documentation Prompt
13
- Role: You are a senior technical writer. Input: You will receive a specific code snippet representing a fragment of a larger system.
14
- Task: Write clear, structured, and hierarchical documentation for this fragment. Length: 0.7–1k characters (keep it tight).
15
-
16
- Content Requirements:
17
- Component Responsibility: Define exactly what this specific fragment does.
18
- Interactions: Describe how this piece communicates with the rest of the system.
19
- Technical Details: Detail key functions, classes, and logic flows present in the snippet.
20
- Data Flow: Outline inputs, outputs, side effects, and logic assumptions.
21
-
22
- Constraint - No Generic Headers (CRITICAL):
23
- DO NOT use generic or global topic headers such as "Overview," "Core," "Introduction," "Background," or "System Summary."
24
- All headings must be specific to the functionality of the code fragment provided.
25
-
26
- Context & Style:
27
- Use the global system description as the primary context, but do not restate it. Focus exclusively on the fragment.
28
- Write for developers who are new to the codebase.
29
- Maintain high technical accuracy and a concise, professional tone.
30
-
31
- Formatting:
32
- Use Markdown for structure.
33
- Include HTML anchors near titles: <a name="specific-title"></a> \n ## Specific Title."""
12
+ BASE_PART_COMPLITE_TEXT = """
13
+ Role: You are a Senior Technical Writer & System Architect. Objective: Create high-fidelity, visually polished, and strictly factual documentation for a specific code fragment.
14
+
15
+ 1. STRICT GROUNDING & ACCURACY (NO HALLUCINATIONS):
16
+ Source Truth: Use ONLY the provided code snippet and the explicit global context.
17
+ Zero Assumption Policy: If a function's origin, a variable's purpose, or a data source is not explicitly present in the provided text, do not invent it. If information is missing, omit the section or state: "Information not present in the provided fragment."
18
+ Context Lock: Do not use general knowledge about external libraries unless their specific usage is visible in the code.
19
+
20
+ 2. VISUAL STRUCTURE & MD STYLE:
21
+ Layout: Use a highly scannable, hierarchical Markdown structure.
22
+ Data Visualization: Present Inputs, Outputs, and Parameters in a Markdown Table (Columns: Entity, Type, Role, Notes).
23
+ Emphasis: Use backticks for code symbols, bolding for key terms, and > Blockquotes for critical logic assumptions or warnings.
24
+ Navigation: Every heading must be preceded by an HTML anchor: <a name="unique-id"></a> \n ## Specific Heading.
25
+
26
+ 3. CONTENT REQUIREMENTS (0.7–1k characters):
27
+ Specific Component Responsibility: Define the exact functional role of this fragment within the system.
28
+ Visible Interactions: Describe how this piece communicates with other parts of the system based only on the snippet.
29
+ Technical Logic Flow: A step-by-step breakdown of the classes, functions, and internal logic.
30
+ Data Contract: Detailed flow of inputs, outputs, and side effects in table format.
31
+
32
+ 4. CRITICAL CONSTRAINT - NO GENERIC HEADERS:
33
+ Forbidden: "Overview", "Introduction", "Background", "Technical Details", "Summary", "Core".
34
+ Required: Use headers that describe the specific functionality (e.g., ## [Component Name] Request Validation or ## Stream Processing Pipeline).
35
+
36
+ 5. TONE & STYLE:
37
+ Professional, technical, and laconic.
38
+ Write for developers who need to understand the fragment's implementation instantly.
39
+ Focus exclusively on the fragment; do not restate the global system description."""
34
40
 
35
41
  BASE_INTRODACTION_CREATE_LINKS = """
36
42
  Role: Senior Technical Solutions Architect.
@@ -13,7 +13,7 @@ from .factory.modules.general_modules import CustomModule
13
13
  from .ui.progress_base import BaseProgress, LibProgress
14
14
  from .ui.logging import BaseLogger, BaseLoggerTemplate, InfoLog, ErrorLog, WarningLog, FileLoggerTemplate
15
15
  from .preprocessor.settings import ProjectSettings
16
- from .auto_runner.config_reader import ProjectConfigSettings
16
+ from .auto_runner.config_reader import ProjectBuildConfig
17
17
  from .postprocessor.sorting import get_order, split_text_by_anchors
18
18
  from .config.config import Config
19
19
 
@@ -44,7 +44,7 @@ class Manager:
44
44
  self.async_model = async_model
45
45
 
46
46
  self.logger = BaseLogger()
47
- self.logger.set_logger(FileLoggerTemplate(self.get_file_path("logs"), log_level=self.config.pcs.log_level))
47
+ self.logger.set_logger(FileLoggerTemplate(self.get_file_path("logs"), log_level=self.config.pbc.log_level))
48
48
 
49
49
  cache_path = os.path.join(self.project_directory, self.CACHE_FOLDER_NAME)
50
50
 
@@ -120,6 +120,6 @@ class Manager:
120
120
  file.write(result)
121
121
 
122
122
  def clear_cache(self):
123
- if not self.config.pcs.save_logs:
123
+ if not self.config.pbc.save_logs:
124
124
  os.remove(self.get_file_path("logs"))
125
125
 
@@ -40,13 +40,13 @@ def split_data(data: str, max_symbols: int) -> list[str]:
40
40
 
41
41
  return split_objects
42
42
 
43
- def write_docs_by_parts(part_id: int, part: str, model: Model, prev_info: str = None, language: str = "en"):
43
+ def write_docs_by_parts(part: str, model: Model, prev_info: str = None, language: str = "en"):
44
44
  logger = BaseLogger()
45
45
  logger.log(InfoLog("Generating documentation for a part..."))
46
46
  prompt = [
47
47
  {
48
48
  "role": "system",
49
- "content": f"For the following task use language {language}. your part id is {part_id}"
49
+ "content": f"For the following task use language {language}"
50
50
  },
51
51
  {
52
52
  "role": "system",
@@ -89,10 +89,7 @@ async def async_write_docs_by_parts(part: str, async_model: AsyncModel, global_i
89
89
  "role": "system",
90
90
  "content": BASE_PART_COMPLITE_TEXT
91
91
  },
92
- # {
93
- # "role": "system",
94
- # "content": global_info
95
- # },
92
+
96
93
  {
97
94
  "role": "user",
98
95
  "content": part
@@ -102,7 +99,7 @@ async def async_write_docs_by_parts(part: str, async_model: AsyncModel, global_i
102
99
  if prev_info is not None:
103
100
  prompt.append({
104
101
  "role": "system",
105
- "content": f"it is last part of documentation that you have write before{prev_info}"
102
+ "content": f"it is last part of documentation that you have write before {prev_info}"
106
103
  })
107
104
 
108
105
  prompt.append({
@@ -134,7 +131,7 @@ def gen_doc_parts(full_code_mix, max_symbols, model: Model, language, progress_b
134
131
 
135
132
  all_result = ""
136
133
  for i, el in enumerate(splited_data):
137
- result = write_docs_by_parts(i + 1, el, model, result, language)
134
+ result = write_docs_by_parts(el, model, result, language)
138
135
  all_result += result
139
136
  all_result += "\n\n"
140
137
 
@@ -57,7 +57,7 @@ class ConsoleGtiHubProgress(BaseProgress):
57
57
  def __init__(self):
58
58
  super().__init__()
59
59
  self.curr_task = None
60
- self.gen_task = ConsoleTask("General Progress", 5)
60
+ self.gen_task = ConsoleTask("General Progress", 4)
61
61
 
62
62
  def create_new_subtask(self, name: str, total_len: int):
63
63
  self.curr_task = ConsoleTask(name, total_len)