This Project helps you to create docs for your projects
Project description
Executive Navigation Tree
- 📦 Installation
- 🛠️ Manager
- 📦 Modules
- 📂 Code Mix
- 🗜️ Compressor
- ⚙️ Core Functions
- 🤖 Interaction Model
- 📈 Execution Parts
- 📊 Orchestration
- 📜 Logging & Progress
- 📚 Postprocess
- 📜 Assumptions & Limits
- 📜 History
- ❗ Exceptions
explain how install workflow with install.ps1 and install.sh scripts for install you should use links irm https://raw.githubusercontent.com/Drag-GameStudio/ADG/main/install.ps1 | iex for powershell and curl -sSL https://raw.githubusercontent.com/Drag-GameStudio/ADG/main/install.sh | bash for linux based systems and also you have to add secret variable to git hub action GROCK_API_KEY with your api key from grock docs https://grockdocs.com to make it work
Parameters required by Manager
project_path– path to the project (e.g.,".").project_settings– an instance ofProjectSettings.pcs– an instance ofProjectConfigSettings.sync_model– an instance ofGPTModel.async_model– an instance ofAsyncGPTModel.ignore_files– list of file names to ignore (list[str]).progress_bar– an instance of a progress UI, e.g.,ConsoleGtiHubProgress().language– language code string, e.g.,"en".
Full example of usage (taken from the provided context)
from autodocgenerator.manage import Manager
from autodocgenerator.engine.models.gpt_model import GPTModel, AsyncGPTModel
from autodocgenerator.ui.progress_base import ConsoleGtiHubProgress
from autodocgenerator.preprocessor.settings import ProjectSettings
from autodocgenerator.factory.base_factory import DocFactory
from .config_reader import Config, read_config, ProjectConfigSettings
from autodocgenerator.engine.config.config import API_KEY
# Load configuration
with open("autodocconfig.yml", "r", encoding="utf-8") as file:
config_data = file.read()
config: Config = read_config(config_data)
# Extract needed objects from config
project_settings = config.get_project_settings()
doc_factory, intro_factory = config.get_doc_factory()
# Prepare GPT models
sync_model = GPTModel(API_KEY, use_random=False)
async_model = AsyncGPTModel(API_KEY)
# Other arguments
project_path = "." # current directory
pcs: ProjectConfigSettings = config.pcs
ignore_list = config.ignore_files
progress = ConsoleGtiHubProgress()
language = "en"
# Create the Manager instance
manager = Manager(
project_path,
project_settings,
pcs,
sync_model=sync_model,
async_model=async_model,
ignore_files=ignore_list,
progress_bar=progress,
language=language,
)
# Example operations using the manager
manager.generate_code_file()
manager.generate_global_info_file(use_async=False, max_symbols=8000)
manager.generete_doc_parts(use_async=False, max_symbols=5000)
manager.factory_generate_doc(doc_factory)
manager.factory_generate_doc(intro_factory)
manager.clear_cache()
output_doc = manager.read_file_by_file_key("output_doc")
The autodocconfig.yml file is a YAML document that defines the configuration for the Auto Doc Generator.
Based on the provided context, the following top‑level keys are recognized:
| Key | Type | Description | Example |
|---|---|---|---|
project_name |
string | Name of the project that will appear in the generated documentation. | project_name: "Auto Doc Generator" |
language |
string | Language code for the documentation (default en). | language: "en" |
project_settings |
mapping | Settings that affect the documentation generation process. | project_settings: |
project_additional_info |
mapping | Arbitrary key‑value pairs that are added to the project information section. | project_additional_info: |
ignore_files |
list of strings (optional) | Glob patterns for files/folders that should be ignored during scanning. If omitted the default list from Config is used. |
ignore_files: |
custom_descriptions |
list of strings | Custom textual descriptions that will be turned into modules by the generator. Each entry is processed as a CustomModule. |
custom_descriptions: |
Typical structure
project_name: "My Project"
language: "en"
project_settings:
save_logs: true
log_level: 2
project_additional_info:
description: "Short description of the project"
author: "Your Name"
ignore_files:
- "*.md"
- "docs/**"
custom_descriptions:
- "First custom description"
- "Second custom description"
📦 autodocgenerator package initialisation
The autodocgenerator/__init__.py file is executed on every import of the ADG library.
Its sole responsibilities are:
- Signal successful import – the
print("ADG")statement writes a short banner to stdout (useful during debugging or when the package is invoked as a script). - Expose a ready‑to‑use logger – it imports the concrete logging classes from
autodocgenerator.ui.loggingand creates a module‑levelloggerinstance:logger = BaseLogger() logger.set_logger(BaseLoggerTemplate())
This singleton is shared across the entire code‑base, so any sub‑module can simplyfrom autodocgenerator import loggerand emitInfoLog,WarningLogorErrorLogmessages without configuring a logger themselves.
Interaction with the rest of the system
- UI → Engine → Factory components all import
loggerto report progress, configuration problems, or fatal errors. - The logger respects the global settings defined in
autodocconfig.yml(e.g.,save_logsandlog_level) becauseBaseLoggerTemplatereads those values during its own initialisation.
Assumptions & side‑effects
- The environment must have the
autodocgenerator.ui.loggingmodule available; otherwise anImportErroraborts package loading. - The
printside‑effect writes to standard output every time the package is imported – in production pipelines this can be silenced by redirecting stdout or by removing the line.
Overall, this file provides a tiny but essential bootstrap: a consistent logger and a visual cue that the Auto Doc Generator library has been loaded.
autodocgenerator.auto_runner.config_reader – Configuration Bootstrap
This module translates autodocconfig.yml into runtime objects used throughout the generator.
-
ProjectConfigSettings– holds global logger flags (save_logs,log_level).load_settings()copies any YAML keys into the instance viasetattr. -
Config– central holder for:ignore_files– default file‑patterns excluded from scanning.language,project_name,project_additional_info.custom_modules– list ofCustomModuleobjects supplied by the user.pcs– an attachedProjectConfigSettings.
It supplies fluent setters (set_language,add_ignore_file, …) and two factories:get_project_settings()→ builds aProjectSettingsobject populated with extra info.get_doc_factory()→ creates the mainDocFactory(with custom modules) and an intro factory (IntroLinks, optionallyIntroText).
-
read_config(file_data: str) -> Config– parses the YAML, fills aConfiginstance, and returns it.- Reads
ignore_files,language,project_name,project_additional_info,project_settings, andcustom_descriptions. - Instantiates
CustomModulefor each user‑provided description.
- Reads
Interaction – All higher‑level components (run_file, Manager, factories) import Config to obtain:
- the ignore list passed to
Manager, - the
ProjectSettingsfor metadata, - the prepared
DocFactoryobjects, and - the logger configuration (
pcs).
Assumptions / Side‑effects
- The YAML file is syntactically correct; otherwise
yaml.safe_loadraises. CustomModuleaccepts a raw description dict.- No I/O is performed here – the caller must read the file (as
run_filedoes).
autodocgenerator.auto_runner.run_file – Execution Entrypoint
run_file.py glues the configuration, AI models, and generation pipeline together.
-
gen_doc(...) -> str- Instantiates
GPTModel(sync) andAsyncGPTModel(async) using the globalAPI_KEY. - Builds a
Managerwith project path,ProjectSettings,ProjectConfigSettings, the models, ignore list, aConsoleGtiHubProgressbar, and language. - Calls the manager’s stages in order:
generate_code_file– extracts source code snippets.generate_global_info_file– creates a high‑level overview (max 8 000 symbols).generete_doc_parts– produces modular doc chunks (max 5 000 symbols).factory_generate_doc– runs both the main and introDocFactoryobjects.clear_cache– removes temporary artefacts.
- Returns the assembled documentation via
manager.read_file_by_file_key("output_doc").
- Instantiates
-
__main__block – reads autodocconfig.yml, builds aConfigviaread_config, extractsProjectSettingsand factories, then callsgen_docand stores the result inoutput_doc.
Interaction –
- Relies on
Config(above) for all runtime parameters. - Uses the singleton
loggerfromautodocgenerator.ui.logging(imported but not explicitly called here; internalManagerand factories emit logs). - Progress is visualised through
ConsoleGtiHubProgress, a subclass ofBaseProgress.
Assumptions –
API_KEYis defined inengine.config.config.- Required packages (
rich,yaml, GPT model wrappers) are installed. - The current working directory is the project root (passed as
".").
Together, these two files form the bootstrap that reads user configuration, prepares AI back‑ends, and drives the full documentation generation pipeline.
autodocgenerator.engine.config.config – Prompt Templates & Global Settings
Responsibility
This module centralises all static prompt texts and runtime constants used by the AutoDoc generation pipeline. The strings (BASE_SYSTEM_TEXT, BASE_PART_COMPLITE_TEXT, BASE_INTRODACTION_CREATE_TEXT, BASE_INTRO_CREATE, BASE_SETTINGS_PROMPT) are injected into LLM calls to steer behaviour (e.g., step‑by‑step code analysis, documentation scaffolding, navigation‑tree creation).
Key Elements
| Symbol | Type | Purpose |
|---|---|---|
BASE_SYSTEM_TEXT |
str |
System‑level instruction for incremental code‑snippet analysis. |
BASE_PART_COMPLITE_TEXT |
str |
Template for the “write documentation” stage. |
BASE_INTRODACTION_CREATE_TEXT |
str |
Prompt that generates an executive navigation tree from Markdown links. |
BASE_INTRO_CREATE |
str |
Prompt for a full project overview (title, goal, core logic, etc.). |
BASE_SETTINGS_PROMPT |
str |
Prompt that establishes a persistent project knowledge base for later interactions. |
get_BASE_COMPRESS_TEXT(start, power) |
Callable[[int, int], str] |
Factory that builds a compression‑task prompt, scaling the allowed summary length (~start/power chars) and embedding a strict usage‑example skeleton. |
API_KEY |
str |
Obtained from environment (.env) – required by the GPT model wrappers. |
MODELS_NAME |
list[str] |
Default model identifiers the system can select from. |
Interaction with the System
- LLM factories / managers import these constants to build prompts for
GPTModel,AsyncGPTModel, and the variousDocFactoryobjects. read_config(in the configuration loader) does not use them directly, but the generatedConfigobject later supplies them to the pipeline viaManager.run_filepullsAPI_KEYandMODELS_NAMEto instantiate model wrappers before constructing theManager.
Assumptions & Side‑effects
- The
.envfile is present and definesAPI_KEY; otherwise an exception aborts start‑up. - Prompt strings are treated as raw literals – no runtime formatting occurs here.
get_BASE_COMPRESS_TEXTonly returns a formatted string; it does not perform any I/O.
Typical Usage Example
from autodocgenerator.engine.config.config import (
BASE_SYSTEM_TEXT,
get_BASE_COMPRESS_TEXT,
API_KEY,
MODELS_NAME,
)
# Build a compression prompt for a 5000‑char snippet, aiming for ~500‑char summary
compress_prompt = get_BASE_COMPRESS_TEXT(start=5000, power=10)
# Pass prompts to the LLM wrapper (pseudo‑code)
gpt = GPTModel(api_key=API_KEY, model_name=MODELS_NAME[0])
response = gpt.complete(system=BASE_SYSTEM_TEXT, user=compress_prompt)
ModelExhaustedException
ModelExhaustedException is a custom sentinel raised when the runtime‑selected list of model identifiers (regen_models_name) becomes empty. It propagates up to the calling factory or UI layer, signalling that no fallback LLM is available and that request processing must abort.
History
A lightweight container for the conversation payload sent to Groq.
- Constructor
History(system_prompt: str = BASE_SYSTEM_TEXT)– starts with an empty list and optionally injects the system prompt. - add_to_history(role, content) – appends a dict
{"role": role, "content": content}. - Interaction: Instances are shared with
Model/AsyncModelso every generated answer can be stored and later reused whenwith_history=True.
ParentModel
Base class that prepares common state for concrete model wrappers.
- Stores the API key, a
Historyobject, and an index (current_model_index). - Copies the global
MODELS_NAMElist, shuffles it whenuse_random=True, and exposes the ordered list asregen_models_name. - Assumption:
MODELS_NAMEcontains at least one valid Groq model identifier; otherwiseModelExhaustedExceptionwill be raised later.
Model (synchronous)
Derives from ParentModel and implements the high‑level public API used by the rest of the system.
generate_answer(with_history=True, prompt=None) → str– abstract placeholder overridden byGPTModel.get_answer_without_history(prompt)– convenience wrapper that forwards a raw message list directly togenerate_answer.get_answer(prompt)– records the user message, callsgenerate_answer(which uses history by default), stores the assistant reply, and returns it.- Side‑effects: Mutates
self.historyby appending user and assistant entries.
AsyncModel (asynchronous)
Mirrors Model but with async signatures, enabling non‑blocking UI or batch pipelines.
- Same three public helpers (
generate_answer,get_answer_without_history,get_answer) but allawaitable. - History handling is identical to the sync version.
GPTModel – concrete synchronous wrapper around Groq’s SDK.
- Instantiates
self.client = Groq(api_key=self.api_key)and aBaseLogger. - generate_answer
- Logs start.
- Picks
messagesfromself.historyor the suppliedprompt. - Loops over
regen_models_nametrying each model until a successfulchat.completions.createcall returns. - On failure logs a warning, advances
current_model_index, and retries; if the list empties, raisesModelExhaustedException. - Extracts
result = chat_completion.choices[0].message.content, logs it, and returns the string.
- Inputs:
with_historyflag, optional rawprompt. - Outputs: generated answer string.
- Side‑effects: logging, possible index mutation, no direct history mutation (handled by
Model.get_answer).
AsyncGPTModel – asynchronous counterpart of GPTModel.
- Uses
AsyncGroqclient and the same logging strategy. - The
generate_answercoroutine follows the identical retry logic, awaitingself.client.chat.completions.create. - Returns the answer string once the awaitable completes.
Interaction Overview
- Factory / UI creates a
GPTModelorAsyncGPTModel, passing the globalAPI_KEYand optionally a customHistory. - Callers invoke
get_answer/get_answer_without_history. - The wrapper builds the message payload, selects a model (randomised order), contacts Groq, logs each step, and returns the assistant response.
- If every candidate model fails,
ModelExhaustedExceptionbubbles up for graceful error handling.
BaseModule (abstract)
Defines the contract for all documentation‑generation plug‑ins.
- Responsibility – Provide a
generate(info, model)method that receives a parsed source‑code dictionary (info) and a concreteModel(sync or async) to query LLMs. - Interaction – Sub‑classes are instantiated by
DocFactoryand called sequentially. No side effects beyond returning a string fragment.
DocFactory
Orchestrates module execution and aggregates results.
- Constructor – Accepts any number of
BaseModuleinstances; stores them inself.modules. - generate_doc(info, model, progress) –
- Creates a sub‑task in the supplied
BaseProgressUI component. - Iterates over
self.modules, invokingmodule.generate(info, model). - Concatenates each fragment (
module_result) with double new‑lines. - Logs success and raw output via
BaseLogger. - Updates progress after each module and finally removes the sub‑task.
- Creates a sub‑task in the supplied
- Outputs – The full assembled documentation string.
- Side effects – UI progress updates, structured logging, no mutation of
infoormodel.
CustomModule (general‑purpose)
- Purpose – Produce a user‑defined description block.
- Inputs –
info["code_mix"](mixed source code),info["language"], and the constructor‑provideddiscriptiontext. - Logic – Splits the code into ≤ 7 000‑symbol chunks (
split_data), then callsgenerete_custom_discriptionwith the chunks, the LLMmodel, the custom description, and the target language. Returns the resulting markdown/HTML fragment.
- IntroLinks – Extracts every HTML anchor from
info["full_data"](get_all_html_links), prints the list (debug), and asks the LLM (get_links_intro) to compose a brief “quick‑links” section in the desired language. - IntroText – Requests a high‑level introduction for the project (
get_introdaction) based oninfo["global_data"]and the language.
Both modules return plain strings that are later stitched byDocFactory.
Manager – Orchestrator of the documentation pipeline
The Manager class is the central coordinator that ties together all preprocessing, LLM‑driven generation, post‑processing and UI‑feedback components of AutoDocGenerator. It receives a project path and configuration objects, prepares a cache directory, and exposes high‑level actions that are called by the CLI / UI.
Construction & state
def __init__(self,
project_directory: str,
project_settings: ProjectSettings,
pcs: ProjectConfigSettings,
sync_model: Model = None,
async_model: AsyncModel = None,
ignore_files: list = [],
language: str = "en",
progress_bar: BaseProgress = BaseProgress())
- Inputs – paths, settings, optional synchronous/asynchronous LLM wrappers, file‑ignore list, UI progress object.
- Side‑effects – creates
<project>/ .auto_doc_cacheif missing and configures a file logger (FileLoggerTemplate) that writes toreport.log. - Assumptions – at least one of
sync_model/async_modelis supplied;pcs.log_levelis a validlogginglevel.
Helper utilities
read_file_by_file_key(file_key)– opens a cached file (code mix, global info, output, logs) and returns its text.get_file_path(file_key)– builds an absolute path inside the cache folder usingFILE_NAMES.
Both helpers are used by every public method, ensuring a single source of truth for cache locations.
generate_code_file – building the raw source snapshot
- Logs start/end via
BaseLogger. - Instantiates
CodeMix(project_directory, ignore_files). - Calls
CodeMix.build_repo_content(target_path)which walks the repository, concatenates source files (respectingignore_files) and writes the result tocode_mix.txt. - Updates the UI progress bar.
Outputs: a plain‑text “code mix” file used by later stages.
generate_global_info_file – placeholder for project‑wide summary
Current implementation reads the previously generated code mix, then writes a stub ("ss") to global_info.md.
Intended flow (commented out) would:
- Split the code mix (
split_data) into ≤max_symbolschunks. - Choose
sync_modelorasync_model. - Call
compress_to_oneto let the LLM synthesize a high‑level description of the whole project.
The method also advances the progress bar.
generete_doc_parts – chunk‑wise documentation creation
- Reads
global_infoand the full code mix. - Depending on
use_async, runs eitherasync_gen_doc_parts(viaasyncio.run) orgen_doc_parts. Both functions:- Split the source into ≤
max_symbolspieces. - Prompt the LLM (sync or async) to produce module‑level docs.
- Return a concatenated markdown string.
- Split the source into ≤
- Writes the result to
output_doc.mdand updates the progress UI.
Outputs: a first‑pass documentation file containing generated sections for every code chunk.
factory_generate_doc – post‑processing with a DocFactory
- Loads
global_info, the currentoutput_doc, and the originalcode_mix. - Packages them into an
infodict (language,global_data,full_data,code_mix). - Logs a detailed start message, listing the concrete module classes contained in the supplied
DocFactory. - Calls
doc_factory.generate_doc(info, self.sync_model, self.progress_bar).- The factory runs a configurable pipeline of modules (e.g.,
IntroLinks,IntroText,CustomModule) that may add introductions, quick‑link sections, or custom markdown.
- The factory runs a configurable pipeline of modules (e.g.,
- Prepends the factory output to the existing documentation and rewrites
output_doc.md. - Updates the progress bar.
Side‑effects: modifies the final doc file and produces additional log entries.
clear_cache – optional log cleanup
If pcs.save_logs is False, removes report.log from the cache folder. No other files are touched.
Interaction diagram (textual)
[CLI/UI] → Manager
│
├─> CodeMix (preprocessor) → code_mix.txt
├─> split_data / compress_to_one (preprocessor) → global_info.md
├─> gen_doc_parts / async_gen_doc_parts (preprocessor) → output_doc.md
├─> DocFactory (factory) → IntroLinks, IntroText, CustomModule → enrich output_doc.md
└─> BaseLogger / BaseProgress → console & file logs
All heavy LLM calls are delegated to the Model/AsyncModel objects; the manager merely forwards them and handles I/O, logging and progress reporting.
This documentation covers the Manager component only; other modules (spliter, compressor, postprocess, UI) are described elsewhere.
CodeMix – repository‑wide source collector
Responsibility – Walk a project directory, filter out unwanted files/folders and emit a single code‑mix text file that contains a tree view of the repository followed by the raw contents of every kept file. This file is the primary input for later preprocessing (splitting, compression) and documentation generation stages.
Public API
| Member | Type / signature | Description |
|---|---|---|
__init__(self, root_dir=".", ignore_patterns=None) |
`root_dir: str | Path– base folder;ignore_patterns: list[str]` – glob patterns. |
should_ignore(self, path: Path) -> bool |
Returns True if path (relative to root_dir) matches any pattern (full path, basename, or any path component). |
|
build_repo_content(self, output_file="repomix-output.txt") |
Writes the mixed file. | 1️⃣ Emits “Repository Structure” with indented tree. 2️⃣ Inserts a separator line. 3️⃣ For each non‑ignored file writes <file path="…"> header and its UTF‑8 text (errors ignored). Logs ignored items at level 1. |
Interaction with the system
- Inputs – Physical files under
root_dir; optionalignore_patterns. - Outputs –
output_file(plain‑text “code‑mix”); log entries viaBaseLogger. - Consumers –
Manager.generate_global_info_file,Manager.generete_doc_parts, and any downstream component that expects a single mixed source file. - Side effects – File creation on disk, logging; no mutation of source files.
Assumptions & limits
- All source files are readable as UTF‑8 (binary files are filtered out by patterns).
- Ignoring is purely pattern‑based; complex VCS‑aware rules must be expressed as globs.
- The separator (
"="*20) marks the boundary for downstream splitters.
The ignore_list defined at module level provides sensible defaults (virtual envs, caches, compiled artefacts, markdown docs, etc.).
Compressor module – high‑level view
The compressor prepares source‑code chunks for downstream processing (e.g., global‑info generation). It reduces large texts by sending them to a LLM ( Model / AsyncModel ) with a system prompt derived from ProjectSettings and a configurable compress_power. The output is a shortened representation that still preserves structural clues.
Key functions
| Function | Responsibility | Main I/O | Side‑effects |
|---|---|---|---|
| compress | Build a three‑message prompt and obtain a single LLM answer. | data: str → str |
None (network call only). |
| compress_and_compare | Synchronously batch‑compress compress_power files, concatenate results, and report progress. | list[str] → list[str] (≈ len/ compress_power items) |
Updates BaseProgress. |
| async_compress | Same as compress but guarded by an asyncio.Semaphore and updates progress asynchronously. |
str → str (awaitable) |
None besides progress update. |
| async_compress_and_compare | Parallel version of compress_and_compare using a semaphore (default 4 workers). | list[str] → list[str] |
Progress sub‑task handling. |
| compress_to_one | Repeatedly compresses until a single aggregated string remains; switches to async mode if requested. | list[str] → str |
May invoke asyncio.run. |
| generate_describtions_for_code | Sends each compressed block to the LLM with a strict “describe API” prompt, collects markdown‑ready descriptions. | list[str] → list[str] |
Progress updates; no file I/O. |
Interaction with the rest of the system
- Inputs – Raw source‑code strings produced by the collector stage.
- Outputs – Compressed text blobs consumed by
Manager.generate_global_info_fileand later splitters; description strings fed to the doc‑generator stage. - Dependencies –
ProjectSettings.prompt(system context).get_BASE_COMPRESS_TEXT(template for compression intensity).BaseProgressfor UI feedback.- LLM model interfaces (
Model,AsyncModel).
The module is pure‑logic: it never writes files, only returns strings and updates the progress UI.
Assumptions & limits
- All incoming texts are UTF‑8 readable; binary artefacts must be filtered earlier.
- Compression quality is driven solely by compress_power (default 4) and the static prompt template – no VCS‑aware heuristics.
- Asynchronous workers are capped at four concurrent calls to avoid overwhelming the LLM endpoint.
Use this module when you need to shrink large codebases into a single “code‑mix” representation before documentation generation.
postprocess – Final‑stage documentation polishing
The postprocess module is the last step of the autodocgenerator pipeline.
After the raw “code‑mix” markdown has been created it extracts headings and
HTML anchors, asks the LLM to craft a short introduction that lists the
available sections, and optionally generates a custom description for a
user‑supplied topic.
Responsibility
- Parse markdown headers (
##) → generate Markdown‑compatible anchors. - Scan existing
<a name=…>tags → collect internal HTML links. - Build LLM prompts (using
BASE_INTRODACTION_CREATE_TEXT/BASE_INTRO_CREATE) and retrieve generated introductory text. - Provide a helper (
generete_custom_discription) that iteratively asks the model for a concise description until a non‑empty answer is obtained.
Interaction with the system
- Relies on the generic Model interface (
model.get_answer_without_history). - Uses configuration constants from
engine.config.config. - Emits progress information through
ui.logging.BaseLogger(InfoLog).
Key functions
| Function | Purpose | Input / Output |
|---|---|---|
generate_markdown_anchor(header:str) -> str |
Normalises a header to a GitHub‑style #anchor. |
Header text → #slug |
get_all_topics(data:str) -> tuple[list[str], list[str]] |
Finds every ## heading, returns titles and their markdown anchors. |
Full markdown → (titles, anchors) |
get_all_html_links(data:str) -> list[str] |
Extracts internal <a name=…> links (max 25 chars) and logs the count. |
Full markdown → list of #name |
get_links_intro(links:list[str], model:Model, language:str="en") -> str |
Calls the LLM to produce an introductory paragraph that enumerates the supplied links. | Links + model → generated text |
get_introdaction(global_data:str, model:Model, language:str="en") -> str |
Generates a generic introduction for the whole documentation block. | Full doc + model → intro |
generete_custom_discription(splited_data:str, model:Model, custom_description:str, language:str="en") -> str |
Loops over split fragments, asking the model for a strict description of a custom topic; stops on the first non‑empty answer. | Fragments + description + model → description or empty string |
Assumptions & side effects
- Input markdown uses
\n##for top‑level sections and<a name=…>for anchors. - The LLM is expected to respect the Strict Rules prompt; otherwise the
function may return
"!noinfo"or"No information found". - Logging is performed synchronously; no external state is mutated besides the logger.
This module therefore “tidies up” the generated documentation, making it navigable and providing human‑readable introductions before the final output is written to disk.
Data Splitting – split_data
Responsibility – Breaks a large source‑code string into chunks that respect max_symbols (≈ token limit of the LLM).
Interaction – Called by the orchestration functions (gen_doc_parts, async_gen_doc_parts) to produce the list splited_data.
Logic – Iteratively trims any chunk > 1.5 × max_symbols by inserting a half‑size slice, then packs the resulting pieces into split_objects while ensuring no object exceeds 1.25 × max_symbols.
Assumptions – Input is a plain‑text code dump; max_symbols is a positive integer.
Outputs – List[str] where each element is safe to send to the LLM.
Synchronous Part Documentation – write_docs_by_parts
Responsibility – Sends a single code chunk to the LLM and returns the generated markdown.
Interaction – Consumes Model.get_answer_without_history; receives the previous part’s output (prev_info) to maintain context.
Key Steps –
- Build a system‑prompt that forces the requested language and injects
BASE_PART_COMPLITE_TEXT. - Optionally append the previous documentation fragment.
- Append the user‑prompt containing the code part (twice, per original design).
- Strip surrounding triple‑backticks from the LLM answer.
Inputs –part: str,model: Model,global_info: str(currently unused), optionalprev_info,language.
Outputs – Cleaned documentation string for the part.
Asynchronous Part Documentation – async_write_docs_by_parts
Responsibility – Same as the sync version but runs concurrently under a semaphore.
Interaction – Uses AsyncModel.get_answer_without_history; calls update_progress after each LLM response.
Side Effects – Logs progress and may raise if the semaphore limit is exceeded.
Orchestration – gen_doc_parts / async_gen_doc_parts
Responsibility – Drives full‑document generation by:
- Splitting the whole code base (
split_data). - Serially (or concurrently) invoking the part‑generation helpers.
- Accumulating results, keeping a 3 000‑character tail (
result = result[-3000:]) to provide context for the next chunk. - Updating a
BaseProgresssub‑task for UI feedback.
Interactions – Relies on the logger (BaseLogger), progress bar, and the appropriate model interface.
Outputs – The complete documentation string for the supplied code base.
These components together enable the AutoDocGenerator to respect LLM token limits while producing coherent, language‑specific documentation in both synchronous and asynchronous pipelines.
AutoDocGenerator – UI & Setup Documentation
Logging subsystem (ui/logging.py)
- Responsibility – Provides a lightweight, extensible logging façade used throughout the generator (e.g., during parsing, model calls, file writes).
- Core classes
BaseLog: storesmessageand numericlevel;_log_prefixadds a timestamp.ErrorLog,WarningLog,InfoLog: overrideformat()to prepend severity tags.BaseLoggerTemplate: holds alog_levelfilter and routes logs toprint().FileLoggerTemplate: same API but appends formatted messages to a user‑specified file.BaseLogger(singleton): holds the activelogger_template;set_logger()swaps implementations,log()forwards toglobal_log()which respects the filter.
- Interaction – UI components (e.g.,
progress_base, CLI) callBaseLogger().log(ErrorLog(...)); the concrete template decides where the text ends up.
Progress subsystem (ui/progress_base.py)
- Responsibility – Visual feedback for multi‑step documentation generation, abstracted to allow Rich‑based or plain‑console rendering.
- Key abstractions
BaseProgress: defines the interface (create_new_subtask,update_task,remove_subtask).LibProgress: wraps arich.progress.Progressobject, creates a “General progress” task and optional sub‑tasks, advancing the appropriate bar on eachupdate_task().ConsoleTask: tiny helper that prints start and percentage updates.ConsoleGtiHubProgress: implementsBaseProgressusingConsoleTask; useful when Rich is unavailable (e.g., CI logs).
- Interaction – The main generation pipeline instantiates either
LibProgressorConsoleGtiHubProgressand calls the three interface methods as stages (parsing, model inference, file writing) progress.
install.ps1(PowerShell) andinstall.sh(Bash) create a GitHub‑Actions workflow (.github/workflows/autodoc.yml) and a minimalautodocconfig.yml.- They ensure the workflow directory exists, write static YAML content with proper escaping, inject the current folder name as
project_name, and confirm success via console output. - These scripts are the entry point for users to enable the AutoDocGenerator CI integration with a single command.
All components cooperate: the logger records events, the progress visualizer reflects the pipeline state, and the install scripts set up CI to run the generator automatically.
It looks like you’ve pasted the pyproject.toml file twice, but the request was to write documentation for a specific code fragment (the “last part” of the documentation that sets up the CI‑integration entry point).
Could you share the actual Python script / module you’d like documented (e.g., the install‑or‑setup script that prints the folder name as project_name and confirms success on the console)? Once I have that snippet I can produce the concise, linked documentation you need.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autodocgenerator-0.7.9.tar.gz.
File metadata
- Download URL: autodocgenerator-0.7.9.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f404a5f1e0175fc876a211d948b82da09ba34dd6115c06eab4e5e0aec2f5a2e9
|
|
| MD5 |
41c53906d79f406be0f661cfc99c6624
|
|
| BLAKE2b-256 |
30b4020df4efce5a1e66241b4bbf8c0ee1490173921d23281df2e37d1c69ff4f
|
File details
Details for the file autodocgenerator-0.7.9-py3-none-any.whl.
File metadata
- Download URL: autodocgenerator-0.7.9-py3-none-any.whl
- Upload date:
- Size: 35.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8121eaea14d35c67735fa8abec5e619c93f93f8d2f304c2e1031583932fed928
|
|
| MD5 |
e07e37e4b2c7a4f709d4e0c51194a763
|
|
| BLAKE2b-256 |
4cc39726077fabd8d5aa620fcf6acaf67f580a0f18710bca61851afbbf471e60
|