initialize_values(data)
- rel_path = os.path.relpath(args.page, data["_PAGE_ROOT"])
- rel_path_no_type, file_type = os.path.splitext(rel_path)
- namespace = split_path(rel_path_no_type)
- os.makedirs(os.path.join(data["_OUT"], os.path.split(rel_path)[0]), exist_ok=True)
- if file_type == ".md":
- rel_path = rel_path_no_type + ".html"
- with open(os.path.join(data["_OUT"], rel_path), "w") as out_file:
- out_file.write(generate_output(args.page, data, namespace))
+ if not args.pages:
+ pages = []
+ for dir in os.walk(data["_PAGE_ROOT"]):
+ for file in dir[2]:
+ pages.append(os.path.join(dir[0], file))
+ else:
+ pages = args.pages
+
+ for page in pages:
+ rel_path = os.path.relpath(page, data["_PAGE_ROOT"])
+ rel_path_no_type, file_type = os.path.splitext(rel_path)
+ namespace = split_path(rel_path_no_type)
+ os.makedirs(
+ os.path.join(data["_OUT"], os.path.split(rel_path)[0]), exist_ok=True
+ )
+ if file_type == ".md":
+ rel_path = rel_path_no_type + ".html"
+ with open(os.path.join(data["_OUT"], rel_path), "w") as out_file:
+ out_file.write(generate_output(page, data, namespace))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument("--page", type=str)
+ parser.add_argument("--pages", type=str, nargs="*")
parser.add_argument("--page-root", type=str)
parser.add_argument("--templates", type=str)
parser.add_argument("--data", default="data.toml", type=argparse.FileType("rb"))