Makefile 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. site:
  2. cd en_site && ../makesite.py
  3. cd ../
  4. rm -rf static/en
  5. mv en_site/_site static/en
  6. ./makesite.py
  7. serve: site
  8. if python3 -c 'import http.server' 2> /dev/null; then \
  9. echo Running Python3 http.server ...; \
  10. cd _site && python3 -m http.server; \
  11. elif python -c 'import http.server' 2> /dev/null; then \
  12. echo Running Python http.server ...; \
  13. cd _site && python -m http.server; \
  14. elif python -c 'import SimpleHTTPServer' 2> /dev/null; then \
  15. echo Running Python SimpleHTTPServer ...; \
  16. cd _site && python -m SimpleHTTPServer; \
  17. else \
  18. echo Cannot find Python http.server or SimpleHTTPServer; \
  19. fi
  20. venv2:
  21. virtualenv ~/.venv/makesite
  22. echo . ~/.venv/makesite/bin/activate > venv
  23. . ./venv && pip install commonmark coverage
  24. venv: FORCE
  25. python3 -m venv ~/.venv/makesite
  26. echo . ~/.venv/makesite/bin/activate > venv
  27. . ./venv && pip install commonmark coverage
  28. test: FORCE
  29. . ./venv && python -m unittest -bv
  30. coverage:
  31. . ./venv && coverage run --branch --source=. -m unittest discover -bv; :
  32. . ./venv && coverage report -m
  33. . ./venv && coverage html
  34. clean:
  35. find . -name "__pycache__" -exec rm -r {} +
  36. find . -name "*.pyc" -exec rm {} +
  37. rm -rf .coverage htmlcov
  38. REV = cat /tmp/rev.txt
  39. example:
  40. #
  41. # Remove existing output directories.
  42. rm -rf _site /tmp/_site
  43. #
  44. # Create params.json for makesite-demo.
  45. echo '{ "base_path": "/makesite-demo", "site_url":' \
  46. '"https://tmug.github.io/makesite-demo" }' > params.json
  47. #
  48. # Generate the website.
  49. . ./venv && ./makesite.py
  50. rm params.json
  51. #
  52. # Get current commit ID.
  53. git rev-parse --short HEAD > /tmp/rev.txt
  54. #
  55. # Write a README for makesite-demo repository.
  56. echo makesite.py demo > _site/README.md
  57. echo ================ >> _site/README.md
  58. echo This is the HTML/CSS source of an example static >> _site/README.md
  59. echo website auto-generated with [sunainapai/makesite][makesite] >> _site/README.md
  60. echo "([$$($(REV))][commit])". >> _site/README.md
  61. echo >> _site/README.md
  62. echo Visit "<https://tmug.github.io/makesite-demo>" to >> _site/README.md
  63. echo view the example website. >> _site/README.md
  64. echo >> _site/README.md
  65. echo [makesite]: https://github.com/sunainapai/makesite >> _site/README.md
  66. echo [commit]: https://github.com/sunainapai/makesite/commit/$$($(REV)) >> _site/README.md
  67. echo [demo]: https://tmug.github.io/makesite-demo >> _site/README.md
  68. #
  69. # Publish makesite-demo.
  70. mv _site /tmp
  71. cd /tmp/_site && git init
  72. cd /tmp/_site && git config user.name Makesite
  73. cd /tmp/_site && git config user.email makesite@example.com
  74. cd /tmp/_site && git add .
  75. cd /tmp/_site && git commit -m "Auto-generated with sunainapai/makesite - $$($(REV))"
  76. cd /tmp/_site && git remote add origin https://github.com/tmug/makesite-demo.git
  77. cd /tmp/_site && git log
  78. cd /tmp/_site && git push -f origin master
  79. loc:
  80. grep -vE '^[[:space:]]*#|^[[:space:]]*$$|^[[:space:]]*"""' makesite.py | wc -l
  81. FORCE: