Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make copyright year in Flower docs dynamic #2699

Merged
merged 5 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Robert-Steiner marked this conversation as resolved.
Show resolved Hide resolved
- 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
3 changes: 2 additions & 1 deletion 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 git import Repo
Expand Down Expand Up @@ -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
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