diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 52944ffecf70..94f3495a20ef 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,6 +23,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Check copyright line + run: ./dev/test-copyright.sh - name: Bootstrap uses: ./.github/actions/bootstrap - name: Install pandoc diff --git a/baselines/doc/source/conf.py b/baselines/doc/source/conf.py index e1055aaed216..dabd421c61cf 100644 --- a/baselines/doc/source/conf.py +++ b/baselines/doc/source/conf.py @@ -14,6 +14,7 @@ # ============================================================================== +import datetime import os import sys from sphinx.application import ConfigError @@ -32,7 +33,7 @@ # -- Project information ----------------------------------------------------- project = "Flower" -copyright = "2022 Flower Labs GmbH" +copyright = f"{datetime.date.today().year} Flower Labs GmbH" author = "The Flower Authors" # The full version, including alpha/beta/rc tags diff --git a/datasets/doc/source/conf.py b/datasets/doc/source/conf.py index 32baa6dd1471..53d7046bfaac 100644 --- a/datasets/doc/source/conf.py +++ b/datasets/doc/source/conf.py @@ -14,6 +14,7 @@ # ============================================================================== +import datetime import os import sys from sphinx.application import ConfigError @@ -33,7 +34,7 @@ # -- Project information ----------------------------------------------------- project = "Flower Datasets" -copyright = "2023 Flower Labs GmbH" +copyright = f"{datetime.date.today().year} Flower Labs GmbH" author = "The Flower Authors" # The full version, including alpha/beta/rc tags @@ -74,25 +75,27 @@ # The full name is still at the top of the page add_module_names = False + def find_test_modules(package_path): """Go through the python files and exclude every *_test.py file.""" full_path_modules = [] for root, dirs, files in os.walk(package_path): for file in files: - if file.endswith('_test.py'): + if file.endswith("_test.py"): # Construct the module path relative to the package directory full_path = os.path.join(root, file) relative_path = os.path.relpath(full_path, package_path) # Convert file path to dotted module path - module_path = os.path.splitext(relative_path)[0].replace(os.sep, '.') + module_path = os.path.splitext(relative_path)[0].replace(os.sep, ".") full_path_modules.append(module_path) modules = [] for full_path_module in full_path_modules: - parts = full_path_module.split('.') + parts = full_path_module.split(".") for i in range(len(parts)): - modules.append('.'.join(parts[i:])) + modules.append(".".join(parts[i:])) return modules + # Stop from documenting the *_test.py files. # That's the only way to do that in autosummary (make the modules as mock_imports). autodoc_mock_imports = find_test_modules(os.path.abspath("../../")) diff --git a/dev/test-copyright.sh b/dev/test-copyright.sh new file mode 100755 index 000000000000..5ba8fedfe1ef --- /dev/null +++ b/dev/test-copyright.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e + +cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../ + +EXIT_CODE=0 + +while IFS= read -r -d '' file; do + COPYRIGHT=$(grep -h -r "copyright = " "$file") + if [ "$COPYRIGHT" != "copyright = f\"{datetime.date.today().year} Flower Labs GmbH\"" ]; then + echo "::error file=$file::Wrong copyright line. Expected: copyright = f\"{datetime.date.today().year} Flower Labs GmbH\"" + EXIT_CODE=1 + fi +done < <(find . -path "*/doc/source/conf.py" -print0) + +exit $EXIT_CODE diff --git a/doc/source/conf.py b/doc/source/conf.py index 8077d26aa6ae..8f68c992a314 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -14,6 +14,7 @@ # ============================================================================== +import datetime import os import sys from git import Repo @@ -81,7 +82,7 @@ # -- Project information ----------------------------------------------------- project = "Flower" -copyright = "2022 Flower Labs GmbH" +copyright = f"{datetime.date.today().year} Flower Labs GmbH" author = "The Flower Authors" # The full version, including alpha/beta/rc tags diff --git a/examples/doc/source/conf.py b/examples/doc/source/conf.py index 01cbb48c1587..3d629c39c7ea 100644 --- a/examples/doc/source/conf.py +++ b/examples/doc/source/conf.py @@ -22,8 +22,11 @@ # -- Project information ----------------------------------------------------- +import datetime + + project = "Flower" -copyright = "2022 Flower Labs GmbH" +copyright = f"{datetime.date.today().year} Flower Labs GmbH" author = "The Flower Authors" # The full version, including alpha/beta/rc tags