From 3f619478f796eddbba6e39502fe941b285dd97b1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 20:00:34 +0200 Subject: Adding upstream version 1:10.11.6. Signed-off-by: Daniel Baumann --- libmariadb/scripts/create_man | 54 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 libmariadb/scripts/create_man (limited to 'libmariadb/scripts/create_man') diff --git a/libmariadb/scripts/create_man b/libmariadb/scripts/create_man new file mode 100755 index 00000000..4ff118b0 --- /dev/null +++ b/libmariadb/scripts/create_man @@ -0,0 +1,54 @@ +#!/usr/bin/python3 + +import re +import os +import argparse + +def read_content(file): + try: + f=open(file, "r") + content= f.read() + f.close() + except: + raise + return content + +def header(function, version): + hdr= "%% %s(3) Version %s | MariaDB Connector/C\n" % (function, version) + return hdr + +def replace_links(content): + links= list(re.compile(r'\[([^\]]+)\]\(([^)]+)\)').findall(content)) + for l in links: + search= "[%s()](%s)" % (l[1], l[1]) + replace= "**%s(3)**" % l[1] + content= content.replace(search, replace) + return content + +parser= argparse.ArgumentParser(prog="create_man.py", + description="Create man pages for MariaDB Connector/C") +parser.add_argument('--docs', type=str, metavar='docs', help='Directory of MariaDB Connector/C documentation') +parser.add_argument('--funcs', type=str, metavar='funcs', help='File which contains exported functions.') +parser.add_argument('--version', type=str, metavar='version', help='Connector/C version') +args= parser.parse_args() +print(args) + +func_list= read_content(args.funcs) +funcs= func_list.split(";") + +for function in funcs: + + try: + print("%s/%s.md" % (args.docs, function)) + content= read_content("%s/%s.md" % (args.docs, function)) + + except: + print("warning: No documentation for function %s found" % function) + continue + + f= open("%s.3.md" % function, "w") + f.write(header(function, args.version)) + f.write(replace_links(content)) + f.close() + ret= os.system("pandoc --standalone --to man %s.3.md -o man/%s.3" % (function, function)) + os.unlink("%s.3.md" % function) -- cgit v1.2.3