diff --git a/.flake8.ini b/.flake8.ini index a1b5142..6d4e752 100644 --- a/.flake8.ini +++ b/.flake8.ini @@ -1,7 +1,16 @@ [flake8] -ignore = W191,W391,E117 +select = C,E,F,W,B,B950 +# Ignore specific warnings and errors according to CEP-8 style +extend-ignore = + W191, # Indentation contains tabs + W391, # Blank line at end of file + E117, # Over-indented + D208, # Docstring is over-indented + D203, # 1 blank line required before class docstring - CEP-7 + D212, # Multi-line docstring summary should start at the first line - CEP-7 +# Ignore long lines as specified in CEP-8 max-line-length = 100 -exclude = +extend-exclude = # No need to traverse our git directory .git, # There's no value in checking cache directories @@ -10,6 +19,16 @@ exclude = docs, # There's no value in checking tox directories .tox, - # This contains our built documentation + # This contains our built stuff build + # Nothing to find in node_modules, ignore them + node_modules, + # This contains our built package for PyPi + dist, + # There's no value in checking git directories + .git, + # There's no value in checking virtual directories + venv, + # There's no value in checking xcode directories + *.xc** max-complexity = 10 diff --git a/LICENSE.md b/LICENSE.md index c81523f..fe291c3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -License - MIT +# License - MIT Copyright (c) 2017-2024 Mr. Walls diff --git a/Makefile b/Makefile index 3419aa7..cc86c25 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ PHONY: must_be_root cleanup build: $(QUIET)$(ECHO) "No need to build. Try make -f Makefile install" - $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile text 2>/dev/null || true + $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile html 2>/dev/null || true init: $(QUIET)$(ECHO) "$@: Done." @@ -103,7 +103,7 @@ test-pytest: cleanup test-reports $(QUIET)$(ECHO) "$@: Done." test-style: cleanup - $(QUIET)flake8 --ignore=W191,W391 --max-line-length=100 --verbose --count --config=.flake8.ini + $(QUIET)python3 -m flake8 --ignore=W191,W391 --max-line-length=100 --verbose --count --config=.flake8.ini --show-source || DO_FAIL="exit 2" ; $(QUIET)tests/check_spelling 2>/dev/null || true $(QUIET)$(ECHO) "$@: Done." @@ -136,7 +136,7 @@ cleanup: clean: cleanup $(QUIET)rm -f test-results/junit.xml 2>/dev/null || true - $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean 2>/dev/null || true + $(QUIET)$(MAKE) -s -C ./docs/ -f Makefile clean || true $(QUIET)$(ECHO) "$@: Done." must_be_root: diff --git a/README.md b/README.md index bcd2966..b605e9b 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,15 @@ -# About +# Python Repo Template + +## About This repo is basically my template for new repos/projects -# CI Template: +## CI Template By default this template will assume that the GHA Service and Circle-CI Service are used for CI/CD -# Status +## Status -### master: +### master [![CI](https://github.com/reactive-firewall/python-repo/actions/workflows/Tests.yml/badge.svg?branch=master)](https://github.com/reactive-firewall/python-repo/actions/workflows/Tests.yml) [![CircleCI](https://circleci.com/gh/reactive-firewall/python-repo/tree/master.svg?style=svg)](https://circleci.com/gh/reactive-firewall/python-repo/tree/master) [![status](https://travis-ci.org/reactive-firewall/python-repo.svg?branch=master)](https://travis-ci.org/reactive-firewall/python-repo) @@ -24,7 +26,7 @@ By default this template will assume that the GHA Service and Circle-CI Service ![Size](https://img.shields.io/github/languages/code-size/reactive-firewall/python-repo.svg) ![commits-since](https://img.shields.io/github/commits-since/reactive-firewall/python-repo/stable.svg?maxAge=9000) -### Stable: +### Stable [![CI](https://github.com/reactive-firewall/python-repo/actions/workflows/Tests.yml/badge.svg?branch=stable&event=pull_request)](https://github.com/reactive-firewall/python-repo/actions/workflows/Tests.yml) [![CircleCI](https://circleci.com/gh/reactive-firewall/python-repo/tree/stable.svg?style=svg)](https://circleci.com/gh/reactive-firewall/python-repo/tree/stable) [![status](https://travis-ci.org/reactive-firewall/python-repo.svg?branch=stable)](https://travis-ci.org/reactive-firewall/python-repo) @@ -34,7 +36,7 @@ By default this template will assume that the GHA Service and Circle-CI Service [![Coverage Status](https://coveralls.io/repos/github/reactive-firewall/python-repo/badge.svg?branch=stable)](https://coveralls.io/github/reactive-firewall/python-repo?branch=stable) [![codebeat badge](https://codebeat.co/badges/87520e4a-6d24-4e98-a61e-6e9efc58f783)](https://codebeat.co/projects/github-com-reactive-firewall-python-repo-stable) -# How do I use this to create a new project repo? +### How do I use this to create a new project repo? (assuming new project is already forked on github to `MY-NEW-REPO`) @@ -44,7 +46,7 @@ git clone https://github.com/reactive-firewall/MY-NEW-REPO.git MY-NEW-REPO # cd ./MY-NEW-REPO ``` -# Dev Testing Template: +### Dev Testing Template In a rush? Then use this: @@ -70,7 +72,11 @@ make test-tox ; # runs the tox tests make clean ; # cleans up for next test ``` -# Next steps: +### Documentation + +For more details read the project [documentation](./docs/index). + +### Next steps Like automation? Then integrate away, this template can take it! (hint: @coderabbitai, @travis-ci, @houndci-bot, @pyup-bot, @circleci, @codecov-io, @lemurheavy, @coverallsapp, @codeclimate) diff --git a/docs/Makefile b/docs/Makefile index d8b96a1..3081206 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,19 +2,22 @@ # # You can set these variables from the command line. -SPHINXOPTS = +SPHINXOPTS = -c ../docs/ -v SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build +SRCDIR = . +# change this to the directory you store python code in +PROJECT_DOC_SRC_DIR = "pythonrepo" # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) # the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR) -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext +.PHONY: help init clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @@ -38,41 +41,52 @@ help: @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" +init: + @ln -sf ../"$(PROJECT_DOC_SRC_DIR)" $(SRCDIR)/"$(PROJECT_DOC_SRC_DIR)" + @ln -sf ../tests $(SRCDIR)/tests 2>/dev/null || true + @ln -sf ../README.md $(SRCDIR)/README.md + @ln -sf ../LICENSE.md $(SRCDIR)/LICENSE.md + clean: @-rm -rf $(BUILDDIR)/* 2>/dev/null || true + @-rm -rfRd $(SRCDIR)/apidocs/* 2>/dev/null || true + @-unlink $(SRCDIR)/README.md 2>/dev/null || true + @-unlink $(SRCDIR)/tests 2>/dev/null || true + @-unlink $(SRCDIR)/LICENSE.md 2>/dev/null || true + @-unlink $(SRCDIR)/"$(PROJECT_DOC_SRC_DIR)" 2>/dev/null || true -html: +html: init $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." -dirhtml: +dirhtml: init $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." -singlehtml: +singlehtml: init $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." -pickle: +pickle: init $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." -json: +json: init $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." -htmlhelp: +htmlhelp: init $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." -qthelp: +qthelp: init $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ @@ -81,7 +95,7 @@ qthelp: @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/sample.qhc" -devhelp: +devhelp: init $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @@ -90,12 +104,12 @@ devhelp: @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/sample" @echo "# devhelp" -epub: +epub: init $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." -latex: +latex: init $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @@ -108,35 +122,35 @@ latexpdf: $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." -text: +text: init $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." -man: +man: init $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." -texinfo: +texinfo: init $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." -info: +info: init $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." -gettext: +gettext: init $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." -changes: +changes: init $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." @@ -147,7 +161,7 @@ linkcheck: @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." -doctest: +doctest: init $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." diff --git a/docs/conf.py b/docs/conf.py index 14c7307..23e6b33 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,34 +11,55 @@ # All configuration values have a default; values that are commented out # serve to show the default. -# import sys -# import os +import sys +import os + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -# sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('../')) +sys.path.insert(1, os.path.abspath('./pythonrepo')) # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -# needs_sphinx = '1.0' +needs_sphinx = '5.3' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [] +# for md us 'autodoc2' (pip install sphinx-autodoc2) +# for rst use 'sphinx.ext.autodoc' +extensions = [ + 'sphinx.ext.napoleon', 'autodoc2', 'sphinx.ext.autosummary', + 'sphinx.ext.githubpages', 'myst_parser', + 'sphinx.ext.doctest', 'sphinx.ext.todo', + 'sphinx.ext.linkcode', 'sphinx.ext.viewcode' + ] + +# for md auto-docs +autodoc2_packages = [ + "pythonrepo", + "tests", +] + +autodoc2_render_plugin = "myst" # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. -source_suffix = '.md' +source_suffix = { + '.md': 'markdown', + '.txt': 'markdown', + '.rst': 'restructuredtext', +} -# The encoding of source files. -# source_encoding = 'utf-8-sig' +# The encoding of source files. Official sphinx docs reccomend utf-8-sig. +source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = 'toc' # General information about the project. project = u'python_template' @@ -49,9 +70,9 @@ # built documents. # # The short X.Y version. -version = 'v1.1' +version = 'v2.0' # The full version, including alpha/beta/rc tags. -release = 'v1.1.4' +release = 'v2.0.0-alpha' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -62,37 +83,44 @@ # today = '' # Else, today_fmt is used as the format for a strftime call. # today_fmt = '%B %d, %Y' +today_fmt = '%Y.%B.%d' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build', 'tests'] +exclude_patterns = ['_build', '.github', '.circleci', '.DS_Store', '**/.git', 'dist', 'tests'] # The reST default role (used for this markup: `text`) to use for all documents. # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True +add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -# add_module_names = True +add_module_names = True + +# sigs should not have backslashes +strip_signature_backslash = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -show_authors = False +show_authors = True # The name of the Pygments (syntax highlighting) style to use. +# pygments_style = 'py' pygments_style = 'default' # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] +# Create table of contents entries for domain objects (e.g. functions, classes, attributes, etc.). +toc_object_entries = True # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = 'sphinxawesome_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -107,7 +135,7 @@ # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None +html_short_title = 'Project Docs' # The name of an image file (relative to this directory) to place at the top # of the sidebar. @@ -118,6 +146,8 @@ # pixels large. # html_favicon = None +html_permalinks_icon = '#' + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". @@ -168,6 +198,29 @@ htmlhelp_basename = 'python_repo_doc' +# -- Options for MyST markdown parser ------------------------------------------- +# see https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#syntax-directives + +# be more like GFM with style +myst_enable_extensions = ('tasklist', 'strikethrough', 'fieldlist') + +# for GFM diagrams and interoperability with other Markdown renderers +myst_fence_as_directive = ('mermaid', 'suggestion', 'note') + +# Focus only on github markdown +myst_gfm_only = False + + +#heading_anchors = 1 + +# -- Options for napoleon ext -------------------------------------------------- + +# include __init__ when it has docstrings +napoleon_include_init_with_doc = True + +# try to be smarter +napoleon_preprocess_types = True + # -- Options for LaTeX output -------------------------------------------------- latex_elements = {} @@ -257,3 +310,10 @@ # How to display URL addresses: 'footnote', 'no', or 'inline'. # texinfo_show_urls = 'footnote' + +# -- Link resolver ------------------------------------------------------------- +def linkcode_resolve(domain, info): + if domain != 'py' or not info.get('module'): + return None + filename = info['module'].replace('.', '/') + return "https://github.com/reactive-firewall/python-repo/blob/stable/%s.py" % filename diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 2a6eb31..0000000 --- a/docs/index.md +++ /dev/null @@ -1,22 +0,0 @@ -.. python_repo documentation master file, created by - sphinx-quickstart on Mon Apr 16 21:22:43 2012. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -Welcome to Python Repo' documentation! -================================================ - -Contents: - -.. toctree:: - :maxdepth: 2 - - - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/docs/toc.md b/docs/toc.md new file mode 100644 index 0000000..4a27163 --- /dev/null +++ b/docs/toc.md @@ -0,0 +1,23 @@ +# Welcome to Python Repo' documentation! + +## Contents + +```{toctree} +:maxdepth: 3 +apidocs/index +/README.md +/setup.py +/LICENSE.md +:Name: Documentation +/ +``` + +## Overview + +```{autosummary} +``` + + +## Quickstart + +more filler text diff --git a/pythonrepo/pythonrepo.py b/pythonrepo/pythonrepo.py index 12a94cc..e20e95a 100644 --- a/pythonrepo/pythonrepo.py +++ b/pythonrepo/pythonrepo.py @@ -65,9 +65,9 @@ def NoOp(*args, **kwargs): # More boiler-plate-code -TASK_OPTIONS = dict({ # skipcq: PTC-W0020 +TASK_OPTIONS = { # skipcq: PTC-W0020 'noop': NoOp -}) +} """The callable function tasks of this program.""" diff --git a/test-requirements.txt b/test-requirements.txt index e370cb1..b09086e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,4 @@ -#python +#python testing requirements # time - builtin - PSF licence # re - builtin - PSF licence? # subprocess - PSF licence @@ -16,9 +16,9 @@ six>=1.0.0 tox>=3.0.0 #py>=1.4.33 # pip>=19.0 -### +# # TESTING ONLY - Do NOT report issues with these optionals on python-repo -### +# flake8>=5.0 pyflakes>=2.5.0 pep8>=1.0