Skip to content

Commit

Permalink
fix copyright + add ci test
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Steiner committed Dec 8, 2023
1 parent 425906e commit f2196f5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check copyright line
shell: bash
run: |
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
- name: Bootstrap
uses: ./.github/actions/bootstrap
- name: Install pandoc
Expand Down
3 changes: 2 additions & 1 deletion baselines/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ==============================================================================


import datetime
import os
import sys
from sphinx.application import ConfigError
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions datasets/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# ==============================================================================


import datetime
import os
import sys
from sphinx.application import ConfigError
Expand All @@ -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
Expand Down Expand Up @@ -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("../../"))
Expand Down
5 changes: 4 additions & 1 deletion examples/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f2196f5

Please sign in to comment.