PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/iterator/doc/scanrst.py

http://hadesmem.googlecode.com/
Python | 29 lines | 17 code | 7 blank | 5 comment | 5 complexity | eb042cdc2673c43bac4af3ada26207a1 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.0, Apache-2.0, LGPL-3.0
  1. # Copyright David Abrahams 2004. Use, modification and distribution is
  2. # subject to the Boost Software License, Version 1.0. (See accompanying
  3. # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. # This script accepts a list of .rst files to be processed and
  5. # generates Makefile dependencies for .html and .rst files to stdout.
  6. import os,sys
  7. import re
  8. include = re.compile(r' *\.\. +(include|image):: +(.*)', re.MULTILINE)
  9. def deps(path, found):
  10. dir = os.path.split(path)[0]
  11. for m in re.findall(include, open(path).read()):
  12. dependency = os.path.normpath(os.path.join(dir,m[1]))
  13. if dependency not in found:
  14. found[dependency] = 1
  15. if m[0] == 'include':
  16. deps(dependency, found)
  17. return found
  18. for file in sys.argv[1:]:
  19. found = deps(file, {})
  20. if found:
  21. base = os.path.splitext(os.path.basename(file))[0]
  22. print '%s.tex %s.html: %s' % (base, base, ' '.join(found.keys()))