diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d14e2ae --- /dev/null +++ b/.editorconfig @@ -0,0 +1,39 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/toolkit +# +# EditorConfig Configuration file, for more details see: +# http://EditorConfig.org +# EditorConfig is a convention description, that could be interpreted +# by multiple editors to enforce common coding conventions for specific +# file types + +# top-most EditorConfig file: +# Will ignore other EditorConfig files in Home directory or upper tree level. +root = true + + +[*] # For All Files +# Unix-style newlines with a newline ending every file +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +# Set default charset +charset = utf-8 +# Indent style default +indent_style = space +# Max Line Length - a hard line wrap, should be disabled +max_line_length = off + +[*.{py,cfg,ini}] +# 4 space indentation +indent_size = 4 + +[*.{yml,zpt,pt,dtml,zcml}] +# 2 space indentation +indent_size = 2 + +[{Makefile,.gitmodules}] +# Tab indentation (no size specified, but view as 4 spaces) +indent_style = tab +indent_size = unset +tab_width = unset diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aba5d4f..0eb10d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,5 @@ -# Loosely based on: -# https://github.com/zopefoundation/meta/tree/master/config/pure-python +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/toolkit name: tests on: @@ -16,40 +16,46 @@ jobs: # We want to see all failures: fail-fast: false matrix: + os: + - ["ubuntu", "ubuntu-20.04"] config: - # [Python version, extra dependencies] - - ["3.7", "py37"] - - ["3.8", "py3"] - - ["3.9", "py39"] - - ["3.10", "py310"] - - ["3.11", "py311"] + # [Python version, tox env] + - ["3.9", "lint"] + - ["3.7", "py37"] + - ["3.8", "py38"] + - ["3.9", "py39"] + - ["3.10", "py310"] + - ["3.11", "py311"] - ["pypy-3.9", "pypy3"] + - ["3.9", "docs"] - runs-on: ubuntu-latest + runs-on: ${{ matrix.os[1] }} if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - name: ${{ matrix.config[0] }} + name: ${{ matrix.config[1] }} steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.config[0] }} - - name: Install library dependencies - run: | - sudo apt-get update - sudo apt-get install libxml2-dev libxslt1-dev - - name: Cache Python wheels and eggs + - name: Pip cache uses: actions/cache@v3 with: - path: | - ~/.cache/pip - eggs - key: ${{ runner.os }}-py-${{ matrix.config[0] }}-${{ hashFiles('buildout.cfg') }} + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ matrix.config[0] }}-${{ hashFiles('setup.*', 'tox.ini') }} restore-keys: | - ${{ runner.os }}-py-${{ matrix.config[0] }}- - ${{ runner.os }}-py- + ${{ runner.os }}-pip-${{ matrix.config[0] }}- + ${{ runner.os }}-pip- - name: Install dependencies run: | - python -m pip install -U pip tox + python -m pip install --upgrade pip + pip install tox - name: Test run: tox -e ${{ matrix.config[1] }} + - name: Coverage + if: matrix.config[1] == 'coverage' + run: | + pip install coveralls + coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 0dc7f1b..6e61baa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,32 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/toolkit +*.dll +*.egg-info/ +*.profraw *.pyc +*.pyo *.so -*.egg-info -__pycache__ +.coverage +.coverage.* +.eggs/ .installed.cfg .mr.developer.cfg .tox/ -build/ +.vscode/ +__pycache__/ bin/ +build/ +coverage.xml develop-eggs/ -download-cache/ -eggs/ -parts/ -src/ +develop/ +dist/ docs/_build -include/ +eggs/ +etc/ lib/ lib64 -pip-selfcheck.json +log/ +parts/ pyvenv.cfg +testing.log +var/ diff --git a/.meta.toml b/.meta.toml new file mode 100644 index 0000000..c2962ab --- /dev/null +++ b/.meta.toml @@ -0,0 +1,22 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/toolkit +[meta] +template = "toolkit" +commit-id = "faabd7e5" + +[python] +with-sphinx-doctests = false +with-docs = true +with-future-python = false +with-pypy = true +with-macos = false +with-windows = false + +[tox] +use-flake8 = true +testenv-commands = [ + "{envdir}/bin/test-ztk {posargs:-cv}", + ] + +[coverage] +fail-under = "not applicable" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..973aee6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,23 @@ + +# Contributing to zopefoundation projects + +The projects under the zopefoundation GitHub organization are open source and +welcome contributions in different forms: + +* bug reports +* code improvements and bug fixes +* documentation improvements +* pull request reviews + +For any changes in the repository besides trivial typo fixes you are required +to sign the contributor agreement. See +https://www.zope.dev/developer/becoming-a-committer.html for details. + +Please visit our [Developer +Guidelines](https://www.zope.dev/developer/guidelines.html) if you'd like to +contribute code changes and our [guidelines for reporting +bugs](https://www.zope.dev/developer/reporting-bugs.html) if you want to file a +bug report. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..309d909 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,14 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/toolkit +include *.md +include *.rst +include *.txt +include buildout.cfg +include tox.ini + +recursive-include docs *.py +recursive-include docs *.rst +recursive-include docs *.txt +recursive-include docs Makefile + +recursive-include src *.py diff --git a/buildout.cfg b/buildout.cfg index 3a83dcf..9b85876 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -4,37 +4,16 @@ extends = parts = test-ztk - sphinx - ztk-docs checkversions extensions = mr.developer - allow-picked-versions = false -versions = versions [test-ztk] # individual test runners for the ztk recipe = z3c.recipe.compattest include = ${ztk:packages} -[sphinx] -recipe = zc.recipe.egg -eggs = - Sphinx - repoze.sphinx.autointerface - sphinxcontrib.applehelp - lxml - ${ztk:packages} -interpreter = sphinx-py - -[ztk-docs] -recipe = collective.recipe.cmd -on_install = true -on_update = true -cmds = - ${buildout:directory}/bin/sphinx-build -q -b html -d ${buildout:directory}/docs/_build/doctrees -a -W ${buildout:directory}/docs ${buildout:directory}/docs/_build/html - [checkversions] # script to find newer versions recipe = zc.recipe.egg diff --git a/doc-requirements.txt b/doc-requirements.txt new file mode 100644 index 0000000..e357901 --- /dev/null +++ b/doc-requirements.txt @@ -0,0 +1,2 @@ +Sphinx +repoze.sphinx.autointerface diff --git a/docs/conf.py b/docs/conf.py index 51f25bb..ca0b2e5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,8 +12,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os +import sys + # 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 @@ -23,7 +24,7 @@ # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom @@ -44,7 +45,7 @@ source_suffix = '.rst' # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' @@ -71,9 +72,9 @@ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -81,27 +82,27 @@ # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# 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 # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # -- Options for HTML output ---------------------------------------------- @@ -113,26 +114,26 @@ # 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 # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # 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, @@ -142,62 +143,62 @@ # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -#html_search_language = 'en' +# html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value -#html_search_options = {'type': 'default'} +# html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' +# html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = 'zopetoolkitdoc' @@ -205,46 +206,46 @@ # -- Options for LaTeX output --------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', -# Latex figure (float) alignment -#'figure_align': 'htbp', + # Latex figure (float) alignment + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'zopetoolkit.tex', u'zopetoolkit Documentation', - u'Zope Foundation and Contributors', 'manual'), + ('index', 'zopetoolkit.tex', u'zopetoolkit Documentation', + u'Zope Foundation and Contributors', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- @@ -257,7 +258,7 @@ ] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -266,22 +267,23 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'zopetoolkit', u'zopetoolkit Documentation', - u'Zope Foundation and Contributors', 'zopetoolkit', 'One line description of project.', - 'Miscellaneous'), + ('index', 'zopetoolkit', 'zopetoolkit Documentation', + 'Zope Foundation and Contributors', 'zopetoolkit', + 'Documentation for Zope Toolkit', + 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # -- Options for Epub output ---------------------------------------------- @@ -293,65 +295,65 @@ epub_copyright = u'2015, Zope Foundation and Contributors' # The basename for the epub file. It defaults to the project name. -#epub_basename = u'zopetoolkit' +# epub_basename = u'zopetoolkit' -# The HTML theme for the epub output. Since the default themes are not optimized -# for small screen space, using the same theme for HTML and epub output is -# usually not wise. This defaults to 'epub', a theme designed to save visual -# space. -#epub_theme = 'epub' +# The HTML theme for the epub output. Since the default themes are not +# optimized for small screen space, using the same theme for HTML and epub +# output is usually not wise. This defaults to 'epub', a theme designed to save +# visual space. +# epub_theme = 'epub' # The language of the text. It defaults to the language option # or 'en' if the language is not set. -#epub_language = '' +# epub_language = '' # The scheme of the identifier. Typical schemes are ISBN or URL. -#epub_scheme = '' +# epub_scheme = '' # The unique identifier of the text. This can be a ISBN number # or the project homepage. -#epub_identifier = '' +# epub_identifier = '' # A unique identification for the text. -#epub_uid = '' +# epub_uid = '' # A tuple containing the cover image and cover page html template filenames. -#epub_cover = () +# epub_cover = () # A sequence of (type, uri, title) tuples for the guide element of content.opf. -#epub_guide = () +# epub_guide = () # HTML files that should be inserted before the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_pre_files = [] +# epub_pre_files = [] # HTML files shat should be inserted after the pages created by sphinx. # The format is a list of tuples containing the path and title. -#epub_post_files = [] +# epub_post_files = [] # A list of files that should not be packed into the epub file. epub_exclude_files = ['search.html'] # The depth of the table of contents in toc.ncx. -#epub_tocdepth = 3 +# epub_tocdepth = 3 # Allow duplicate toc entries. -#epub_tocdup = True +# epub_tocdup = True # Choose between 'default' and 'includehidden'. -#epub_tocscope = 'default' +# epub_tocscope = 'default' # Fix unsupported image types using the Pillow. -#epub_fix_images = False +# epub_fix_images = False # Scale large images. -#epub_max_image_width = 0 +# epub_max_image_width = 0 # How to display URL addresses: 'footnote', 'no', or 'inline'. -#epub_show_urls = 'inline' +# epub_show_urls = 'inline' # If false, no index is generated. -#epub_use_index = True +# epub_use_index = True # Example configuration for intersphinx: refer to the Python standard library. @@ -374,12 +376,15 @@ 'security', 'structuredtext', ] + + def _sub_url(pkg): path = '%s/src/zope.%s/docs/_build/html' % (WHERE, pkg) if os.path.exists(path): return 'file://%s/src/zope.%s/docs/_build/html' % (WHERE, pkg) # Not until docs.zope.org gets updated with objects.inv - #return 'http://docs.zope.org/zope.%s' % pkg + # return 'http://docs.zope.org/zope.%s' % pkg + urls = [(pkg, (_sub_url(pkg), None)) for pkg in SUBPACKAGES] urls = [(pkg, pair) for pkg, pair in urls if pair[0] is not None] diff --git a/docs/index.rst b/docs/index.rst index d4fc02e..84d56a6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -30,7 +30,7 @@ You should follow these in most cases. Python versions --------------- -The ZTK supports CPython 2.7, 3.5, 3.6, 3.7, 3.8, PyPy and PyPy3. +The ZTK supports CPython 3.7, 3.8, 3.9, 3.10, 3.11, and PyPy3. Documentation diff --git a/docs/ztksphinx.py b/docs/ztksphinx.py index 8917425..14ab51c 100644 --- a/docs/ztksphinx.py +++ b/docs/ztksphinx.py @@ -1,10 +1,10 @@ -from docutils import nodes -from docutils.parsers.rst import Directive import json - -import urllib import socket import threading +import urllib + +from docutils import nodes +from docutils.parsers.rst import Directive def setup(app): @@ -43,11 +43,11 @@ def process_buildbot_nodes(app, doctree, fromdocname): url = parse_builder_url(node.buildbot_url) by_url.setdefault(url, []).append(node) jobs = [] - for url, nodes in by_url.items(): - if not nodes: + for url, nodes_ in by_url.items(): + if not nodes_: continue thread = threading.Thread(target=update_buildbot_nodes, - args=(url, nodes), + args=(url, nodes_), name='%s' % (url,)) thread.start() jobs.append(thread) @@ -97,12 +97,13 @@ def get_buildbot_result(json_url): except Exception as e: return e + class BuildbotColor(nodes.Inline, nodes.TextElement): pass def visit_buildbot_node(self, node): - kwargs = {'href' : node.buildbot_url} + kwargs = {'href': node.buildbot_url} css_class = getattr(node, 'css_class', '') if css_class: kwargs['class'] = css_class @@ -115,4 +116,3 @@ def visit_buildbot_node(self, node): def depart_buildbot_node(self, node): self.body.append('') - diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..557494d --- /dev/null +++ b/setup.cfg @@ -0,0 +1,24 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/toolkit +[bdist_wheel] +universal = 0 + +[flake8] +doctests = 1 + +[check-manifest] +ignore = + .editorconfig + .meta.toml + docs/_build/html/_sources/* + +[isort] +force_single_line = True +combine_as_imports = True +sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER +known_third_party = docutils, pkg_resources, pytz +known_zope = +known_first_party = +default_section = ZOPE +line_length = 79 +lines_after_imports = 2 diff --git a/tox.ini b/tox.ini index 9db2457..da15030 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,53 @@ +# Generated from: +# https://github.com/zopefoundation/meta/tree/master/config/toolkit [tox] -skipsdist = True +minversion = 3.18 envlist = - py37, - py38, - py39, - py310, - py311, - pypy3, + lint + py37 + py38 + py39 + py310 + py311 + pypy3 + docs [testenv] +skip_install = true deps = - zc.buildout + zc.buildout >= 3.0.1 + wheel > 0.37 +commands_pre = + {envbindir}/buildout -nc {toxinidir}/buildout.cfg buildout:directory={envdir} commands = - {envbindir}/buildout -c {toxinidir}/buildout.cfg buildout:directory={envdir} install test-ztk - {envdir}/bin/test-ztk + {envdir}/bin/test-ztk {posargs:-cv} + +[testenv:lint] +basepython = python3 +commands_pre = + mkdir -p {toxinidir}/parts/flake8 +allowlist_externals = + mkdir +commands = + isort --check-only --diff {toxinidir}/docs + flake8 {toxinidir}/docs +deps = + flake8 + isort + +[testenv:isort-apply] +basepython = python3 +skip_install = true +commands_pre = +deps = + isort +commands = + isort {toxinidir}/docs [] + +[testenv:docs] +basepython = python3 +deps = + -r doc-requirements.txt +commands_pre = +commands = + sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html