mix lazy_doc (LazyDoc v0.5.3)
View SourceMain functionality
The module Mix.Tasks.LazyDoc provides a Mix task for processing source files to extract and format documentation for Elixir modules and functions.
Description
It enables the extraction of documentation using AI to enhance the documentation generation process, verifying and formatting documentation as per specified requirements. It handles reading the source code, interacting with a provider for documentation prompts, and writing the results back in a structured format.
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.
Writes the formatted contents of an AST and comments to a specified file.
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.
Writes the formatted contents of an AST and comments to a specified file.
Parameters
- file - the name of the file where the formatted output will be written.
- ast - the abstract syntax tree that needs to be formatted.
- comments - any comments that should accompany the formatted AST.
Description
Formats the AST and comments as a string and writes it to the specified file.