diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2013-03-28 14:32:11 +0100 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2013-03-28 14:32:11 +0100 |
commit | ecfa44f1a8d78798ce850b63dcc618f813b225df (patch) | |
tree | ac8e78d8978078ab8c1b6859ec4f9fe4860035a5 /quickstart | |
parent | 823cb61b8532eb7234cac405d7787484a9c95a76 (diff) | |
download | ontogen-ecfa44f1a8d78798ce850b63dcc618f813b225df.tar.gz ontogen-ecfa44f1a8d78798ce850b63dcc618f813b225df.tar.xz ontogen-ecfa44f1a8d78798ce850b63dcc618f813b225df.zip |
Make the whole toolchain run smoothly incl. generating the graph
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'quickstart')
-rw-r--r-- | quickstart/Makefile | 135 | ||||
-rwxr-xr-x | quickstart/template.py | 36 |
2 files changed, 152 insertions, 19 deletions
diff --git a/quickstart/Makefile b/quickstart/Makefile new file mode 100644 index 0000000..07359b2 --- /dev/null +++ b/quickstart/Makefile @@ -0,0 +1,135 @@ +# prerequisities: +# - xsltproc +# - inkscape +# - isaviz (http://www.w3.org/2001/11/IsaViz/) + +#DEBUG = 1 +ifndef DEBUG + DEBUG = 0 +endif +ifeq (${DEBUG},0) + DEBUG_RM_DEP = rm -f -- $< +else + DEBUG_RM_DEP = +endif + +ONTOGEN_dir ?= ontogen +HTML_NSSCHEMAXSL_file = ${ONTOGEN_dir}/ns-schema.xsl +RDF_ISAVIZPREPROCESSXSL_file = ${ONTOGEN_dir}/isaviz-preprocess.xsl +RDF_ISAVIZPOSTPROCESSXSL_file = ${ONTOGEN_dir}/isaviz-postprocess.xsl + +SVG_ISAVIZ_path ?= ~/wrkspc/sw/IsaViz +SVG_ISAVIZ_runner ?= ./run.sh +SVG_ISAVIZ_cfg = ~/isaviz.cfg +SVG_ISAVIZ_font = Liberation Mono +SVG_ISAVIZ_fontsize = 10 +# LR or TB (not recommended) +SVG_ISAVIZ_orientation = LR +SVG_ISAVIZ_charcount = 30 + +SVG_BIGGERXSL_url = http://inkscape-forum.andreas-s.net/attachment/2730/bigger.xsl +#SVG_BIGGERXSL_url = http://sourceforge.net/mailarchive/attachment.php?list_name=inkscape-user&message_id=20080925142218.2ba4194e%40nrri.umn.edu +#SVG_BIGGERXSL_file ?= $(shell \ +# wget -nv -nc --content-disposition --delete-after ${SVG_BIGGERXSL_url} \ +# | cut -d' ' -f6 \ +#) +SVG_BIGGERXSL_file = bigger.xsl +SVG_BIGGERXSL_scale = 0.9 + +TARGETS_PY = $(shell \ + find -maxdepth 1 -name '*.py' -and -executable -and -type f -printf '%f\n' \ +) +TARGETS = $(TARGETS_PY:.py=) +REMOVE = ${TARGETS:=.requires} ${TARGETS:=.1.rdf} ${TARGETS:=.1.svg} ${TARGETS:=.2.svg} +REMOVE_SYMLINKS = ${TARGETS:=.rdf} ${TARGETS:=.html} ${TARGETS:=.svg} + +.PHONY = ${TARGETS} clean mrproper + +# top-level wrapper +${TARGETS}: %: %.requires + ${DEBUG_RM_DEP} + +ifneq ($(MAKECMDGOALS),clean) + $(foreach target,${TARGETS},$(eval -include ${target:=.requires})) +endif + +# rdf + html +$(TARGETS:=.requires): %.requires: %.rdf + touch $< + +$(TARGETS:=.rdf) : %.rdf: %.py + ./$< AUTO | grep -E '^self-figure: ' | cut -d' ' -f2 \ + | xargs -I'{}' find -L {} -printf '$(@:.rdf=): %f\n' \ + >> $(@:.rdf=.requires) + # ^ -not/-empty condition? + +# only used if html accidentally deleted and rdf kept +$(TARGETS:=.html):: %.html: %.rdf + xsltproc --stringparam xmlfile $< ${HTML_NSSCHEMAXSL_file} $< > $@ + +$(TARGETS:=.svg): %.svg: %.2.svg ${SVG_BIGGERXSL_file} + xsltproc --stringparam scale ${SVG_BIGGERXSL_scale} \ + ${SVG_BIGGERXSL_file} $< > $@ + inkscape $@ --verb FitCanvasToDrawing --verb FileVacuum \ + --verb FileSave --verb FileClose + ${DEBUG_RM_DEP} + +$(TARGETS:=.1.rdf): %.1.rdf: %.rdf ${RDF_ISAVIZPREPROCESSXSL_file} + xsltproc ${RDF_ISAVIZPREPROCESSXSL_file} $< > $@ + +$(TARGETS:=.2.svg): %.2.svg: %.1.svg ${RDF_ISAVIZPOSTPROCESSXSL_file} + xsltproc ${RDF_ISAVIZPOSTPROCESSXSL_file} $< > $@ + ${DEBUG_RM_DEP} + +$(TARGETS:=.1.svg): %.svg: %.rdf ${SVG_ISAVIZ_path}/${SVG_ISAVIZ_runner} + @echo " Sorry, this part currently requires manual actions:" + @echo " 1. File - Import - Replace - RDF/XML from file: $<" + @echo " 2. View - Suggest Layout (only to get a better form; 14pt?)" + @echo " 3. Optionally increase font size for better final look" + @echo " via Edit - Preferences - Rendering/GSS" + @echo " 4. Export - SVG: $@" + mv ${SVG_ISAVIZ_cfg} ${SVG_ISAVIZ_cfg}.$(@:.1.svg=) || : + touch ${SVG_ISAVIZ_cfg} + echo '<?xml version="1.0" encoding="UTF-8"?>' >>${SVG_ISAVIZ_cfg} + echo '<isv:config xmlns:isv="http://www.w3.org/2001/10/IsaViz">' >>${SVG_ISAVIZ_cfg} + echo ' <isv:directories>' >>${SVG_ISAVIZ_cfg} + echo ' <isv:tmpDir value="true">/tmp</isv:tmpDir>' >>${SVG_ISAVIZ_cfg} + echo ' <isv:projDir>/tmp</isv:projDir>' >>${SVG_ISAVIZ_cfg} + echo ' <isv:rdfDir>$(CURDIR)</isv:rdfDir>' >>${SVG_ISAVIZ_cfg} + echo ' <isv:dotExec>/bin/dot</isv:dotExec>' >>${SVG_ISAVIZ_cfg} + #echo ' <isv:graphvizFontDir>/tmp</isv:graphvizFontDir>' >>${SVG_ISAVIZ_cfg} + echo ' </isv:directories>' >>${SVG_ISAVIZ_cfg} + echo ' <isv:constants abbrevSyntax="true"' >>${SVG_ISAVIZ_cfg} + echo ' alwaysIncludeLang="false"' >>${SVG_ISAVIZ_cfg} + echo ' anonymousNodes="genid:"' >>${SVG_ISAVIZ_cfg} + echo ' antialiasing="false"' >>${SVG_ISAVIZ_cfg} + echo ' backgroundColor="-1579033"' >>${SVG_ISAVIZ_cfg} + echo ' defaultLang="en"' >>${SVG_ISAVIZ_cfg} + echo ' defaultNamespace=""' >>${SVG_ISAVIZ_cfg} + echo ' displayLabels="false"' >>${SVG_ISAVIZ_cfg} + echo ' graphFont="${SVG_ISAVIZ_font} Plain ${SVG_ISAVIZ_fontsize}"' \ + >>${SVG_ISAVIZ_cfg} + echo ' graphOrient="${SVG_ISAVIZ_orientation}"' >>${SVG_ISAVIZ_cfg} + echo ' incGSSstyling="false"' >>${SVG_ISAVIZ_cfg} + echo ' maxLitCharCount="${SVG_ISAVIZ_charcount}"' >>${SVG_ISAVIZ_cfg} + echo ' parsingMode="0"' >>${SVG_ISAVIZ_cfg} + echo ' prefixInTf="true"' >>${SVG_ISAVIZ_cfg} + echo ' saveWindowLayout="false"' >>${SVG_ISAVIZ_cfg} + echo ' showAnonIds="false" swingFont="SansSerif Plain 12"/>' \ + >>${SVG_ISAVIZ_cfg} + echo '</isv:config>' >>${SVG_ISAVIZ_cfg} + pushd ${SVG_ISAVIZ_path} 2>/dev/null && \ + ( ${SVG_ISAVIZ_runner} || : ) && \ + popd 2>/dev/null + mv ${SVG_ISAVIZ_cfg}.$(@:.1.svg=) ${SVG_ISAVIZ_cfg} || rm -f ${SVG_ISAVIZ_cfg} + ${DEBUG_RM_DEP} + +${SVG_BIGGERXSL_file}: + wget -nv -nc --content-disposition ${SVG_BIGGERXSL_url} -O- > $@ + +clean: + for f in ${REMOVE_SYMLINKS}; do rm -f -- $$(readlink $$f) $$f; done + rm -f -- ${REMOVE} + +mrproper: clean + rm -f -- ${SVG_BIGGERXSL_file} diff --git a/quickstart/template.py b/quickstart/template.py index 0eaea7f..ead6874 100755 --- a/quickstart/template.py +++ b/quickstart/template.py @@ -4,9 +4,13 @@ from sys import argv #from genshi.input import XML -from ontogen.ontogen import Property, Class, Example, Ontology, Ontologies +from ontogen.ontogen import Property, Class, Example, OntologyWithFigure, \ + Ontologies -BASE = 'http://purl.org/net/foo' +#from ontogen.ontogen import log +#log.setLevel('DEBUG') + +BASE = 'http://example.org/net/template' # @@ -26,6 +30,7 @@ class TFoo(Foo): Represents foos that are special because of the T-shape. """ + # # properties # @@ -49,21 +54,15 @@ class baz(bar): # examples # -# v0.1 - -class ex_0_1_schema(Example): - """Illustrative figure of the vocabulary.""" - image = '0.1.svg' - class ex_0_1(Example): """An example snippet. -<foo:tfoo about="#mytfoo"> - <foo:baz>test</foo:baz> -</foo:tfoo> +<tmpl:tfoo about="#mytfoo"> + <tmpl:baz>test</tmpl:baz> +</tmpl:tfoo> """ - pfx = 'foo:' + pfx = 'tmpl:' # @@ -74,7 +73,7 @@ class ex_0_1(Example): ontologies = Ontologies() -class foo(Ontology): +class template(OntologyWithFigure): """Descriptive vocabulary for foos This vocabulary serves a purpose of shedding light into semantics @@ -82,13 +81,13 @@ class foo(Ontology): """ base_uri = BASE #creator = XML('''\ - # <dc:foo xmlns:dc="http://purl.org/dc/elements/1.1/" - # >John Doe</dc:foo>''') + # <dc:X xmlns:dc="http://purl.org/dc/elements/1.1/" + # >John Doe</dc:X>''') creator = 'John Doe' @ontologies.include -class foo_0_1(foo): +class template_0_1(template): version = '0.1' issued = '2013-02-19' modified = '2013-03-20' @@ -101,14 +100,13 @@ class foo_0_1(foo): baz, ] examples = [ - ex_0_1_schema, ex_0_1, ] #@ontologies.include -#@foo_0_1.supersededBy -#class foo_0_2(foo): +#@template_0_1.supersededBy +#class template_0_2(template): # ... |