cleandoc
Description
Python package leveraging doq, black, pylint, mypy and sphinx to automatically clean and document python code.
Install
pip install cleandoc
Usage
Command Line Usage
cleandoc [-h] [-file FILE] [-dir DIR] [-write] [-ignore] [-noclean] [-nodoc] [-release]
optional arguments:
- -h, --help
- show this help message and exit
- -file FILE,-f FILE
- Python (.py) file to clean
- -dir DIR, -d DIR
- Directory containing Python (.py) files to clean and/or document
- -write, -w
- Flag to write changes to files in-place
- -ignore, -i
- Flag to continue through warnings
- -noclean, -nc
- Flag to prevent cleaning of py files
- -nodoc, -nd
- Flag to prevent html doc creation
- -release RELEASE, -r RELEASE
- Release or version number of documentation (X.Y.Z)
Python In-Line Usage
- Example below can be ran as a standalone code example
- Example includes standard Python packages shutil, os, and webbrowser
- In-line usage of cleandoc is shown when calling "cd."
- Recommended use case is running "cleandoc_all" on your python module folders
# -*- coding: utf-8 -*-
# Pylint will be mad because there is no script docstring
import shutil
import webbrowser
import cleandoc as cd
import os # this import should be before cleandoc, pylint will complain
def example_fxn_1()->str:
"""
Set a variable that get flagged by Pylint
"""
ISSUE_2 = 0 # pylint complains because variables in functions should be snake or lowercase
ISSUE_2 = "setting a previous int to a string now. Mypy will complain"
return ISSUE_2
if __name__=="__main__":
# Create nested source file folder and copy in this script
maindir = os.path.dirname(os.path.abspath(__file__))
srcpath = os.path.join(maindir, "src")
os.mkdir(srcpath)
dirpath = os.path.join(srcpath, "readme_test")
os.mkdir(dirpath)
scriptpath = os.path.join(maindir, "src", "readme_test", os.path.basename(os.path.abspath(__file__)))
shutil.copyfile(os.path.abspath(__file__), scriptpath)
print("\n\n>>> Cleaning One Python File <<<\n")
cd.clean_pyfile(scriptpath, write=True)
print("\n\n>>> Cleaning All Python Files in Directory <<<\n")
cd.clean_all(dirpath, ignore=True, write=False, skip=True)
print("\n\n>>> Cleaning All and Generating HTML Docs <<<\n")
try:
# Below line runs clean_all and gen_docs functions
# Raises a syntax warnings because ignore=False, so docs are not generated
cd.cleandoc_all(dirpath, ignore=False, write=True, release="0.0.1")
except SyntaxWarning as error:
print(f"syntax warning:\n\n{error}")
print("\n\n>>> Generating HTML Documents with Sphinx <<<\n")
webpage = cd.gen_docs(dirpath, changed=True, release="0.0.1")
issue_1 = "This string line is way too long. Why did you need to type this all in one line? Black is going to try to shorten this and pylint will complain. Pylint also complains because constaints in main script should be all uppercase."
ISSUE_2 = example_fxn_1()
ISSUE_3 = ["really","long","list","so","black","reformats","it","and","turns","the","one","line","list","into","multi","line"]
# Delete src folder created at begining of script
shutil.rmtree(srcpath)
webbrowser.open(webpage)
Read The Docs
Download "docs" folder or check preview.
Contributing
Message me on Github.
License
Copyright:
(c) 2023, Jason Krist
Metadata
Release files for cleandoc 0.0.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cleandoc-0.0.14.tar.gz | 26.2 kB | Without provenance | Details for cleandoc-0.0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cleandoc-0.0.14-py3-none-any.whl | Python 3 | none | any | Details for cleandoc-0.0.14-py3-none-any.whl |
Total release size: 52.9 kB
Release files / cleandoc-0.0.14.tar.gz
| Download URL | cleandoc-0.0.14.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b65d1e07e129a1503ba0885358b66d8e47684bcb1dafa886534c377422f8dbd
|
|
BLAKE2b-256 checksum How to use checksums |
8a1fb0109f079d127ef22af3682cc1350bd98a33626ee37335fec73ccd9c5d92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Release files / cleandoc-0.0.14-py3-none-any.whl
| Download URL | cleandoc-0.0.14-py3-none-any.whl |
|---|---|
| Size | 26.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db6c713091e879b41d05c094ead843bae0305bc2a92e92c3216eb06807dba358
|
|
BLAKE2b-256 checksum How to use checksums |
b2165ebecba297d868fc816e9ac4b26b37d1964b554305091893989f3ea31a95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Security for cleandoc 0.0.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.