INNER CODE UNIT · Python
comment
michelp/pgsodium · docgen.py:14
comment = s[: end + 2]
lines = comment.splitlines()
if not lines:
return
first = lines[0]
if not first.startswith("/* doctest"):
return
target = first[len("/* doctest"):].strip()
if target.startswith("/"):
target = target[1:]
if not target:
return
target = target.replace('/', '_')
stripped_comment = "\n".join(lines[1:-1]).strip() if len(lines) >= 3 else ""
out_file = os.path.join("sql", target + ".sql")
os.makedirs(os.path.dirname(out_file), exist_ok=True)
with open(out_file, "w") as out:
out.write(stripped_comment + "\n\n")