Skip to content

Commit

Permalink
Version Autoselector
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan-wanna-M committed Aug 8, 2024
1 parent e9145b4 commit 8a6f230
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
target_folder: ${{ github.ref_name }}/
pre_build: |
chmod +x docs/header_gen.sh
./docs/header_gen.sh
./docs/header_gen.sh ${{ github.ref_name }}
chmod +x py_filter.sh
export VERSION=${{ github.ref_name }}
echo "PROJECT_NUMBER = $VERSION" >> Doxyfile
Expand Down
12 changes: 5 additions & 7 deletions docs/header_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def version_key(version):

# Create the parser
parser = argparse.ArgumentParser(description='Process some tags.')

parser.add_argument('--current_tag', default="", action='store', help='Current tag')
# Add the tags argument
parser.add_argument('--tags', default=[], action='store', nargs='*', help='List of tags to process')

Expand All @@ -24,9 +24,10 @@ def version_key(version):

# filter out empty tags
args.tags = [tag for tag in args.tags if tag]

options = [fr'<option value="../{i}/index.html">{i}</option>' for i in sort_versions_by_latest(args.tags)]

options = [fr'<option value="../{i}/index.html" {"selected" if i == args.current_tag else ""}>{i}</option>'
for i in sort_versions_by_latest(args.tags)]
if not args.current_tag:
options.append(r'<option value="../dev/index.html" selected>dev</option>')
options = '\n'.join(options)

html = rf"""<!-- HTML header for doxygen 1.11.0-->
Expand Down Expand Up @@ -82,10 +83,7 @@ def version_key(version):
<div id="projectname">$projectname<span id="projectnumber">&#160;$projectnumber</span>
<!-- Version Selector -->
<select id="versionSelector" onchange="location = this.value;">
<option value="none" selected disabled hidden>Select an Version</option>
<option value="../dev/index.html">dev</option>
{options}
</select>
</div>
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
Expand Down
2 changes: 1 addition & 1 deletion docs/header_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ echo "Tags: $tags"
mapfile -t tags_array <<< "$tags"

# Pass the tags to the Python script
python docs/header_gen.py --tags "${tags_array[@]}"
python docs/header_gen.py --current_tag "$1" --tags "${tags_array[@]}"

0 comments on commit 8a6f230

Please sign in to comment.