Skip to content

Commit 84a1f5e

Browse files
authored
Merge pull request #125 from pyfar/cookiecutter
apply cookiecutter
2 parents 4089467 + 28d3f95 commit 84a1f5e

5 files changed

Lines changed: 77 additions & 18 deletions

File tree

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* sofar version:
44
* Python version:
55
* Operating System:
6-
* Did you install pyfar via pip:
6+
* Did you install sofar via pip:
77

88
## Description
99

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR Check Label for version Label
1+
name: pull_request label
22

33
on:
44
pull_request:
@@ -12,17 +12,15 @@ jobs:
1212
check-labels:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Check for version label
15+
- name: pull_request label
1616
run: |
17-
echo "Checking for version label on pull request..."
17+
echo "Checking for label on pull request..."
1818
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }})
1919
LABEL_NAMES=$(echo "$PR_DATA" | jq -r '.labels[].name')
2020
echo "Labels: $LABEL_NAMES"
2121
22-
REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$"
23-
MATCHES=$(echo "$LABEL_NAMES" | grep -E "$REGEX")
24-
if [ -z "$MATCHES" ]; then
25-
echo "Error: No version label found on this pull request. Please add a label in the format vX.Y.Z."
22+
if [ -z "$LABEL_NAMES" ]; then
23+
echo "Error: No label found on this pull request. Please add a label."
2624
exit 1
2725
fi
2826
env:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: pull_request version milestone
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- labeled
8+
- unlabeled
9+
- synchronize
10+
11+
jobs:
12+
check-labels:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: pull_request version milestone
16+
run: |
17+
echo "Checking for version milestone on pull request..."
18+
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }})
19+
MILESTONE_NAME=$(echo "$PR_DATA" | jq -r '.milestone.title')
20+
echo "Milestone: $MILESTONE_NAME"
21+
22+
REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$"
23+
MATCHES=$(echo "$MILESTONE_NAME" | grep -E "$REGEX")
24+
if [ -z "$MATCHES" ]; then
25+
echo "Error: No version milestone found on this pull request. Please add a milestone in the format vX.Y.Z."
26+
exit 1
27+
fi
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/conf.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import urllib3
1212
import shutil
13+
import numpy as np
1314
sys.path.insert(0, os.path.abspath('..'))
1415

1516
import sofar
@@ -117,7 +118,8 @@
117118
"navbar_start": ["navbar-logo"],
118119
"navbar_end": ["navbar-icon-links", "theme-switcher"],
119120
"navbar_align": "content",
120-
"header_links_before_dropdown": 8,
121+
"header_links_before_dropdown": None, # will be automatically set later based on headers.rst
122+
"header_dropdown_text": "Packages", # Change dropdown name from "More" to "Packages"
121123
"icon_links": [
122124
{
123125
"name": "GitHub",
@@ -152,16 +154,44 @@
152154
'_static/header.rst',
153155
'resources/logos/pyfar_logos_fixed_size_sofar.png',
154156
]
155-
c = urllib3.PoolManager()
156-
for file in folders_in:
157-
url = link + file
158-
filename = file
159-
os.makedirs(os.path.dirname(filename), exist_ok=True)
160-
with c.request('GET', url, preload_content=False) as res, open(filename, 'wb') as out_file:
161-
shutil.copyfileobj(res, out_file)
157+
158+
def download_files_from_gallery(link, folders_in):
159+
c = urllib3.PoolManager()
160+
for file in folders_in:
161+
url = link + file
162+
filename = file
163+
os.makedirs(os.path.dirname(filename), exist_ok=True)
164+
with c.request('GET', url, preload_content=False) as res:
165+
if res.status == 200:
166+
with open(filename, 'wb') as out_file:
167+
shutil.copyfileobj(res, out_file)
168+
169+
download_files_from_gallery(link, folders_in)
170+
# if logo does not exist, use pyfar logo
171+
if not os.path.exists(html_logo):
172+
download_files_from_gallery(
173+
link, ['resources/logos/pyfar_logos_fixed_size_pyfar.png'])
174+
shutil.copyfile(
175+
'resources/logos/pyfar_logos_fixed_size_pyfar.png', html_logo)
162176

163177
# replace sofar hard link to internal link
164178
with open("_static/header.rst", "rt") as fin:
165179
with open("header.rst", "wt") as fout:
166-
for line in fin:
167-
fout.write(line.replace(f'https://{project}.readthedocs.io', project))
180+
lines = [line.replace(f'https://{project}.readthedocs.io', project) for line in fin]
181+
contains_project = any(project in line for line in lines)
182+
183+
fout.writelines(lines)
184+
185+
# add project to the list of projects if not in header
186+
if not contains_project:
187+
fout.write(f' {project} <{project}>\n')
188+
189+
# count the number of gallery headings
190+
count_gallery_headings = np.sum(
191+
['https://pyfar-gallery.readthedocs.io' in line for line in lines])
192+
193+
194+
# set dropdown header after gallery headings
195+
html_theme_options['header_links_before_dropdown'] = count_gallery_headings+1
196+
197+

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ classifiers = [
2323
"Programming Language :: Python :: 3.10",
2424
"Programming Language :: Python :: 3.11",
2525
"Programming Language :: Python :: 3.12",
26+
"Programming Language :: Python :: 3.13",
2627
]
2728
dependencies = [
2829
'netCDF4',
@@ -122,6 +123,7 @@ lint.select = [
122123
[tool.ruff.lint.pydocstyle]
123124
convention = "numpy"
124125

126+
125127
[tool.bumpversion]
126128
current_version = "1.2.1"
127129
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"

0 commit comments

Comments
 (0)