diff --git a/confix.py b/confix.py deleted file mode 100644 index 4175b69..0000000 --- a/confix.py +++ /dev/null @@ -1,67 +0,0 @@ -""" -sphinx-quickstart creates conf.py and index.rst files. - -They need to be edited before launching the build. -""" - - -class ModulesAlreadyInIndex(Exception): - """Raise when "modules" is already in docs/index.rst""" - - -def fix_docs_conf_py(): - """ - Lines to be edited in docs/conf.py: - - # import os - # import sys - # sys.path.insert(0, os.path.abspath('.')) - - to: - - import os - import sys - sys.path.insert(0, os.path.abspath('../src')) - """ - with open("docs/conf.py", "r", encoding="utf-8") as file_obj: - lines = file_obj.readlines() - with open("docs/conf.py", "w", encoding="utf-8") as file_obj: - for line in lines: - if line.startswith("# import"): - # uncomment the line - line = line[2:] - if line.startswith("# sys.path.insert"): - line = "\nsys.path.insert(0, os.path.abspath('../src'))\n" - file_obj.write(line) - - -def fix_docs_index_rst(): - """ - In docs/index.rst, the string "modules" must be added 2 lines below ":caption: Contents:". - - .. toctree:: - :maxdepth: 2 - :caption: Contents: - - modules - """ - towrite = [] - with open("docs/index.rst", "r", encoding="utf-8") as file_obj: - lines = file_obj.readlines() - for line in lines: - # Add "modules" to the toctree - # raise an error if the string "modules" is already in the file - if line.startswith(" :caption: Contents:"): - towrite.extend((" :caption: Contents:\n\n", " modules\n")) - elif line.strip() == "modules": - raise ModulesAlreadyInIndex('"modules" is already in docs/index.rst') - else: - towrite.append(line) - - with open("docs/index.rst", "w", encoding="utf-8") as file_obj: - file_obj.write("".join(towrite)) - - -if __name__ == "__main__": - fix_docs_conf_py() - fix_docs_index_rst() diff --git a/justfile b/justfile index ba3ac79..e625b9d 100644 --- a/justfile +++ b/justfile @@ -54,23 +54,19 @@ MIN_COVERAGE := '100' # rename project and author @rename project author: # replace string "Cleanpython" with {{project}} and "iacopy" with {{author}} in files - sed -i "" -e s/Cleanpython/"{{project}}"/g -e s/iacopy/"{{author}}"/g docs/conf.py - sed -i "" s/Cleanpython/"{{project}}"/g docs/index.rst + sed -i "" -e s/Cleanpython/"{{project}}"/g -e s/iacopy/"{{author}}"/g pyproject.toml + sed -i "" s/"Clean code with batteries included."/"Project description placeholder"/g pyproject.toml sed -i "" s/iacopy/"{{author}}"/g LICENSE + # Overwrite the default docs/index.md + echo "# {{project}}\n" > docs/index.md # Overwrite the default README.md echo "# {{project}}\n" > README.md - # Remove the docs/build directory - rm -rf docs/build - # Remove all files from 'docs' directory except index.rst, conf.py, Makefile, and requirements.txt - find docs -not -name 'index.rst' -not -name 'conf.py' -not -name 'Makefile' -not -name 'requirements.txt' -delete - # add github badges to the readme @badges username reponame: # Generate badges echo "[![Testing](https://github.com/{{username}}/{{reponame}}/actions/workflows/ci.yml/badge.svg)](https://github.com/{{username}}/{{reponame}}/actions/workflows/ci.yml)" >> README.md - echo "[![Sphinx build](https://github.com/{{username}}/{{reponame}}/actions/workflows/sphinx.yml/badge.svg)](https://github.com/{{username}}/{{reponame}}/actions/workflows/sphinx.yml)" >> README.md echo "[![pages-build-deployment](https://github.com/{{username}}/{{reponame}}/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/{{username}}/{{reponame}}/actions/workflows/pages/pages-build-deployment)" >> README.md # WARNING! Reset git history, add all files and make initial commit diff --git a/pyproject.toml b/pyproject.toml index acb7f59..977864a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [tool.poetry] -name = "cleanpython" +name = "Cleanpython" version = "0.1.0" description = "Clean code with batteries included." -authors = ["iacopo "] +authors = ["iacopy"] license = "MIT" readme = "README.md"