Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* pyrato version:
* Python version:
* Operating System:
* Did you install pyfar via pip:
* Did you install pyrato via pip:

## Description

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/has_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pull_request label

on:
pull_request:
types:
- opened
- labeled
- unlabeled
- synchronize

jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- name: pull_request label
run: |
echo "Checking for label on pull request..."
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }})
LABEL_NAMES=$(echo "$PR_DATA" | jq -r '.labels[].name')
echo "Labels: $LABEL_NAMES"

if [ -z "$LABEL_NAMES" ]; then
echo "Error: No label found on this pull request. Please add a label."
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/has_version_milestone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: pull_request version milestone

on:
pull_request:
types:
- opened
- labeled
- unlabeled
- synchronize

jobs:
check-labels:
runs-on: ubuntu-latest
steps:
- name: pull_request version milestone
run: |
echo "Checking for version milestone on pull request..."
PR_DATA=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }})
MILESTONE_NAME=$(echo "$PR_DATA" | jq -r '.milestone.title')
echo "Milestone: $MILESTONE_NAME"

REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$"
MATCHES=$(echo "$MILESTONE_NAME" | grep -E "$REGEX")
if [ -z "$MATCHES" ]; then
echo "Error: No version milestone found on this pull request. Please add a milestone in the format vX.Y.Z."
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion docs/api_reference.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _api_reference:

API Reference
==================
=============

The following gives detailed information about all pyrato functions sorted
according to their modules.
Expand Down
66 changes: 48 additions & 18 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import sys
import urllib3
import shutil
import numpy as np
sys.path.insert(0, os.path.abspath('..'))

import pyrato # noqa
Expand Down Expand Up @@ -54,9 +55,9 @@
master_doc = 'index'

# General information about the project.
project = u'pyrato'
copyright = u"2021-2023, Marco Berzborn; 2023, The pyfar developers"
author = u"The pyfar developers"
project = 'pyrato'
copyright = "2021-2023, Marco Berzborn; 2023, The pyfar developers"
author = "The pyfar developers"

# The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout
Expand Down Expand Up @@ -94,7 +95,6 @@
'numpy': ('https://numpy.org/doc/stable/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
'matplotlib': ('https://matplotlib.org/stable/', None),
'spharpy': ('https://spharpy.readthedocs.io/en/stable/', None),
'pyfar': ('https://pyfar.readthedocs.io/en/stable/', None),
}

Expand All @@ -111,13 +111,15 @@
# -- HTML theme options
# https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/layout.html
html_sidebars = {
"pyrato": []
"pyrato": []
}

html_theme_options = {
"navbar_start": ["navbar-logo"],
"navbar_end": ["navbar-icon-links", "theme-switcher"],
"navbar_align": "content",
"header_links_before_dropdown": 8,
"header_links_before_dropdown": None, # will be automatically set later based on headers.rst
"header_dropdown_text": "Packages", # Change dropdown name from "More" to "Packages"
"icon_links": [
{
"name": "GitHub",
Expand All @@ -140,7 +142,7 @@

# redirect index to pyfar.html
redirects = {
"index": f"{project}.html"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not leave it like this. Fine for me anyways...

"index": "pyrato.html"
}

# -- download navbar and style files from gallery -----------------------------
Expand All @@ -152,16 +154,44 @@
'_static/header.rst',
'resources/logos/pyfar_logos_fixed_size_pyrato.png',
]
c = urllib3.PoolManager()
for file in folders_in:
url = link + file
filename = file
os.makedirs(os.path.dirname(filename), exist_ok=True)
with c.request('GET', url, preload_content=False) as res, open(filename, 'wb') as out_file:
shutil.copyfileobj(res, out_file)

# replace pyfar hard link to internal link

def download_files_from_gallery(link, folders_in):
c = urllib3.PoolManager()
for file in folders_in:
url = link + file
filename = file
os.makedirs(os.path.dirname(filename), exist_ok=True)
with c.request('GET', url, preload_content=False) as res:
if res.status == 200:
with open(filename, 'wb') as out_file:
shutil.copyfileobj(res, out_file)

download_files_from_gallery(link, folders_in)
# if logo does not exist, use pyfar logo
if not os.path.exists(html_logo):
download_files_from_gallery(
link, ['resources/logos/pyfar_logos_fixed_size_pyfar.png'])
shutil.copyfile(
'resources/logos/pyfar_logos_fixed_size_pyfar.png', html_logo)

# replace pyrato hard link to internal link
with open("_static/header.rst", "rt") as fin:
with open("header.rst", "wt") as fout:
for line in fin:
fout.write(line.replace(f'https://{project}.readthedocs.io', project))
lines = [line.replace(f'https://{project}.readthedocs.io', project) for line in fin]
contains_project = any(project in line for line in lines)

fout.writelines(lines)

# add project to the list of projects if not in header
if not contains_project:
fout.write(f' {project} <{project}>\n')

# count the number of gallery headings
count_gallery_headings = np.sum(
['https://pyfar-gallery.readthedocs.io' in line for line in lines])


# set dropdown header after gallery headings
html_theme_options['header_links_before_dropdown'] = count_gallery_headings+1