Skip to content

Commit

Permalink
Add steps to generate Collections Ontology shapes documentation
Browse files Browse the repository at this point in the history
A follow-on patch will regenerate Make-managed files.

References:
* ucoProject/UCO#389

Signed-off-by: Alex Nelson <[email protected]>
  • Loading branch information
ajnelson-nist committed Jun 22, 2022
1 parent e6a12c9 commit 7fb70d4
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ When a new ontology release is created, follow these steps:
2. The version of UCO is hard-coded in `uco/Makefile` as part of titling the documentation. Update it to the new version.
3. Run `make clean`.
4. Run `make`. (`make -j` will work.)
5. Run `git add uco`. This will pick up all file deletions and new file creations.
5. Run `git add co uco`. This will pick up all file deletions and new file creations.
6. Commit the changes.
7. Push to Github.
8. Run `git pull` in the deployment space.
Expand Down
24 changes: 23 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ SHELL := /bin/bash
HOST_PREFIX ?= http://localhost

all: \
all-co \
all-uco

.PHONY: \
all-co \
all-uco \
check-service
check-co \
check-service \
check-uco


# This target checks for a file's existence to confirm that the submodule
Expand Down Expand Up @@ -63,13 +67,28 @@ all: \
dependencies/Ontospy[FULL]
touch $@

all-co: \
.venv.done.log
$(MAKE) \
--directory co

all-uco: \
.venv.done.log \
dependencies/UCO/tests/uco_monolithic.ttl
$(MAKE) \
--directory uco

check: \
check-co \
check-uco

check-co: \
all-co
$(MAKE) \
--directory co \
check

check-uco: \
all-uco
$(MAKE) \
--directory uco \
Expand Down Expand Up @@ -174,6 +193,9 @@ clean:
@$(MAKE) \
--directory uco \
clean
@$(MAKE) \
--directory co \
clean
@rm -f .*.done.log
@test ! -r dependencies/UCO/README.md \
|| $(MAKE) \
Expand Down
101 changes: 101 additions & 0 deletions co/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/make -f

# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to title 17 Section 105 of the
# United States Code this software is not subject to copyright
# protection and is in the public domain. NIST assumes no
# responsibility whatsoever for its use by other parties, and makes
# no guarantees, expressed or implied, about its quality,
# reliability, or any other characteristic.
#
# We would appreciate acknowledgement if the software is used.

SHELL := /bin/bash

top_srcdir := $(shell cd .. ; pwd)

RDF_TOOLKT_JAR := $(top_srcdir)/dependencies/UCO/lib/rdf-toolkit.jar

rdf_files := \
co.rdf

all: \
$(rdf_files) \
.symlinking.done.log \
co.ttl

.PHONY: \
clean-symlinking

.documentation.done.log: \
$(top_srcdir)/.venv.done.log \
$(top_srcdir)/dependencies/UCO/ontology/co/co.ttl
rm -rf documentation
mkdir documentation
source $(top_srcdir)/venv/bin/activate \
&& ontospy gendocs \
--outputpath $$PWD/documentation \
--theme darkly \
--title co-shapes-docs \
--type 2 \
$(top_srcdir)/dependencies/UCO/ontology/co/co.ttl
touch $@

.%.symlinking.done.log: \
%.ttl \
.documentation.done.log
source $(top_srcdir)/venv/bin/activate \
&& python3 $(top_srcdir)/src/map_concepts_as_symlinks.py \
$<

.symlinking.done.log: \
.co.symlinking.done.log

check: \
$(rdf_files)
# Test that generated RDF-XML is valid XML.
source $(top_srcdir)/venv/bin/activate \
&& rdfpipe \
--input-format xml \
--no-out \
co.rdf

clean: \
clean-symlinking
@rm -f \
*.rdf \
*.ttl \
.*.done.log
@rm -rf \
documentation

clean-symlinking:
@rm -f \
.symlinking.done.log
@find \
. \
-name '*.html' \
-type l \
-exec rm '{}' \;

co.rdf: \
$(top_srcdir)/dependencies/UCO/ontology/co/co.ttl \
$(RDF_TOOLKT_JAR) \
$(top_srcdir)/src/namespaces.sed
java -jar $(RDF_TOOLKT_JAR) \
--inline-blank-nodes \
--source $< \
--source-format turtle \
--target __$@ \
--target-format rdf-xml
sed \
-f $(top_srcdir)/src/namespaces.sed \
__$@ \
> _$@
rm __$@
mv _$@ $@

co.ttl: \
$(top_srcdir)/dependencies/UCO/ontology/co/co.ttl
cp $< $@
1 change: 1 addition & 0 deletions uco/namespaces.sed → src/namespaces.sed
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ s_&tool;_https://ontology.unifiedcyberontology.org/uco/tool/_g
s_&types;_https://ontology.unifiedcyberontology.org/uco/types/_g
s_&victim;_https://ontology.unifiedcyberontology.org/uco/victim/_g
s_&vocabulary;_https://ontology.unifiedcyberontology.org/uco/vocabulary/_g
s_&uco-co;_https://ontology.unifiedcyberontology.org/co/_g
s_&xsd;_http://www.w3.org/2001/XMLSchema#_g
Loading

0 comments on commit 7fb70d4

Please sign in to comment.