diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 54bf28a623b6d96947e922262ccc82598a9edab5..9d66e676db12b46203c4ac7ab3be8a2918477ea2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,3 +32,11 @@ run_unit_tests_coverage: path: my_awesome_app/coverage.xml paths: - my_awesome_app/htmlcov/* + +# Override artifact directories +package_docs: + stage: package + artifacts: + expire_in: 1w + paths: + - my_awesome_app/docs/build/* \ No newline at end of file diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore index dd694bf7e5bbe6a53d8e82e8ca3e5b37164a7b58..36bb668ccb33470e35bf27a3e7ba9e6f216325e2 100644 --- a/{{cookiecutter.project_slug}}/.gitignore +++ b/{{cookiecutter.project_slug}}/.gitignore @@ -9,6 +9,10 @@ htmlcov/* build dist +# Documentation +docs/source/source_documentation +docs/build + # Setuptools SCM {{cookiecutter.project_slug}}/_version.py diff --git a/{{cookiecutter.project_slug}}/.gitlab-ci.yml b/{{cookiecutter.project_slug}}/.gitlab-ci.yml index e7bea35a09b19b26a066e0074a35ed2ea2c8ab46..6e41df262ba9bd8bf503348f2bd4488f00444e3e 100644 --- a/{{cookiecutter.project_slug}}/.gitlab-ci.yml +++ b/{{cookiecutter.project_slug}}/.gitlab-ci.yml @@ -95,14 +95,12 @@ package_files: package_docs: stage: package - allow_failure: true artifacts: expire_in: 1w paths: - - docs/* # update path to match the dest dir for documentation + - docs/build/* script: - - echo "build and collect docs" - - exit 1 + - tox -e docs run_integration_tests: stage: integration diff --git a/{{cookiecutter.project_slug}}/docs/.gitkeep b/{{cookiecutter.project_slug}}/docs/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/{{cookiecutter.project_slug}}/docs/cleanup.sh b/{{cookiecutter.project_slug}}/docs/cleanup.sh new file mode 100644 index 0000000000000000000000000000000000000000..aac4cef22a134a44b69e99369755a58507b3794f --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/cleanup.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +FILE_DIR=$(dirname -- "$(readlink -f -- "${0}")") + +echo "Cleaning.. ${FILE_DIR}/source/source_documentation/*" + +for f in "${FILE_DIR}"/source/source_documentation/* +do + + case $f in + */index.rst) true;; + *) echo "Removing.. ${f}"; rm "${f}";; + esac +done diff --git a/{{cookiecutter.project_slug}}/docs/requirements.txt b/{{cookiecutter.project_slug}}/docs/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..3c6e46c6db7ddaf65e47cfa22c9ec0b914f7fd38 --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/requirements.txt @@ -0,0 +1,5 @@ +sphinx!=1.6.6,!=1.6.7,>=1.6.5 # BSD +sphinx-rtd-theme>=0.4.3 #MIT +sphinxcontrib-apidoc>=0.3.0 #BSD +myst-parser>=2.0 # MIT +docutils>=0.17 # BSD diff --git a/{{cookiecutter.project_slug}}/docs/source/conf.py b/{{cookiecutter.project_slug}}/docs/source/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..c14432747f3fbb5409e54edb47eb8f80b41dc99a --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/conf.py @@ -0,0 +1,93 @@ +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 + +import os + +from {{cookiecutter.project_slug}} import __version__ + +# -- General configuration ---------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.viewcode", + "sphinxcontrib.apidoc", + "sphinx_rtd_theme", + "myst_parser" +] + +# Assumes tox is used to call sphinx-build +project_root_directory = os.getcwd() + +apidoc_module_dir = "../../{{cookiecutter.project_slug}}" +apidoc_output_dir = "source_documentation" +apidoc_excluded_paths = [] +apidoc_separate_modules = True +apidoc_toc_file = False +# This should include private methods but does not work +# https://github.com/sphinx-contrib/apidoc/issues/14 +apidoc_extra_args = ["--private"] + +# The suffix of source filenames. +source_suffix = [".rst"] + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = "{{cookiecutter.project_name}}" +copyright = "2023, ASTRON" + +# openstackdocstheme options +repository_name = "{{cookiecutter.project_url}}" +bug_project = "none" +bug_tag = "" +html_last_updated_fmt = "%Y-%m-%d %H:%M" + +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +version = __version__ + +modindex_common_prefix = ["{{cookiecutter.project_slug}}."] + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +html_theme = "sphinx_rtd_theme" +html_static_path = ["static"] +html_css_files = [ + "css/custom.css", +] + +# Output file base name for HTML help builder. +htmlhelp_basename = "%sdoc" % project + +# Conf.py variables exported to sphinx rst files access using |NAME| +variables_to_export = [ + "project", + "copyright", + "version", +] + +# Write to rst_epilog to export `variables_to_export` extract using `locals()` +# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_epilog +frozen_locals = dict(locals()) +rst_epilog = "\n".join( + map( + lambda x: f".. |{x}| replace:: {frozen_locals[x]}", # noqa: F821 + variables_to_export, + ) +) +# Pep is not able to determine that frozen_locals always exists so noqa +del frozen_locals diff --git a/{{cookiecutter.project_slug}}/docs/source/index.rst b/{{cookiecutter.project_slug}}/docs/source/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..65932d229c9902616280ee6fbecf521aa61d1984 --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/index.rst @@ -0,0 +1,16 @@ +==================================================== +Welcome to the documentation of {{cookiecutter.project_name}} +==================================================== + +.. + To define more variables see rst_epilog generation in conf.py + +Documentation for version: |version| + +Contents: + +.. toctree:: + :maxdepth: 2 + + readme + source_documentation/index diff --git a/{{cookiecutter.project_slug}}/docs/source/readme.rst b/{{cookiecutter.project_slug}}/docs/source/readme.rst new file mode 100644 index 0000000000000000000000000000000000000000..87c96deef60fc04b35a8b9b9cca2f72b7e64e70c --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/readme.rst @@ -0,0 +1,2 @@ +.. include:: ../../README.md + :parser: myst_parser.sphinx_ diff --git a/{{cookiecutter.project_slug}}/docs/source/source_documentation/index.rst b/{{cookiecutter.project_slug}}/docs/source/source_documentation/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..df6590fc912620dbf00d703cf04cf14ca928e78f --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/source_documentation/index.rst @@ -0,0 +1,7 @@ +Source code documentation +========================= + +.. toctree:: + :maxdepth: 3 + + {{cookiecutter.project_slug}} diff --git a/{{cookiecutter.project_slug}}/docs/source/static/css/custom.css b/{{cookiecutter.project_slug}}/docs/source/static/css/custom.css new file mode 100644 index 0000000000000000000000000000000000000000..3ea8a2fc0c9c1ecb2b318cbc32edf90d2940c38d --- /dev/null +++ b/{{cookiecutter.project_slug}}/docs/source/static/css/custom.css @@ -0,0 +1,14 @@ +.orange { color: #c65d09; } + +.green { color: #5dc609; } + +.yellow { color: #c6c609; } + +.bolditalic { + font-weight: bold; + font-style: italic; +} + +.rst-content code, .rst-content tt, code { + white-space: break-spaces; +} diff --git a/{{cookiecutter.project_slug}}/setup.cfg b/{{cookiecutter.project_slug}}/setup.cfg index 02afb4fe2b4ea9c2080fc89f44a1961b84c2ced7..906b08ebcea3165b47b6663cf47f4894e43d0220 100644 --- a/{{cookiecutter.project_slug}}/setup.cfg +++ b/{{cookiecutter.project_slug}}/setup.cfg @@ -34,3 +34,4 @@ install_requires = file: requirements.txt [flake8] max-line-length = 88 extend-ignore = E203 +exclude=.venv,.git,.tox,dist,docs,*lib/python*,*egg,_version.py diff --git a/{{cookiecutter.project_slug}}/tests/test_cool_module.py b/{{cookiecutter.project_slug}}/tests/test_cool_module.py index 19e5cd2bd0bff16fa00560bdb678f9345e4e79f4..3336578a3e5b4a24c4efceb03e6c41af3eb3e6ba 100644 --- a/{{cookiecutter.project_slug}}/tests/test_cool_module.py +++ b/{{cookiecutter.project_slug}}/tests/test_cool_module.py @@ -1,3 +1,6 @@ +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 + """Testing of the Cool Module""" from unittest import TestCase diff --git a/{{cookiecutter.project_slug}}/tox.ini b/{{cookiecutter.project_slug}}/tox.ini index 97459ed340314968a4c38d574103d2044bd57a22..a469b2d888fbfa5bd0d9ab18901b0cfca1f4296a 100644 --- a/{{cookiecutter.project_slug}}/tox.ini +++ b/{{cookiecutter.project_slug}}/tox.ini @@ -40,6 +40,19 @@ commands = format: {envpython} -m autopep8 -v -aa --in-place --recursive tests format: {envpython} -m black -v {{cookiecutter.project_slug}} tests +[testenv:docs] +allowlist_externals = + sh +; unset LC_ALL / LANGUAGE from testenv, would fail sphinx otherwise +setenv = +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/docs/requirements.txt +changedir = {toxinidir} +commands = + sh docs/cleanup.sh + sphinx-build -b html docs/source docs/build/html + [testenv:build] usedevelop = False commands = {envpython} -m build diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py index 35d0142800c927ba97b4c350de181c8d48f45f43..58d3379529ec297099b77b8ce5c9df5f59798ca8 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/__init__.py @@ -1,3 +1,6 @@ +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 + """ {{cookiecutter.project_name}} """ try: diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cool_module.py b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cool_module.py index bd9416c291b7ed52a278bc6966f2dac155e4aa05..de82c46c186cce3880ff8f56d87ba4406ee195ce 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cool_module.py +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/cool_module.py @@ -1,3 +1,6 @@ +# Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy) +# SPDX-License-Identifier: Apache-2.0 + """ Cool module containing functions, classes and other useful things """