docstripy API#
docstripy.difference#
Classes and functions to manage difference between files.
- satenize_ranges(ranges, to_insert_list)#
Check if the ranges are overlapping.
- order_lists(ranges, lines, to_insert)#
Order the ranges in descending order and lines accordingly.
- apply_diff(ranges, lines, old_lines, *, to_insert=False)#
Apply the difference to a list of lines.
- Parameters:
ranges (List[List[int]]) – List of ranges of docstring line numbers [start, end]. Includes line at start, excludes line at end.
lines (List[str]) – List of lines to add to the file.
old_lines (List[str]) – List of lines of the original file.
to_insert (Union[bool, List[bool]], optional) – Whether to insert the lines or overwrite them instead. If a list is given, it should have the same length as ranges. Otherwise, the same value will be used for all ranges. By default, False.
- Return type:
docstripy.file_parser#
File parsing functions.
- parse_ranges(lines)#
Parse source code lines ranges.
- docstring_parse_range(line, ind_line, states)#
Parse docstring lines range from source code.
- Return type:
- is_def_line(strip_line)#
Return whether the line is a function or class definition.
- Return type:
docstripy.line_break#
Line break function.
- line_break(lines, max_line_length, num_add_char=0)#
Break lines at a given length.
docstripy.lines_routines#
Routines on code source lines.
- find_prefix(lines, prefix_start, prefix_continue, *, dash=False)#
Find the index of consecutive lines starting with prefix.
- Parameters:
- Return type:
- Returns:
start (int) – Index of the first line (or -1 if not found).
end (int) – Index of the last line (or -1 if not found).
- remove_quotes(lines)#
Remove triple quotes and return whether the docstring is escaped or not.
docstripy.main#
Main functions for parsing and building docstrings.
docstripy.write#
Main functions for parsing and building docstrings.
- generate_new_file(file_lines, docstr_config)#
Generate new file with the updated docstrings.
- write_file_py(in_path, out_path, *, overwrite, docstr_config)#
Write new docstrings on a file.
- Return type:
- write_file_ipynb(in_path, out_path, *, overwrite, docstr_config)#
Write new docstrings on a file.
- Return type:
- write_files_recursive(in_path, out_path, *, overwrite, docstr_config)#
Write new docstrings on all files in a folder.
- Return type: