aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/update_man_page.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/update_man_page.py')
-rwxr-xr-xscripts/update_man_page.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/update_man_page.py b/scripts/update_man_page.py
new file mode 100755
index 00000000..0ae93442
--- /dev/null
+++ b/scripts/update_man_page.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+# Copyright 2020 David Robillard <d@drobilla.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+"""
+Update the serdi man page from the canonical check descriptions in serd.ttl.
+"""
+
+import serd
+import argparse
+import sys
+
+
+def run(serd_ttl_path):
+ rdf = serd.Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#")
+ rdfs = serd.Namespace("http://www.w3.org/2000/01/rdf-schema#")
+ ns_serd = serd.Namespace("http://drobilla.net/sw/serd#")
+ ns_checks = serd.Namespace("http://drobilla.net/sw/serd/checks#")
+
+ world = serd.World()
+ model = world.load(serd_ttl_path)
+ for s in model.range((None, rdf.type, ns_serd.ValidatorCheck)):
+ check = s.subject()
+ check_name = ns_checks.name(check)
+ assert check_name is not None
+
+ check_description = model.get(s.subject(), rdfs.comment)
+
+ print(".It Va {}".format(check_name))
+ print(str(check_description).replace('. ', '.\n').strip())
+
+
+if __name__ == "__main__":
+ ap = argparse.ArgumentParser(
+ usage="%(prog)s SERD_TTL_PATH",
+ description=__doc__,
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ )
+
+ ap.add_argument("serd_ttl_path", help="path to serd.ttl")
+
+ run(**vars(ap.parse_args(sys.argv[1:])))