diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-03-28 15:34:38 +0100 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-03-28 15:34:38 +0100 |
commit | ab6a817ffc583c8abde59093f843234ac9f62189 (patch) | |
tree | 444e95d37cd2c05d3da6d6d21fd818aad477f175 | |
download | ns-a4doc-ab6a817ffc583c8abde59093f843234ac9f62189.tar.gz ns-a4doc-ab6a817ffc583c8abde59093f843234ac9f62189.tar.xz ns-a4doc-ab6a817ffc583c8abde59093f843234ac9f62189.zip |
Initial commit
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
l--------- | .gitignore | 1 | ||||
-rw-r--r-- | .gitmodules | 3 | ||||
l--------- | Makefile | 1 | ||||
-rwxr-xr-x | a4doc.py | 220 | ||||
m--------- | ontogen | 0 |
5 files changed, 225 insertions, 0 deletions
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ý <jpokorny at redhat dot com> + +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. + +<optional> + <attribute name="rrp_token_expired_timeout" a:defaultValue="47" + a4doc:danger-hint="It is not recommended to override this value without guidance from the corosync community."> + <a:documentation> + 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. + </a:documentation> + <data type="unsignedInt"/> + </attribute> +</optional> + """ + pfx = 'a4doc:' + + +class ex_relaxng_0_2(Example): + """An example snippet within RELAX NG schema. + +<optional> + <attribute name="rrp_token_expired_timeout" a:defaultValue="47"> + <a:documentation> + 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. + </a:documentation> + <a4doc:annotation> + <a4doc:hint type="danger"> + It is not recommended to override this value without guidance from + the corosync community. + </a4doc:hint> + </a4doc:annotation> + <data type="unsignedInt"/> + </attribute> +</optional> + """ + 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('''\ + # <dc:foo xmlns:dc="http://purl.org/dc/elements/1.1/" + # >Jan Pokorný</dc:foo>''') + 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 +Subproject 2341a09c090870ca12172351c9afe4e44182d02 |