jamfile.jam 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #|
  2. Copyright 2004,2006 Vladimir Prus
  3. Copyright 2018 Rene Rivera
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
  6. |#
  7. #|
  8. Doc generation works in two modes: standalone embedded and website.
  9. For the standalone we just generate the local html for inclusion in a release
  10. archive. This is the default when no arguments are given.
  11. For the website we clone the website branch locally, generatate the docs in
  12. the website tree, commit, and push. The default for those arguments is to
  13. build as if we are doing "develop" branch docs.
  14. b2 --website-dir=website --website-doc-dir=manual/develop website
  15. Building documentation has only been tested on Posix systems and requires:
  16. * Ruby
  17. * Python 2
  18. * gem install asciidoctor
  19. * gem install pygments.rb
  20. * pip install --user Pygments
  21. * pip install --user https://github.com/bfgroup/jam_pygments/archive/master.zip
  22. |#
  23. import asciidoctor ;
  24. import modules ;
  25. import path ;
  26. project b2doc
  27. ;
  28. path-constant PYGMENTS_DIR : src/pygments ;
  29. path-constant STYLES_DIR : src/styles ;
  30. doc-dir = [ MATCH "--doc-dir=(.*)" : [ modules.peek : ARGV ] ] ;
  31. doc-dir ?= html ;
  32. website = [ MATCH "(website)" : [ modules.peek : ARGV ] ] ;
  33. website-dir = [ MATCH "--website-dir=(.*)" : [ modules.peek : ARGV ] ] ;
  34. website-dir ?= website ;
  35. website-doc-dir = [ MATCH "--website-doc-dir=(.*)" : [ modules.peek : ARGV ] ] ;
  36. website-doc-dir ?= manual/develop ;
  37. if $(website)
  38. {
  39. doc-dir = $(website-dir)/$(website-doc-dir) ;
  40. }
  41. # ECHO $(website) .. $(website-dir) .. $(website-doc-dir) .. $(doc-dir) ;
  42. html index : src/standalone.adoc :
  43. :
  44. # <flags>--require=$(PYGMENTS_DIR)/pygments_init.rb
  45. <flags>--trace
  46. <flags>--verbose
  47. # <dependency>$(PYGMENTS_DIR)/pygments_init.rb
  48. # <flags>"-a stylesheet=amber.css"
  49. # <flags>"-a stylesdir=$(STYLES_DIR)"
  50. # <asciidoctor-attribute>linkcss
  51. ;
  52. explicit index ;
  53. install html : index : <location>$(doc-dir) <dependency>website-html ;
  54. explicit html ;
  55. make index.html : : @make_redir_html : <location>.. ;
  56. REDIR_HTML = "
  57. <html><head><meta http-equiv=\"refresh\" content=\"0; URL=doc/html/index.html\"></head><body>
  58. Automatic redirection failed, please go to <a href=\"doc/html/index.html\">doc/html/index.html</a>.
  59. <!-- Distributed under the Boost Software License, Version 1.0. \(See accompanying file LICENSE.txt or copy at https://www.bfgroup.xyz/b2/LICENSE.txt\) -->
  60. </body></html>
  61. " ;
  62. actions make_redir_html
  63. {
  64. echo @($(<):O=F:E=$(REDIR_HTML))
  65. }
  66. explicit index.html ;
  67. alias standalone-html : html ;
  68. if $(website)
  69. {
  70. make website-checkout : : @website-checkout ;
  71. make website-publish : html : @website-publish ;
  72. alias website-html : website-checkout ;
  73. always website-checkout ;
  74. always website-publish ;
  75. }
  76. else
  77. {
  78. alias website-checkout ;
  79. alias website-publish ;
  80. alias website-html ;
  81. }
  82. alias website : website-publish ;
  83. explicit website-checkout ;
  84. explicit website-publish ;
  85. explicit website-html ;
  86. explicit website ;
  87. ###############################################################################
  88. actions website-checkout
  89. {
  90. rm -rf "$(website-dir)"
  91. git clone --verbose --branch gh-pages --depth 1 "https://${GH_TOKEN}github.com/bfgroup/b2.git" "$(website-dir)" || exit 1
  92. CD=${PWD}
  93. cd "$(website-dir)"
  94. git rm --ignore-unmatch -r "$(website-doc-dir)" || exit 1
  95. mkdir -p "$(website-doc-dir)" || exit 1
  96. cd ${CD}
  97. echo "done" > "$(<)"
  98. }
  99. actions website-publish
  100. {
  101. CD=${PWD}
  102. cd "$(website-dir)/$(website-doc-dir)"
  103. git config user.email "b2-bot"
  104. git config user.name "b2-bot"
  105. git add --verbose . || exit 1
  106. git commit -m "Update user manual."
  107. git push || exit 1
  108. cd ${CD}
  109. rm -rf "$(website-dir)"
  110. echo "done" > "$(<)"
  111. }
  112. ###############################################################################
  113. alias boostdoc ;
  114. explicit boostdoc ;
  115. alias boostrelease : standalone-html index.html ;
  116. explicit boostrelease ;