diff options
author | David Robillard <d@drobilla.net> | 2021-03-08 23:25:35 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-09 01:43:52 -0500 |
commit | 7b954f5667e82de1b64984a9aeb26b8ebb5cab81 (patch) | |
tree | 5668f80ce2dc7a52cf66bbe2f4e4429b18f09e08 /scripts/update_man_page.py | |
parent | c579186c5dd4e11bffddd353cef8978a66ef9c10 (diff) | |
download | serd1-meson.tar.gz serd1-meson.tar.bz2 serd1-meson.zip |
WIP: Validationserd1-meson
Diffstat (limited to 'scripts/update_man_page.py')
-rwxr-xr-x | scripts/update_man_page.py | 54 |
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:]))) |