From ab6a817ffc583c8abde59093f843234ac9f62189 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Thu, 28 Mar 2013 15:34:38 +0100 Subject: Initial commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- .gitignore | 1 + .gitmodules | 3 + Makefile | 1 + a4doc.py | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ontogen | 1 + 5 files changed, 226 insertions(+) create mode 120000 .gitignore create mode 100644 .gitmodules create mode 120000 Makefile create mode 100755 a4doc.py create mode 160000 ontogen diff --git a/.gitignore b/.gitignore new file mode 120000 index 0000000..5678c90 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +ontogen/quickstart/.gitignore \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..a7dcbb2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ontogen"] + path = ontogen + url = git://fedorapeople.org/home/fedora/jpokorny/public_git/ontogen.git diff --git a/Makefile b/Makefile new file mode 120000 index 0000000..d9b4c75 --- /dev/null +++ b/Makefile @@ -0,0 +1 @@ +ontogen/quickstart/Makefile \ No newline at end of file diff --git a/a4doc.py b/a4doc.py new file mode 100755 index 0000000..6467fe6 --- /dev/null +++ b/a4doc.py @@ -0,0 +1,220 @@ +#!/usr/bin/env python +# vim: set fileencoding=UTF-8: +# Copyright 2013 Red Hat, Inc. +# Author: Jan Pokorný + +from sys import argv +#from genshi.input import XML + +from ontogen.ontogen import Property, Class, Example, OntologyWithFigure, \ + Ontologies + +#from ontogen.ontogen import log +#log.setLevel('DEBUG') + +BASE = 'http://purl.org/net/a4doc' + + +# +# classes +# + + +# v0.2 + +# TODO: limit occurrences to 1 towards +class AnnotationItem(Class): + """abstract annotation item, use only its subclasses""" + + +#@AnnotationItem.isSuperclassOf +class Hint(AnnotationItem): + """hint-like annotation item + + The content serves to express the hint itself in a text form. + There are various types defined to optionally carry extra semantics. + """ + + +# +# properties +# + +# v0.1 + +class hint(Property): + """plain note-like annotation + + Standalone side notes for the item. + """ + range = "http://www.w3.org/2001/XMLSchema#string" + + +class dangerHint(hint): + """annotates something dangerous + + Explaining what is dangerous about touching this item (when used, + even if with an empty string, marks the current item as + dangerous/experimental). + """ + + +class deprecationHint(hint): + """annotates something deprecated + + Details about item deprecation (when used, even if with an empty + string, marks the current item as deprecated). + """ + + +class discretionHint(hint): + """annotates something one should treat with care + + Explaining why extra caution about touching this item (when used, even + if with an empty string, marks the current item as requiring discretion). + """ + + +# v0.2 + +@AnnotationItem.inRangeOf +class annotation(Property): + """connects annotation item(s) to the annotated entity""" + + +@AnnotationItem.inDomainOf +class Type(Property): + """defines type of the hint + + Expressed as a short symbolic string; recognized values include + 'danger', 'deprecation', and 'discretion' + """ + + +@AnnotationItem.inDomainOf +class content(Property): + """the actual content implicitly attached to the annotation item""" + range = "http://www.w3.org/2000/01/rdf-schema#Literal" # like RDF Schema + #range = "http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral" + #range = "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral" + + +# +# examples +# + + +class ex_relaxng_0_1(Example): + """An example snippet within RELAX NG schema. + + + + + This specifies the time in milliseconds to increment the problem + counter for the redundant ring protocol after not having received a + token from all rings for a particular processor. + + This value will automatically be calculated from the *token* timeout + and *problem_count_threshold* but may be overridden. + + + + + """ + pfx = 'a4doc:' + + +class ex_relaxng_0_2(Example): + """An example snippet within RELAX NG schema. + + + + + This specifies the time in milliseconds to increment the problem + counter for the redundant ring protocol after not having received + a token from all rings for a particular processor. + + This value will automatically be calculated from the *token* + timeout and *problem_count_threshold* but may be overridden. + + + + It is not recommended to override this value without guidance from + the corosync community. + + + + + + """ + pfx = 'a4doc:' + + +# +# ontology + versions +# + + +ontologies = Ontologies() + + +class a4doc(OntologyWithFigure): + """Documentation vocabulary for semantic highlights of eligible properties + + This vocabulary serves a purpose of annotating specific notable + semantic properties accompanied with (optional) textual details + or just standalone hints connected with annotated entity, both + of which are typically reflected in some form of documentation + (hence a4doc as typical prefix). + + Primarily created for custom RELAX NG schema annotations + via elements and attributes in the external namespace (see + the example). + """ + base_uri = BASE + #creator = XML('''\ + # Jan Pokorný''') + creator = u'Jan Pokorný' + + +@ontologies.include +class a4doc_0_1(a4doc): + version = '0.1' + issued = '2013-02-19' + modified = '2013-03-20' + properties = [ + dangerHint, + deprecationHint, + discretionHint, + hint, + ] + examples = [ + ex_relaxng_0_1, + ] + + +# different strategy than v0.1, hence no inheritance +@ontologies.include +@a4doc_0_1.supersededBy +class a4doc_0_2(a4doc): + version = '0.2' + issued = '2013-03-20' + modified = '2013-03-21' + classes = [ + AnnotationItem, + Hint, + ] + properties = [ + annotation, + content, + Type, + ] + examples = [ + ex_relaxng_0_2, + ] + + +if __name__ == '__main__': + ontologies.generate_latest(**(len(argv) > 1 and {'outfile': argv[1]} or {})) diff --git a/ontogen b/ontogen new file mode 160000 index 0000000..2341a09 --- /dev/null +++ b/ontogen @@ -0,0 +1 @@ +Subproject commit 2341a09c090870ca12172351c9afe4e44182d02c -- cgit