This pull request adds a protection against accidental overwriting of the output directory.
Why this?
Previously, using a non-empty output directory could lead to an inconsistent state of it: When you generated the documentation, changed some code, and generated it again, the documentation directory could include some old files which are not included in the new documentation version (e. g. because a module was renamed). That is why a protection is important: Either the output directory is completely emptied first and the documentation is generated, or an error that the directory is not empty occurs.
Summary
DirectoryNotEmptyError exception class (handled by CLI)
core functionality: added force argument to the Python documentation generator method and tests
# Accidental output directory overwriting protection
This pull request adds a protection against accidental overwriting of the output directory.
## Why this?
Previously, using a non-empty output directory could lead to an inconsistent state of it: When you generated the documentation, changed some code, and generated it again, the documentation directory could include some old files which are not included in the new documentation version (e. g. because a module was renamed). That is why a protection is important: Either the output directory is completely emptied first and the documentation is generated, or an error that the directory is not empty occurs.
## Summary
- `DirectoryNotEmptyError` exception class (handled by CLI)
- core functionality: added `force` argument to the Python documentation generator method and tests
- CLI option (`-f`, `--force`) and tests
- changelog entry
## Related issues
Closes #33
jakob.scheid
added this to the 0.2.0 milestone 2026-09-27 21:17:25 +02:00
Added a force argument to
PythonDocumentationGenerator.generate_documentation to control whether
the content of the output directory should be overwritten or not, if it
is not empty. If the force argument is True, the output directory
content will first be deleted recursively. If it is False and the output
directory is not empty, a DirectoryNotEmptyError will be raised.
Added tests to test new output directory deletion behavior:
- output directory overwriting (not empty; force)
- error (not empty; not force)
- nothing (empty; force)
- nothing (empty; not force)
One test was adapted to output directory emptiness check because the
.gitkeep file which is required for Git to track the directory makes it
non-empty.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Accidental output directory overwriting protection
This pull request adds a protection against accidental overwriting of the output directory.
Why this?
Previously, using a non-empty output directory could lead to an inconsistent state of it: When you generated the documentation, changed some code, and generated it again, the documentation directory could include some old files which are not included in the new documentation version (e. g. because a module was renamed). That is why a protection is important: Either the output directory is completely emptied first and the documentation is generated, or an error that the directory is not empty occurs.
Summary
DirectoryNotEmptyErrorexception class (handled by CLI)forceargument to the Python documentation generator method and tests-f,--force) and testsRelated issues
Closes #33