Skip to content

Commit ba4548f

Browse files
authored
Using first version of ontokit for generating documentation.
2 parents 475cd01 + 770c1a5 commit ba4548f

10 files changed

Lines changed: 448 additions & 26 deletions

.github/emmocheck_conf.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Configurations used when running emmocheck from the ci_emmocheck workflow

.github/scripts/init_ghpages.sh

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
#!/bin/bash
2+
3+
#set -x
4+
5+
help() {
6+
cat <<EOF
7+
Usage: init_ghpages.sh [OPTIONS]
8+
Initialise GitHub Pages branch.
9+
10+
Options:
11+
-h, --help Print this help and exit.
12+
-g, --ghpages BRANCH Name of GitHub Pages branch. Default: gh-pages
13+
-n, --ontology-name NAME Name of ontology.
14+
-p, --ontology-prefix PREFIX Ontology prefix.
15+
-n, --ontology-iri IRI Ontology IRI.
16+
-r, --remote Remote git repository. Default: origin
17+
18+
EOF
19+
}
20+
21+
## Defaults
22+
GHPAGES=gh-pages
23+
ONTOLOGY_NAME=
24+
ONTOLOGY_PREFIX=
25+
ONTOLOGY_IRI=
26+
REMOTE=origin
27+
28+
## Parse options
29+
TEMP=$(getopt -o hg: --long help,ghpages:,ontology: -- "$@")
30+
[ $? != 0 ] && exit 1
31+
eval set -- "$TEMP"
32+
while true; do
33+
case "$1" in
34+
-h|--help) help; exit 0;;
35+
-g|--ghpages) GHPAGES=$2; shift 2;;
36+
-n|--ontology-name) ONTOLOGY_NAME=$2; shift 2;;
37+
-p|--ontology-prefix) ONTOLOGY_PREFIX=$2; shift 2;;
38+
-i|--ontology-iri) ONTOLOGY_IRI=$2; shift 2;;
39+
-r|--remote) REMOTE=$2; shift 2;;
40+
--) shift; break;;
41+
esac
42+
done
43+
44+
current_branch="$(git branch --show-current)"
45+
rootdir="$(git rev-parse --show-toplevel)"
46+
reponame="${rootdir##*/}"
47+
48+
# Ensure that all changes are comitted
49+
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
50+
echo "There exist uncomitted changes"
51+
exit 1
52+
fi
53+
54+
# Set defaults
55+
if [ -z "$ONTOLOGY_NAME" ]; then
56+
ONTOLOGY_NAME="$reponame"
57+
ONTOLOGY_NAME="${ONTOLOGY_NAME#domain-}"
58+
ONTOLOGY_NAME="${ONTOLOGY_NAME#application-}"
59+
fi
60+
if [ ! -f "$rootdir/${ONTOLOGY_NAME}.ttl" ]; then
61+
echo "Missing ontology file: $rootdir/${ONTOLOGY_NAME}.ttl"
62+
exit 1
63+
fi
64+
65+
if [ -z "$ONTOLOGY_IRI" ]; then
66+
ONTOLOGY_IRI="$(sed -n 's/^@prefix : *<\([^>]*\)>.*/\1/p' $rootdir/${ONTOLOGY_NAME}.ttl)"
67+
ONTOLOGY_IRI=${ONTOLOGY_IRI%#}
68+
ONTOLOGY_IRI=${ONTOLOGY_IRI%/}
69+
fi
70+
71+
if [ -z "${ONTOLOGY_IRI}" ]; then
72+
echo "Empty ONTOLOGY_IRI"
73+
exit 1
74+
fi
75+
76+
if [ -z "$ONTOLOGY_PREFIX" ]; then
77+
ONTOLOGY_PREFIX="$(sed -n 's|^@prefix *\([^:]*\): *<${ONTOLOGY_IRI}>.*|\1|p' $rootdir/${ONTOLOGY_NAME}.ttl)"
78+
fi
79+
80+
have_deps=$([ -f "${rootdir}/${ONTOLOGY_NAME}-dependencies.ttl" ] && echo true || echo false)
81+
82+
83+
# Show settings
84+
echo "-- Settings:"
85+
echo " - current_branch=$current_branch"
86+
echo " - rootdir=$rootdir"
87+
echo " - reponame=$reponame"
88+
echo " - have_deps=$have_deps"
89+
echo " - GHPAGES=$GHPAGES"
90+
echo " - ONTOLOGY_NAME=$ONTOLOGY_NAME"
91+
echo " - ONTOLOGY_PREFIX=$ONTOLOGY_PREFIX"
92+
echo " - ONTOLOGY_IRI=$ONTOLOGY_IRI"
93+
echo " - REMOTE=$REMOTE"
94+
95+
96+
# Squashed ontology
97+
echo -n "-- Checking for squashed ${ONTOLOGY_NAME}.ttl "
98+
if git show "${GHPAGES}:${ONTOLOGY_NAME}.ttl" > "/tmp/${ONTOLOGY_NAME}.ttl" 2>/dev/null; then
99+
echo "- exists"
100+
else
101+
echo "- creating"
102+
ontoconvert \
103+
-sawe \
104+
--namespace="emmo:https://w3id.org/emmo#" \
105+
--namespace="${ONTOLOGY_PREFIX}:${ONTOLOGY_IRI}#" \
106+
--base-iri="${ONTOLOGY_IRI}#" \
107+
--iri="${ONTOLOGY_IRI}" \
108+
"$rootdir/${ONTOLOGY_NAME}.ttl" \
109+
"/tmp/${ONTOLOGY_NAME}.ttl"
110+
fi
111+
112+
# Squashed dependencies
113+
echo -n "-- Checking for dependencies "
114+
if $have_deps; then
115+
if git show "${GHPAGES}:${ONTOLOGY_NAME}-dependencies.ttl" >"/tmp/${ONTOLOGY_NAME}-dependencies.ttl" 2>/dev/null; then
116+
echo "- exists"
117+
else
118+
echo "- creating"
119+
ontoconvert \
120+
-saw \
121+
--namespace="emmo:https://w3id.org/emmo#" \
122+
--namespace="${ONTOLOGY_PREFIX}:${ONTOLOGY_IRI}#" \
123+
"${ONTOLOGY_NAME}-dependencies.ttl" \
124+
"/tmp/${ONTOLOGY_NAME}-dependencies.ttl"
125+
fi
126+
else
127+
echo "- missing ${ONTOLOGY_NAME}-dependencies.ttl (skipping)"
128+
fi
129+
130+
# Switch to gh-pages branch (creating it if it doesn't exists)
131+
if [ -z $(git branch --list "$GHPAGES") ]; then
132+
git switch --orphan "$GHPAGES"
133+
else
134+
git switch "$GHPAGES"
135+
fi
136+
137+
# Pull from remote
138+
git pull $REMOTE $GHPAGES 2>/dev/null
139+
140+
# Add generated files to gh-pages branch
141+
mv -f "/tmp/${ONTOLOGY_NAME}.ttl" "$rootdir/."
142+
git add "$rootdir/${ONTOLOGY_NAME}.ttl"
143+
if $have_deps; then
144+
mv -f "/tmp/${ONTOLOGY_NAME}-dependencies.ttl" "$rootdir/."
145+
git add "$rootdir/${ONTOLOGY_NAME}-dependencies.ttl"
146+
fi
147+
148+
# Commit gh-pages branch (if needed)
149+
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
150+
git commit -m "Added squashed ontology and dependencies"
151+
fi
152+
153+
# Push to remote repository
154+
git push $REMOTE $GHPAGES || exit 1
155+
156+
# Change back to original branch
157+
git checkout "$current_branch"

.github/workflows/cd_ghpages.yml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Deploy on GitHub Pages
2+
3+
# Only run this workflow on push to a release branch or master
4+
#on: push
5+
on:
6+
push:
7+
branches:
8+
- '[0-9]+.[0-9]+.[0-9]+'
9+
- '[0-9]+.[0-9]+.[0-9]+-*'
10+
- master
11+
- main
12+
- flb/test_ontokit
13+
14+
env:
15+
ONTOLOGY_NAME: atomistic
16+
ONTOLOGY_PREFIX: at
17+
ONTOLOGY_IRI: https://w3id.org/emmo/domain/atomistic
18+
GITHUB_REPOSITORY: emmo-repo/domain-atomistic
19+
20+
permissions:
21+
contents: write
22+
23+
24+
jobs:
25+
deploy-on-ghpages:
26+
#concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Python
34+
uses: actions/setup-python@v5
35+
with:
36+
python-version: 3.14
37+
38+
- name: Install EMMOntoPy and tripper
39+
run: |
40+
pip install --upgrade pip
41+
pip install \
42+
"EMMOntoPy[ontokit] @ git+https://github.com/emmo-repo/EMMOntoPy.git@master" \
43+
"tripper[datadoc] @ git+https://github.com/EMMC-ASBL/tripper.git@master"
44+
45+
#- name: Install current ontology for keywords tool
46+
# run: |
47+
# pip install -U git+
48+
49+
- name: Install ROBOT
50+
run: |
51+
mkdir bin
52+
wget -nv https://github.com/ontodev/robot/releases/download/v1.9.6/robot.jar
53+
mv robot.jar bin/.
54+
curl https://raw.githubusercontent.com/ontodev/robot/master/bin/robot > bin/robot
55+
chmod +x bin/robot
56+
ls -l bin/
57+
58+
- name: Download Widoco
59+
run: |
60+
wget --quiet https://github.com/dgarijo/Widoco/releases/download/v1.4.25/widoco-1.4.25-jar-with-dependencies_JDK-17.jar
61+
62+
- name: Copy readme and license files to gh-pages
63+
run: |
64+
mkdir build
65+
cp README.md LICENSE build/.
66+
67+
- name: Create dependencies on gh-pages
68+
run: |
69+
ontoconvert \
70+
-saw \
71+
--namespace="emmo:https://w3id.org/emmo#" \
72+
--namespace="at:https://w3id.org/emmo/domain/atomistic#" \
73+
atomistic-dependencies.ttl \
74+
build/atomistic-dependencies.ttl
75+
76+
- name: Create squashed ontology
77+
run: |
78+
ontoconvert \
79+
-sawe \
80+
--namespace="emmo:https://w3id.org/emmo#" \
81+
--namespace="at:https://w3id.org/emmo/domain/atomistic#" \
82+
--base-iri="https://w3id.org/emmo/domain/atomistic#" \
83+
--iri="https://w3id.org/emmo/domain/atomistic" \
84+
atomistic.ttl \
85+
build/atomistic.ttl
86+
87+
- name: Create ontology for used later for generating documentation
88+
run: |
89+
ontoconvert \
90+
-awe \
91+
--namespace="emmo:https://w3id.org/emmo#" \
92+
--namespace="at:https://w3id.org/emmo/domain/atomistic#" \
93+
--base-iri="https://w3id.org/emmo/domain/atomistic#" \
94+
--iri="https://w3id.org/emmo/domain/atomistic" \
95+
--copy-annotation="elucidation-->http://purl.org/dc/terms/description" \
96+
--copy-annotation="prefLabel-->http://www.w3.org/2000/01/rdf-schema#label" \
97+
atomistic.ttl \
98+
build/atomistic-doc.ttl
99+
100+
- name: Create inferred ontology
101+
run: |
102+
bin/robot reason \
103+
--reasoner HermiT \
104+
--remove-redundant-subclass-axioms true \
105+
--preserve-annotated-axioms true \
106+
--exclude-owl-thing true \
107+
--exclude-duplicate-axioms true \
108+
--input build/atomistic.ttl \
109+
--output atomistic-inferred.ttl
110+
ontoconvert --iri=https://w3id.org/emmo/domain/atomistic/inferred atomistic-inferred.ttl build/atomistic-inferred.ttl
111+
112+
- name: Generate markdown documentation of all keywords
113+
run: |
114+
keywords -i build/atomistic-doc.ttl --write-kw-md build/atomistic_kw.md --namespace-filter=https://w3id.org/emmo/domain/atomistic# --redefine=allow
115+
116+
- name: Generate Widoco documentation
117+
run: |
118+
java -jar widoco-1.4.25-jar-with-dependencies_JDK-17.jar \
119+
-ontFile build/atomistic-doc.ttl \
120+
-outFolder build/widoco \
121+
-getOntologyMetadata \
122+
-oops \
123+
-rewriteAll \
124+
-saveConfig build/widoco/widoco.conf \
125+
-webVowl \
126+
-licensius \
127+
-includeAnnotationProperties
128+
129+
- name: Generate Ontokit documentation to public
130+
run: ontokit docs --iri-regex=https://w3id.org/emmo/domain/atomistic . && touch public/.nojekyll
131+
132+
# Copy turtle files from build to public
133+
- name: Copy ontologies to public
134+
run: cp build/*ttl public/
135+
136+
# Copy widoco documentation to public, what to do with it is not yet decided.
137+
- name: Copy widoco documentation to public
138+
run: cp -r build/widoco public
139+
140+
- name: Deploy to GitHub Pages
141+
uses: JamesIves/github-pages-deploy-action@v4
142+
with:
143+
folder: public
144+
branch: gh-pages
145+
clean: false
146+
single-commit: true

.github/workflows/cd_release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release new version
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
ONTOLOGY_NAME: atomistic
9+
TAG: ${{ github.ref_name }}
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
release_version:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout gh-pages
20+
uses: actions/checkout@v4
21+
with:
22+
ref: gh-pages
23+
24+
- name: Create and copy generated files to versions/
25+
run: |
26+
mkdir -p versions/${TAG#v}
27+
cp -f \
28+
README.md \
29+
atomistic.ttl \
30+
atomistic-dependencies.ttl \
31+
atomistic-inferred.ttl \
32+
versions/${TAG#v}/.
33+
34+
- name: Push to gh-pages
35+
run: |
36+
git config --global user.email "atomistic@emmc.eu"
37+
git config --global user.name "atomistic"
38+
git add versions/${TAG#v}
39+
git commit -m "Release version ${TAG#v}"
40+
git push origin gh-pages

.github/workflows/ci_tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI tests
2+
on: [push]
3+
4+
env:
5+
ONTOLOGY_NAME: atomistic
6+
7+
jobs:
8+
ci_testing:
9+
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: 3.11
20+
21+
- name: Install EMMOntoPy
22+
run: |
23+
pip install --upgrade pip
24+
# pip install EMMOntoPy
25+
pip install -U git+https://github.com/emmo-repo/EMMOntoPy.git@master
26+
27+
- name: Test
28+
run: |
29+
emmocheck --configfile=.github/emmocheck_conf.yml atomistic.ttl

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,15 @@ Version dependencies on imported ontologies:
3030
|---------|--------------|-------------------|-------------|
3131
| 0.0.1 | 1.0.0-alpha1 | 0.0.1 | 0.0.1 |
3232
| 0.0.2 | 1.0.1 | 0.0.1 | 0.0.1 |
33-
| 0.0.3 | 1.0.1 | 0.0.1 | 0.0.1 |
33+
| 0.0.3 | 1.0.1 | N/A | N/A |
3434

3535

3636

3737
Obtaining domain-atomistic
3838
--------------------------
39-
This repository include the correct version of the crystallography and
40-
mechanics domain ontologies as a git submodules. Hence, use the
41-
following command when cloning this repository:
39+
Use the following command when cloning this repository:
4240

43-
git clone --recurse-submodules --shallow-submodules git@github.com:emmo-repo/domain-atomistic.git
41+
git clone git@github.com:emmo-repo/domain-atomistic.git
4442

4543

4644
Attributions and credits

0 commit comments

Comments
 (0)