Skip to content

Commit 790b8e1

Browse files
authored
Merge pull request #211 from adafruit/add-preserve-folders-feature
Add PRESERVE_FOLDERS feature to documentation generation script
2 parents 71a8675 + 9cacd6a commit 790b8e1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,18 @@ The `doxy_gen_and_deploy.sh` script uses [Doxygen](https://www.doxygen.nl/) to g
7676
for the library. Any issues, like missing documentation, will cause the CI to fail.
7777
See the [guide](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen) for details on installing and running Doxygen locally. The guide also has some
7878
[tips](https://learn.adafruit.com/the-well-automated-arduino-library/doxygen-tips) on basic usage of Doxygen markup within your code.
79+
80+
### Preserving Folders in Documentation Branch
81+
82+
By default, the documentation deployment script cleans the gh-pages branch before adding new documentation. If you need to preserve certain folders (like custom web interfaces), you can set the `PRESERVE_FOLDERS` environment variable in your workflow:
83+
84+
```yaml
85+
- name: doxygen
86+
env:
87+
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
88+
PRETTYNAME : "My Arduino Library"
89+
PRESERVE_FOLDERS: "webserial,assets"
90+
run: bash ci/doxy_gen_and_deploy.sh
91+
```
92+
93+
This will preserve the listed folders (comma-separated) during the documentation generation process.

doxy_gen_and_deploy.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ __AUTHOR__="Jeroen de Bruijn, modified by ladyada"
1818
# Optional global variables:
1919
# - DOXYFILE : The Doxygen configuration file.
2020
# - PRETTYNAME : A string name of the project (for the doxy headers)
21+
# - PRESERVE_FOLDERS : Comma-separated list of folders to preserve during cleanup
2122
#
2223
# For information on how to encrypt variables for Travis CI please go to
2324
# https://docs.travis-ci.com/user/environment-variables/#Encrypted-Variables
@@ -84,6 +85,19 @@ git config --global push.default simple
8485
git config user.name "Doxygen CI"
8586
git config user.email "ci-arduino@invalid"
8687

88+
# Check if PRESERVE_FOLDERS is set and back them up
89+
if [ -n "$PRESERVE_FOLDERS" ]; then
90+
echo "Preserving folders: $PRESERVE_FOLDERS"
91+
mkdir -p /tmp/preserved
92+
# Move preserved folders to temp dir
93+
for folder in ${PRESERVE_FOLDERS//,/ }; do
94+
if [ -d "$folder" ]; then
95+
echo "Backing up folder: $folder"
96+
cp -r "$folder" /tmp/preserved/
97+
fi
98+
done
99+
fi
100+
87101
# Remove everything currently in the gh-pages branch.
88102
# GitHub is smart enough to know which files have changed and which files have
89103
# stayed the same and will only update the changed files. So the gh-pages branch
@@ -99,6 +113,16 @@ else
99113
rm -r -- !(index.html) || true
100114
fi
101115

116+
# Restore preserved folders if they were backed up
117+
if [ -n "$PRESERVE_FOLDERS" ]; then
118+
for folder in ${PRESERVE_FOLDERS//,/ }; do
119+
if [ -d "/tmp/preserved/$folder" ]; then
120+
echo "Restoring folder: $folder"
121+
cp -r "/tmp/preserved/$folder" ./
122+
fi
123+
done
124+
fi
125+
102126
# Need to create a .nojekyll file to allow filenames starting with an underscore
103127
# to be seen on the gh-pages site. Therefore creating an empty .nojekyll file.
104128
# Presumably this is only needed when the SHORT_NAMES option in Doxygen is set

0 commit comments

Comments
 (0)