This Project helps you to create docs for your projects
Project description
Executive Navigation Tree
- 📂 Configuration
- ⚙️ AutoDoc Generator
- 📄 Documentation
- 🤖 Technical Details
- 📈 Utilities
- 📦 Installation
To install the workflow, you should use the following links:
For PowerShell, use irm https://raw.githubusercontent.com/Drag-GameStudio/ADG/main/install.ps1 | iex.
For Linux-based systems, use curl -sSL https://raw.githubusercontent.com/Drag-GameStudio/ADG/main/install.sh | bash.
Additionally, you need to add a secret variable to your GitHub Action, GROCK_API_KEY, with your API key from Grock Docs (https://grockdocs.com) to make it work.
To use the Manager class, you need to provide the following parameters:
- project_path: the path to the project
- project_settings: an instance of ProjectSettings
- pcs: an instance of ProjectConfigSettings
- sync_model: an instance of GPTModel
- async_model: an instance of AsyncGPTModel
- ignore_files: a list of files to ignore
- progress_bar: an instance of a progress bar class (in this case, ConsoleGtiHubProgress)
- language: the language to use (in this case, "en")
Here is an example of usage:
sync_model = GPTModel(API_KEY, use_random=False)
async_model = AsyncGPTModel(API_KEY)
manager = Manager(
project_path=".",
project_settings=project_settings,
pcs=pcs,
sync_model=sync_model,
async_model=async_model,
ignore_files=ignore_list,
progress_bar=ConsoleGtiHubProgress(),
language="en"
)
You can then call various methods on the manager instance, such as:
manager.generate_code_file()
manager.generate_global_info_file(use_async=False, max_symbols=8000)
manager.generete_doc_parts(use_async=False, max_symbols=6000)
manager.factory_generate_doc(doc_factory)
manager.order_doc()
manager.factory_generate_doc(intro_factory)
The autodocconfig.yml file has the following available options:
- project_name: the name of the project
- language: the language of the project (default is "en")
- project_settings:
- save_logs: whether to save logs (default is False)
- log_level: the level of logs (default is -1)
- project_additional_info: additional information about the project, where the key and value are both strings
- custom_descriptions: a list of custom descriptions, where each description is a string. These options are used to configure the Auto Doc Generator.
AutoDoc Generator Component
The AutoDoc Generator is a tool designed to automate the process of generating documentation for projects.
Component Responsibility
This component is responsible for creating and maintaining documentation for a given project, utilizing a configuration file (autodocconfig.yml) to guide the documentation generation process.
Interactions
The AutoDoc Generator interacts with the project's repository, utilizing GitHub Actions to automate the documentation generation process. It also relies on the autodocconfig.yml file for configuration settings.
Technical Details
Key functions and classes in this component include:
autodocgenerator.auto_runner.run_file: The main entry point for the documentation generation process.autodocgenerator.engine.config.config.py: Handles configuration settings for the generator.autodocgenerator.factory.base_factory.py: Provides a base factory for creating documentation components.autodocgenerator.ui.logging.py: Offers logging functionality for the generator.
Data Flow
The data flow for this component involves:
- Input: The
autodocconfig.ymlfile, which provides configuration settings for the generator. - Processing: The generator uses the configuration settings to create documentation for the project.
- Output: The generated documentation is saved as a Markdown file (
README.md) in the project's repository. - Side Effects: The generator also creates log files (
agd_report.txt) to track any issues during the documentation generation process.
Configuration Settings
The autodocconfig.yml file contains the following configuration settings:
project_name: The name of the project being documented.language: The language used for the documentation.project_settings: Additional settings for the project, such as log level and save logs.custom_descriptions: Custom descriptions for the project, including installation instructions and usage examples.
Autodoc Generator Architecture
The Autodoc generator is a complex system composed of multiple components.
Configuration Parsing
The provided code snippet is responsible for parsing configuration files for the auto documentation generator.
Config Class
The Config class is used to store configuration settings. It has the following properties:
ignore_files: a list of file patterns to ignorelanguage: the language used for documentationproject_name: the name of the project being documentedproject_additional_info: additional information about the projectcustom_modules: a list of custom modulespcs: project configuration settings
The Config class also has methods to set these properties and to get project settings and a document factory.
Reading Configuration
The read_config function reads configuration from a YAML file and returns a Config object. It parses the following settings:
ignore_fileslanguageproject_nameproject_additional_infoproject_settingscustom_descriptions
ProjectConfigSettings Class
The ProjectConfigSettings class is used to store project configuration settings. It has the following properties:
save_logs: whether to save logslog_level: the log level
The ProjectConfigSettings class also has a method to load settings from a dictionary.
Document Generation
The gen_doc function generates documentation for a project. It uses the following parameters:
project_settings: project settingspcs: project configuration settingsignore_list: a list of files to ignoreproject_path: the path to the projectdoc_factory: a document factoryintro_factory: an intro factory
The gen_doc function generates code files, global info files, and documentation parts, and then orders and generates the final documentation.
Main Function
The main function reads the configuration from the autodocconfig.yml file, generates documentation, and prints the output.
Project Configuration
The project configuration is defined in the pyproject.toml file. This file specifies the project's dependencies, version, and other metadata.
Installation Scripts
The installation scripts (install.ps1, install.sh) are used to set up the Autodoc generator. They create the necessary directories and files, including the .github/workflows/autodoc.yml file and the autodocconfig.yml file.
Documentation Generation
The documentation generation module is responsible for generating documentation for a given code snippet. This module utilizes the Model and AsyncModel classes to generate documentation.
Data Splitting
The split_data function splits the input data into smaller parts based on the max_symbols parameter. This is done to prevent excessive data from being processed at once.
Documentation Generation by Parts
The gen_doc_parts function generates documentation for each part of the split data. It uses the write_docs_by_parts function to generate documentation for each part and then combines the results.
Asynchronous Documentation Generation
The async_gen_doc_parts function generates documentation asynchronously using the async_write_docs_by_parts function. This allows for multiple parts to be processed concurrently, improving performance.
Technical Details
The documentation generation module uses the following key functions and classes:
split_data: Splits the input data into smaller parts based on themax_symbolsparameter.write_docs_by_parts: Generates documentation for a single part of the split data.gen_doc_parts: Generates documentation for all parts of the split data.async_write_docs_by_parts: Generates documentation for a single part of the split data asynchronously.async_gen_doc_parts: Generates documentation for all parts of the split data asynchronously.
Usage Example
full_code_mix = "This is a sample code snippet."
global_info = "This is a sample global information."
max_symbols = 1000
model = Model()
language = "en"
progress_bar = BaseProgress()
result = gen_doc_parts(full_code_mix, global_info, max_symbols, model, language, progress_bar)
Custom Introduction Generation
The custom introduction generation module is responsible for extracting HTML links from documentation, generating introductions with links, and creating custom descriptions.
Functionality
The module consists of four main functions:
get_all_html_links: Extracts HTML links from a given documentation string.get_links_intro: Generates an introduction with links using a provided model and language.get_introdaction: Creates an introduction based on global data, a model, and a language.generete_custom_discription: Generates a custom description for a given code or documentation snippet.
Interactions
The custom introduction generation module interacts with the following components:
GPTModel: For generating introductions and custom descriptions.Model: For generating introductions and custom descriptions.BaseLogger: For logging information and warnings.
Data Flow
- Input: The module takes in documentation strings, models, languages, and custom description requests.
- Output: The module generates introductions with links, custom descriptions, and logs information and warnings.
- Side Effects: The module updates the log with information and warnings.
Technical Details
The module uses regular expressions to extract HTML links from documentation strings. It also utilizes the GPTModel and Model classes to generate introductions and custom descriptions.
Usage Example
links = get_all_html_links(doc_string)
intro = get_links_intro(links, model, language="en")
custom_description = generete_custom_discription(code_snippet, model, custom_description_request)
Usage Example
To use the Autodoc generator, simply run the installation script and follow the prompts. Once the Autodoc generator is set up, you can use it to generate documentation for your project.
# Create a new logger
logger = BaseLogger()
# Set the logger template
logger.set_logger(FileLoggerTemplate("log.txt"))
# Log a message
logger.log(InfoLog("This is an info message"))
Technical Details
The Autodoc generator uses a variety of technologies, including Python, YAML, and Markdown. It also uses several libraries, including pyyaml, anyio, and rich.
GPT Model Implementation
Purpose
The GPT model implementation is designed to handle the generation of answers using the GPT model. It includes two classes: AsyncGPTModel and GPTModel, which inherit from AsyncModel and Model respectively.
Technical Details
The AsyncGPTModel and GPTModel classes are defined in the autodocgenerator\engine\models\gpt_model.py file. They utilize the Groq and AsyncGroq clients to interact with the GPT model. The logger attribute is used to log information, warnings, and errors.
Interactions
The GPT model implementation interacts with the ModelExhaustedException class to handle situations where no models are available for use. It also interacts with the History class to store and retrieve conversation history.
Data Flow
- Input: The
generate_answermethod takes inwith_historyandpromptparameters. - Output: The method returns the generated answer as a string.
- Side Effects: The method updates the conversation history and logs information, warnings, and errors.
Usage Example
gpt_model = AsyncGPTModel()
try:
answer = await gpt_model.generate_answer(with_history=True, prompt="Hello, how are you?")
print(answer)
except ModelExhaustedException as e:
print(f"Error: {e}")
Data Flow
The data flow of the Autodoc generator involves the following steps:
- The user runs the installation script to set up the Autodoc generator.
- The Autodoc generator reads the project's configuration from the
pyproject.tomlfile. - The Autodoc generator uses the
BaseLogandBaseLoggerTemplateclasses to handle logging. - The Autodoc generator uses the
BaseProgressclass to track progress. - The Autodoc generator generates documentation based on the project's configuration and code.
Model Exception Handling
Purpose
The ModelExhaustedException class is designed to handle situations where none of the models in the predefined list are available for use.
Technical Details
This custom exception is defined in the autodocgenerator\engine\exceptions.py file. It inherits from the base Exception class, allowing it to be used as a specific error type in the code.
Interactions
The ModelExhaustedException is expected to be raised when the code attempts to utilize a model from the MODELS_NAME list, but none are available. This could be due to various reasons such as the models being offline, not properly configured, or exceeding usage limits.
Data Flow
- Input: The exception is triggered by the unavailability of models.
- Output: The exception is raised, indicating that no suitable model is available.
- Side Effects: The program's execution is halted until the exception is handled, potentially leading to a restart or alternative model selection.
Usage Example
try:
# Attempt to use a model from the list
for model_name in MODELS_NAME:
# Model usage logic here
pass
# If no model is available, raise the exception
raise ModelExhaustedException("No model is available for use.")
except ModelExhaustedException as e:
# Handle the exception, e.g., log the error and notify the user
print(f"Error: {e}")
Compressor Module
The compressor module is responsible for compressing and comparing data using a provided model and project settings.
Compressor Functions
The compressor module contains the following key functions:
compress: Compresses a given string of data using a provided model and project settings.compress_and_compare: Compresses and compares a list of data using a provided model and project settings.async_compress: Asynchronously compresses a given string of data using a provided model and project settings.async_compress_and_compare: Asynchronously compresses and compares a list of data using a provided model and project settings.compress_to_one: Compresses a list of data to a single string using a provided model and project settings.generate_discribtions_for_code: Generates descriptions for a list of code using a provided model and project settings.
Data Flow
- Input: The compressor module takes in data, models, project settings, and progress bars.
- Output: The compressor module generates compressed data, descriptions, and logs information and warnings.
- Side Effects: The compressor module updates the log with information and warnings.
Technical Details
The compressor module uses the GPTModel and AsyncModel classes to compress and compare data. It also utilizes the ProjectSettings class to store project information and generate prompts for the model.
Usage Example
project_settings = ProjectSettings("My Project")
data = ["This is a test string", "This is another test string"]
compressed_data = compress_to_one(data, model, project_settings)
Logging Mechanism
The logging mechanism is handled by the BaseLog class and its subclasses (ErrorLog, WarningLog, InfoLog). These classes define the structure of log messages, including a timestamp and a message.
Logger Templates
The BaseLoggerTemplate class and its subclasses (FileLoggerTemplate) define how log messages are handled. The BaseLogger class is a singleton that provides a global logging interface.
Progress Tracking
The progress tracking mechanism is handled by the BaseProgress class and its subclasses (LibProgress, ConsoleGtiHubProgress). These classes define how progress is tracked and updated.
Manager Class
Purpose
The Manager class is responsible for orchestrating the documentation generation process, including code mixing, global information generation, documentation generation, and post-processing.
Technical Details
The Manager class is defined in the autodocgenerator\manage.py file and utilizes various modules, such as CodeMix, DocFactory, and ProjectSettings, to perform its tasks. It also interacts with the GPTModel and AsyncGPTModel classes for documentation generation.
Interactions
The Manager class interacts with the following components:
CodeMix: for code mixing and generating the code mix fileDocFactory: for generating documentation using the factory approachGPTModelandAsyncGPTModel: for documentation generationProjectSettingsandProjectConfigSettings: for project configuration and settings
Data Flow
- Input: The Manager class takes in project directory, project settings, and other parameters.
- Output: The Manager class generates various files, including the code mix file, global information file, and output documentation file.
- Side Effects: The Manager class updates the cache folder, logs information, warnings, and errors, and clears the cache if necessary.
Usage Example
manager = Manager(project_directory="/path/to/project", project_settings=ProjectSettings(),
pcs=ProjectConfigSettings(), sync_model=GPTModel(), async_model=AsyncGPTModel())
manager.generate_code_file()
manager.generate_global_info_file()
manager.generete_doc_parts()
manager.factory_generate_doc(DocFactory())
manager.order_doc()
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.8.4.tar.gz.
File metadata
- Download URL: autodocgenerator-0.8.4.tar.gz
- Upload date:
- Size: 24.9 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 |
96f83721fe116baab96b116d38af0316699b62f4f9eab6dff6704b49259e7752
|
|
| MD5 |
b2448c96e1a1b616e5fee9ba3e7cdd6b
|
|
| BLAKE2b-256 |
65f4dff84e862f4e96bdf29f7cf66534868042df4f03e2a01aebedc28a6b850d
|
File details
Details for the file autodocgenerator-0.8.4-py3-none-any.whl.
File metadata
- Download URL: autodocgenerator-0.8.4-py3-none-any.whl
- Upload date:
- Size: 27.9 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 |
cb673a23e86db2e6e597056c5bb05f5cd27ac06cfd19b802213b012e8888e3f5
|
|
| MD5 |
e4bbc5f204ed29454d9e37befffb8729
|
|
| BLAKE2b-256 |
91e3ae85916429842988f9cc562320a065f3d81ca1a7b101e5934e44b5dfa079
|