mix lazy_doc (LazyDoc v0.6.2)
View SourceThe module Mix.Tasks.LazyDoc provides a Mix task for generating and inserting documentation into Elixir modules using an AI-powered provider.
Description
It orchestrates the extraction of data from source files, interacts with a specified AI provider to produce documentation for both modules and functions, and writes the generated documentation back into the respective source files. The task ensures necessary configurations such as tokens and provider parameters are validated before proceeding with the documentation generation process. Additionally, it handles file writing operations in a formatted manner and maintains the structure of the Elixir AST while inserting documentation comments.
Summary
Functions
Returns true if the provided docs are formatted correctly according to the specified criteria.
Returns the modified Abstract Syntax Tree (AST) corresponding to the documentation provided.
Returns the updated AST after inserting the documentation for the specified function.
Returns the modified AST with the documentation for the specified module inserted.
Returns the updated abstract syntax tree after inserting documentation nodes for specified functions in the given module.
Returns the processed files based on the provided entries.
Returns the result of starting necessary applications and processing files based on the provided command line arguments.
Returns the result of writing the abstract syntax tree (AST) to a specified file.
Returns the formatted content written to a file and compiles it if the write operation is successful.
Functions
Returns true if the provided docs are formatted correctly according to the specified criteria.
Parameters
- docs - a binary string containing the documentation text to be validated.
Description
Checks if the documentation is correctly formatted with either a single line or a multi-line block.
Returns the modified Abstract Syntax Tree (AST) corresponding to the documentation provided.
Parameters
- docs - the documentation string to be converted into an AST.
- acc_ast - the accumulator AST that will be updated.
- module_ast - the AST of the module where the documentation will be inserted.
Description
Converts a documentation string into an Elixir AST and integrates it into the module's AST.
Returns the updated AST after inserting the documentation for the specified function.
Parameters
- ast - the abstract syntax tree of the module.
- name_func - the name of the function for which documentation is being added.
- ast_doc - the documentation to be inserted into the function.
- module_ast - the abstract syntax tree representation of the module.
Description
Traverses the AST and inserts documentation for the specified function within the specified module.
Returns the modified AST with the documentation for the specified module inserted.
Parameters
- ast - the abstract syntax tree representing the original code.
- module_ast - the abstract syntax tree of the module where documentation is to be inserted.
- ast_doc - the documentation to be inserted into the module's AST.
Description
Modifies the module's AST to include documentation by traversing the original AST.
Returns the updated abstract syntax tree after inserting documentation nodes for specified functions in the given module.
Parameters
- module - atom representing the module name.
- module_ast - the abstract syntax tree of the module.
- functions - a list of functions for which documentation needs to be inserted.
- final_prompt - the final prompt to use for generating documentation.
- provider_mod - the module responsible for making the request to the provider.
- model_text - the text model to be used in the request.
- token - authentication token for the provider.
- params - additional parameters for the request.
- acc - an accumulator that holds the current state of the abstract syntax tree.
Description
Handles the insertion of documentation nodes by leveraging an external documentation provider and integrates the results into the module's AST.
Returns the processed files based on the provided entries.
Parameters
- entries - a list of entries containing module and function information.
Description
Processes each entry, generating documentation and writing it to the respective files.
Returns the result of starting necessary applications and processing files based on the provided command line arguments.
Parameters
- _command_line_args - the command line arguments provided to the application.
Description
Initiates the required applications and processes the files accordingly.
Returns the result of writing the abstract syntax tree (AST) to a specified file.
Parameters
- file - the path to the file where the AST will be written.
- ast - the abstract syntax tree that will be converted to a string and written to the file.
Description
Writes the string representation of the given AST to the specified file.
Returns the formatted content written to a file and compiles it if the write operation is successful.
Parameters
- file - the path to the file where the content will be written.
- compile_path - the path where the compiled output will be saved.
- ast - the abstract syntax tree that represents the code to format.
- comments - any comments associated with the code that will be included in the output.
Description
Handles file writing and formatting operations, including compilation of the file.