mirror of
https://github.com/boostorg/histogram.git
synced 2026-01-29 19:42:12 +00:00
25 lines
689 B
Python
Executable File
25 lines
689 B
Python
Executable File
import sys
|
|
import re
|
|
import glob
|
|
import os
|
|
|
|
out_dir = os.getcwd() + "/doc_test"
|
|
if not os.path.exists(out_dir):
|
|
os.mkdir(out_dir)
|
|
|
|
exi = 0
|
|
for qbk in glob.glob(os.path.dirname(__file__) + "/*.qbk"):
|
|
base = os.path.splitext(os.path.basename(qbk))[0]
|
|
for m in re.finditer("\[([^\]]+)\]``\s*([^`]+)``",
|
|
open(qbk).read()):
|
|
tag = m.group(1)
|
|
code = m.group(2)
|
|
if tag == "c++":
|
|
ext = "cpp"
|
|
elif tag == "python":
|
|
ext = "py"
|
|
else:
|
|
raise NotImplementedError("can only handle tags c++ and python")
|
|
open(out_dir + "/%s_%i.%s" % (base, exi, ext), "w").write(code)
|
|
exi += 1
|