Skip to content

Commit

Permalink
Update web site generation script
Browse files Browse the repository at this point in the history
  • Loading branch information
JrGoodle committed Jun 28, 2020
1 parent 75d7dff commit b6ebca4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,4 @@ clowder config clear projects # Clear config values

## Development

See [CONTRIBUTING.md](https://github.com/JrGoodle/clowder/blob/master/CONTRIBUTING.md) for information on setting up your environment for development and contribution guidelines
See [CONTRIBUTING.md](CONTRIBUTING.md) for information on setting up your environment for development and contribution guidelines
19 changes: 11 additions & 8 deletions script/update
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ fi

if [ "$1" == 'website' ]; then
cd ..
export GH_PAGES_DIR
GH_PAGES_DIR="$( cd .. && pwd)/clowder-gh-pages"
rm -rf $GH_PAGES_DIR || exit 1
git clone git@github.com:JrGoodle/clowder.git -b gh-pages $GH_PAGES_DIR || exit 1

tail -n+2 "README.md" > "$GH_PAGES_DIR/index.md" || exit 1
rm -rf "$GH_PAGES_DIR/docs/README" || exit 1
cp -a 'docs/README' "$GH_PAGES_DIR/docs/README" || exit 1
script/update_website_index.py

cd $GH_PAGES_DIR || exit 1
git add index.md docs/README || exit 1
git commit -m 'Update web site from latest in master branch' || exit 1
git push || exit 1
rm -rf "$GH_PAGES_DIR/docs/examples" || exit 1
cp -a 'docs/examples' "$GH_PAGES_DIR/docs/examples" || exit 1
rm -rf $GH_PAGES_DIR/docs/examples/*.yml || exit 1
rm -rf $GH_PAGES_DIR/docs/examples/*.sh || exit 1

# cd $GH_PAGES_DIR || exit 1
# git add index.md docs/README || exit 1
# git commit -m 'Update web site from latest in master branch' || exit 1
# git push || exit 1
exit
fi

Expand Down Expand Up @@ -57,4 +61,3 @@ case "$(uname)" in
esac

echo "Installed clowder for $PLATFORM"

38 changes: 38 additions & 0 deletions script/update_website_index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python

import os
import re
import shutil
import subprocess
from pathlib import Path
from typing import List, Optional


if 'GH_PAGES_DIR' not in os.environ:
print('GH_PAGES_DIR not set')
exit(1)

gh_pages_dir = Path(os.environ['GH_PAGES_DIR'])
print(gh_pages_dir)
path = Path.cwd()


def main():
readme_path = path / 'README.md'
readme_contents = readme_path.read_text()
readme_contents = readme_contents.splitlines()
readme_contents = readme_contents[2:]

output = "\n".join(readme_contents)
output = output.replace('](CONTRIBUTING', '](https://github.com/JrGoodle/clowder/blob/master/CONTRIBUTING')

pattern = r'\]\(docs\/(.+?(?<!\.gif))\)'
matches = re.findall(pattern, output)
replace = r'](https://github.com/JrGoodle/clowder/blob/master/docs/\1)'
output = re.sub(pattern, replace, output)

with open(str( gh_pages_dir / 'index.md'), "w") as text_file:
text_file.write(f"{output}\n")


main()

0 comments on commit b6ebca4

Please sign in to comment.