BUILD_DOCS.tcl 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # \
  3. exec tclsh "$0" "$@"
  4. # Copyright (C) 2009 The Trustees of Indiana University.
  5. # Use, modification and distribution is subject to the Boost Software
  6. # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. # http://www.boost.org/LICENSE_1_0.txt)
  8. # Authors: Jeremiah Willcock, Andrew Lumsdaine
  9. foreach input [glob *.rst] {
  10. set output [file join html "[file rootname $input].html"]
  11. puts "Processing $input -> $output"
  12. set processor [open "|rst2html.py --stylesheet=../../../../rst.css -gdt --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript >$output" w]
  13. set inputfd [open $input r]
  14. set data [read $inputfd]
  15. close $inputfd
  16. foreach line [split $data \n] {
  17. if {[regexp {^\.\. image:: (http:.*)$} $line _ url]} {
  18. set tag $url
  19. regsub -all {.*/} $tag {} tag
  20. regsub -all {[^a-zA-Z0-9]} $tag _ tag
  21. set imageoutput [file join html "$tag.png"]
  22. puts "Getting image $url -> $imageoutput"
  23. exec wget -q -O $imageoutput $url
  24. puts $processor ".. image:: [file tail $imageoutput]"
  25. } else {
  26. puts $processor $line
  27. }
  28. }
  29. close $processor
  30. }