Commands
write_the_tests(filename, model='gpt-3.5-turbo-instruct')
async
Formats and runs the tests for a given file using a specified model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
Path
|
The path to the file to be tested. |
required |
model |
str
|
The model to use for the generation. Defaults to "gpt-3.5-turbo-instruct". |
'gpt-3.5-turbo-instruct'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The formatted and tested code. |
Examples:
Note
This function is asynchronous and should be awaited when called.
Source code in write_the/commands/tests/tests.py
write_the_converters(filename, input_format, output_format, model='gpt-3.5-turbo-instruct')
async
Formats and runs the tests for a given file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
Path
|
The path to the file to be tested. |
required |
input_format |
str
|
The input format of the file. |
required |
output_format |
str
|
The format to convert the file to. |
required |
model |
str
|
The model to use for conversion. Defaults to "gpt-3.5-turbo-instruct". |
'gpt-3.5-turbo-instruct'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The converted output. |
Examples:
>>> write_the_converters(Path(".travis.yml"), input_format="Travis CI", output_format="Github Actions", model="gpt-3.5-turbo-instruct")
"The converted output"
Source code in write_the/commands/converters/converters.py
write_the_docs(tree, node_names=[], update=False, force=False, save=False, context=False, background=True, pretty=False, max_batch_size=False, model='gpt-3.5-turbo-instruct')
async
Generates docstrings for a given tree of nodes using a specified model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree |
cst.Module
|
The tree of nodes to write docs for. |
required |
node_names |
list
|
The list of nodes names to write docs for. Defaults to an empty list. |
[]
|
update |
bool
|
Whether to update existing docstrings. Defaults to False. |
False
|
force |
bool
|
Whether to force writing of docs. Defaults to False. |
False
|
save |
bool
|
Whether to save the docs. Defaults to False. |
False
|
context |
bool
|
Whether to include context nodes. Defaults to False. |
False
|
background |
bool
|
Whether to run the process in the background. Defaults to True. |
True
|
pretty |
bool
|
Whether to format the code. Defaults to False. |
False
|
max_batch_size |
bool
|
Max number of nodes in each batch. Defaults to False. |
False
|
model |
str
|
The model to use for the generation. Defaults to "gpt-3.5-turbo-instruct". |
'gpt-3.5-turbo-instruct'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The source code with the generated docstrings. |
Raises:
Type | Description |
---|---|
FileSkippedError
|
If no nodes are found. |
Notes
If node_names
is provided, force
is set to True
and context
is set to False
.
Examples:
>>> write_the_docs(tree, model="gpt-3.5-turbo-instruct")
"def add(a, b):
"""Sums 2 numbers.
Args:
a (int): The first number to add.
b (int): The second number to add.
Returns:
int: The sum of `a` and `b`.
"""
return a + b"
Source code in write_the/commands/docs/docs.py
process_nodes(tree, nodes, context, extract_specific_nodes)
Processes a tree of nodes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tree |
cst.Module
|
The tree of nodes to process. |
required |
nodes |
list
|
The list of nodes to process. |
required |
context |
bool
|
Whether to include context nodes. |
required |
extract_specific_nodes |
bool
|
Whether to extract specific nodes. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The processed tree as a string. |
Examples:
Source code in write_the/commands/docs/utils.py
write_the_mkdocs(code_dir, readme=None, out_dir=Path('.'), project_name=None)
Generates a mkdocs project from a directory of python files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
code_dir |
Path
|
The directory containing the python files. |
required |
readme |
Path
|
The readme file to include in the project. Defaults to None. |
None
|
out_dir |
Path
|
The directory to write the project to. Defaults to the current directory. |
Path('.')
|
project_name |
str
|
The name of the project. Defaults to the name of the code_dir. |
None
|
Notes
If readme is not provided, the project will not have a home page. If project_name is not provided, the project will be named after the code_dir.
Side Effects
Creates a mkdocs project in the out_dir. Creates a .github/workflows/mkdocs.yml file in the out_dir.
Returns:
Type | Description |
---|---|
None |