#!/usr/bin/env python3 import tempfile from pathlib import Path from gen_api import ROOT, parse with tempfile.TemporaryDirectory(dir=ROOT) as directory: source = Path(directory) / "wrapped.cpp" source.write_text( """// @lua-module fs FsLib // @lua-const MAX_READ_BYTES integer 65536 Largest portable // whole-file read. const luaL_Reg FUNCTIONS[] = { // --- Reads one complete // file. // @param path string Absolute file // path. // @return string|nil File // contents. {"readFile", readFile}, }; """ ) module = parse(source)[0] assert module["consts"][0][3] == "Largest portable whole-file read." doc = module["functions"][0][1] assert doc["doc"] == ["Reads one complete file."] assert doc["params"][0][2] == "Absolute file path." assert doc["returns"][0][1] == "File contents." print("ok")