pylode 3.5.0__tar.gz → 3.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pylode-3.5.0 → pylode-3.5.2}/PKG-INFO +26 -40
- {pylode-3.5.0 → pylode-3.5.2}/README.md +25 -37
- {pylode-3.5.0 → pylode-3.5.2}/pylode/__init__.py +1 -1
- {pylode-3.5.0 → pylode-3.5.2}/pylode/cli.py +6 -3
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/__init__.py +1 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/ontpub.py +25 -88
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/query/__init__.py +9 -9
- pylode-3.5.2/pylode/profiles/valpub.py +421 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/vocpub.py +110 -174
- {pylode-3.5.0 → pylode-3.5.2}/pylode/pylode.css +17 -1
- pylode-3.5.0/pylode/rdf/ontdoc.ttl → pylode-3.5.2/pylode/rdf/ontpub.ttl +36 -32
- pylode-3.5.2/pylode/rdf/reg-statuses.ttl +188 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/sdo-mod.ttl +1 -1
- pylode-3.5.2/pylode/rdf/shacl.ttl +2057 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf_elements.py +168 -87
- {pylode-3.5.0 → pylode-3.5.2}/pylode/utils.py +145 -62
- pylode-3.5.2/pyproject.toml +63 -0
- pylode-3.5.0/pyproject.toml → pylode-3.5.2/pyproject.toml.orig +1 -3
- {pylode-3.5.0 → pylode-3.5.2}/pylode/__main__.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/__init__.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/component/__init__.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/component/example.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/component/heading.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/component/link.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/component/preamble.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/component/properties_table.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/component/tooltip.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/dataset.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/fragment.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/html.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/loader.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/model.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/namespace.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/query/common.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/query/property_shape.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/random.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/profiles/supermodel/state.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/dcterms-mod.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/licenses.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/owl.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/prov.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/rdf.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/rdfs-mod.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/skos.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/rdf/void.ttl +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/server.py +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/static/asciidoc.css +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/static/hierarchy.css +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/static/hierarchy.js +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/static/property-table-row.js +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/static/pylode.css +0 -0
- {pylode-3.5.0 → pylode-3.5.2}/pylode/version.py +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pylode
|
|
3
|
-
Version: 3.5.
|
|
3
|
+
Version: 3.5.2
|
|
4
4
|
Summary: An OWL ontology documentation tool using Python, based on LODE.
|
|
5
5
|
Author: Nicholas Car
|
|
6
6
|
Author-email: Nicholas Car <nick@kurrawong.ai>
|
|
7
7
|
License-Expression: BSD-3-Clause
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
11
9
|
Classifier: Programming Language :: Python :: 3.12
|
|
12
10
|
Classifier: Programming Language :: Python :: 3.13
|
|
13
11
|
Classifier: Programming Language :: Python :: 3.14
|
|
@@ -38,25 +36,7 @@ An OWL ontology documentation tool using Python, based on LODE.
|
|
|
38
36
|
|
|
39
37
|
In addition to making web page, human-readable forms of ontologies, pyLODE encourages ontology annotation *best practice* by only producing good results for well documented inputs! pyLODE defines what it considers “well documented” in sections below, e.g. [What pyLODE understands](#what-pylode-understands).
|
|
40
38
|
|
|
41
|
-
**New mode**: In v3.1.0, pyLODE now has a new mode called `supermodel`, in addition to the existing `ontpub`
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
## A note on the v 3.x change
|
|
46
|
-
|
|
47
|
-
This is pyLODE version 3.0.1 and it’s vastly different from pyLODE 2.x. It doesn’t yet handle all the various “profiles” that pyLODE 2.13.2 does, such as SKOS “vocabularies” & Profiles Vocabulary “profiles”, it only handles OWL “ontologies”, nor all the special data types, such as JSON literals.
|
|
48
|
-
|
|
49
|
-
However, it generates HTML in a much more straightforward manner and the code is both more efficient and much more maintainable, which is why it’s been made.
|
|
50
|
-
|
|
51
|
-
v 3.x will eventually catch up to all of v 2.13.2’s features.
|
|
52
|
-
|
|
53
|
-
To access v 2.13.2 of pyLODE, either:
|
|
54
|
-
|
|
55
|
-
- [Download it from PyPI](https://pypi.org/project/pylode/2.13.2/)
|
|
56
|
-
- [Check it out from GitHub](https://github.com/RDFLib/pyLODE/releases/tag/2.13.2)
|
|
57
|
-
- Access it via the [online service](http://tools.kurrawong.ai/pylode)
|
|
58
|
-
|
|
59
|
-
---
|
|
39
|
+
**New mode**: In v3.1.0, pyLODE now has a new mode called `supermodel`, in addition to the existing `ontpub` & `vocpub` modes. This new mode allows for documenting **profiles and modules** of multipart models. See [supermodel.md](supermodel.md) for more information.
|
|
60
40
|
|
|
61
41
|
## Contents
|
|
62
42
|
|
|
@@ -101,20 +81,23 @@ The tool can be used in multiple ways:
|
|
|
101
81
|
### Command line arguments
|
|
102
82
|
|
|
103
83
|
```text
|
|
104
|
-
usage:
|
|
84
|
+
usage: pylode [-h] [-v] [-o OUTPUTFILE] [-c {true,false}] [-s] [-p {ontpub,vocpub,supermodel}] [-l {error,warning,info,debug}] input
|
|
105
85
|
|
|
106
86
|
positional arguments:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
87
|
+
input Input file location or URL
|
|
88
|
+
|
|
89
|
+
options:
|
|
90
|
+
-h, --help show this help message and exit
|
|
91
|
+
-v, --version show program's version number and exit
|
|
92
|
+
-o, --outputfile OUTPUTFILE
|
|
93
|
+
A name you wish to assign to the output file. Will be postfixed with .html if not already added. If no output file is given, output will be printed to screen
|
|
94
|
+
-c, --css {true,false}
|
|
95
|
+
Whether (true) or not (false) to include CSS within an output HTML file.
|
|
96
|
+
-s, --sort Enables sorting of the subjects in the ontology in the output
|
|
97
|
+
-p, --profile {ontpub,vocpub,supermodel}
|
|
98
|
+
Which profile to use to generate HTML. Must be one of 'ontpub' (https://linked.data.gov.au/def/ontpub) - for ontologies, 'vocpub' (https://linked.data.gov.au/def/vocpub) - for SKOS vocabularies, 'supermodel' - for profiles of profiles
|
|
99
|
+
-l, --loglevel {error,warning,info,debug}
|
|
100
|
+
Set the logging level
|
|
118
101
|
```
|
|
119
102
|
|
|
120
103
|
### Basic Use
|
|
@@ -125,6 +108,12 @@ optional arguments:
|
|
|
125
108
|
python pylode examples/ontpub/minimal.ttl -o minimal.html
|
|
126
109
|
```
|
|
127
110
|
|
|
111
|
+
for a SKOS vocabulary, indicate the `vocpub` profile:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
python pylode examples/vocpub/GeologicSpecimenMaterialTypes.ttl -o GeologicSpecimenMaterialTypes.html -p vocpub
|
|
115
|
+
```
|
|
116
|
+
|
|
128
117
|
#### As a Docker container
|
|
129
118
|
|
|
130
119
|
```bash
|
|
@@ -305,9 +294,6 @@ Older releases
|
|
|
305
294
|
|
|
306
295
|
| Version | Date | Description |
|
|
307
296
|
|---------|------------------|---------------------------------------------------------------------------------|
|
|
308
|
-
| 3.0.5 | 27 April 2023 | Minor patching |
|
|
309
|
-
| 3.0.4 | 24 May 2022 | Use of Poetry |
|
|
310
|
-
| 3.0.2 | 24 May 2022 | Support for preformatted skos:example literals |
|
|
311
297
|
| 3.0.1 | 6 Jan 2022 | Direct HTML generation using dominate; easier to maintain and extend |
|
|
312
298
|
| 2.13.2 | 21 December 2021 | Updated RDFlib to 6.1.1, improved test to properly use pytest |
|
|
313
299
|
| 2.10.0 | 24 May 2021 | Update Windows EXE build process, simplified versioning |
|
|
@@ -355,11 +341,11 @@ Nicholas Car
|
|
|
355
341
|
2. pass all tests: `$ task test`
|
|
356
342
|
3. increment version number in `pyproject.toml`
|
|
357
343
|
4. commit all changes `$ git commit -a "..."`
|
|
358
|
-
5. tag with version number: `$git tag ...`
|
|
344
|
+
5. tag with version number: `$ git tag ...`
|
|
359
345
|
6. push changes `$ git push`
|
|
360
346
|
7. push version `git push --tags`
|
|
361
|
-
|
|
347
|
+
8. make a GitHub release
|
|
362
348
|
* PyPI release is automated from this in `pypi.yml`
|
|
363
349
|
9. increment version number to next release alpha in `pyproject.toml`
|
|
364
350
|
10. commit all changes `$ git commit -a "..."`
|
|
365
|
-
|
|
351
|
+
11. push changes `$ git push`
|
|
@@ -7,25 +7,7 @@ An OWL ontology documentation tool using Python, based on LODE.
|
|
|
7
7
|
|
|
8
8
|
In addition to making web page, human-readable forms of ontologies, pyLODE encourages ontology annotation *best practice* by only producing good results for well documented inputs! pyLODE defines what it considers “well documented” in sections below, e.g. [What pyLODE understands](#what-pylode-understands).
|
|
9
9
|
|
|
10
|
-
**New mode**: In v3.1.0, pyLODE now has a new mode called `supermodel`, in addition to the existing `ontpub`
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## A note on the v 3.x change
|
|
15
|
-
|
|
16
|
-
This is pyLODE version 3.0.1 and it’s vastly different from pyLODE 2.x. It doesn’t yet handle all the various “profiles” that pyLODE 2.13.2 does, such as SKOS “vocabularies” & Profiles Vocabulary “profiles”, it only handles OWL “ontologies”, nor all the special data types, such as JSON literals.
|
|
17
|
-
|
|
18
|
-
However, it generates HTML in a much more straightforward manner and the code is both more efficient and much more maintainable, which is why it’s been made.
|
|
19
|
-
|
|
20
|
-
v 3.x will eventually catch up to all of v 2.13.2’s features.
|
|
21
|
-
|
|
22
|
-
To access v 2.13.2 of pyLODE, either:
|
|
23
|
-
|
|
24
|
-
- [Download it from PyPI](https://pypi.org/project/pylode/2.13.2/)
|
|
25
|
-
- [Check it out from GitHub](https://github.com/RDFLib/pyLODE/releases/tag/2.13.2)
|
|
26
|
-
- Access it via the [online service](http://tools.kurrawong.ai/pylode)
|
|
27
|
-
|
|
28
|
-
---
|
|
10
|
+
**New mode**: In v3.1.0, pyLODE now has a new mode called `supermodel`, in addition to the existing `ontpub` & `vocpub` modes. This new mode allows for documenting **profiles and modules** of multipart models. See [supermodel.md](supermodel.md) for more information.
|
|
29
11
|
|
|
30
12
|
## Contents
|
|
31
13
|
|
|
@@ -70,20 +52,23 @@ The tool can be used in multiple ways:
|
|
|
70
52
|
### Command line arguments
|
|
71
53
|
|
|
72
54
|
```text
|
|
73
|
-
usage:
|
|
55
|
+
usage: pylode [-h] [-v] [-o OUTPUTFILE] [-c {true,false}] [-s] [-p {ontpub,vocpub,supermodel}] [-l {error,warning,info,debug}] input
|
|
74
56
|
|
|
75
57
|
positional arguments:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
input Input file location or URL
|
|
59
|
+
|
|
60
|
+
options:
|
|
61
|
+
-h, --help show this help message and exit
|
|
62
|
+
-v, --version show program's version number and exit
|
|
63
|
+
-o, --outputfile OUTPUTFILE
|
|
64
|
+
A name you wish to assign to the output file. Will be postfixed with .html if not already added. If no output file is given, output will be printed to screen
|
|
65
|
+
-c, --css {true,false}
|
|
66
|
+
Whether (true) or not (false) to include CSS within an output HTML file.
|
|
67
|
+
-s, --sort Enables sorting of the subjects in the ontology in the output
|
|
68
|
+
-p, --profile {ontpub,vocpub,supermodel}
|
|
69
|
+
Which profile to use to generate HTML. Must be one of 'ontpub' (https://linked.data.gov.au/def/ontpub) - for ontologies, 'vocpub' (https://linked.data.gov.au/def/vocpub) - for SKOS vocabularies, 'supermodel' - for profiles of profiles
|
|
70
|
+
-l, --loglevel {error,warning,info,debug}
|
|
71
|
+
Set the logging level
|
|
87
72
|
```
|
|
88
73
|
|
|
89
74
|
### Basic Use
|
|
@@ -94,6 +79,12 @@ optional arguments:
|
|
|
94
79
|
python pylode examples/ontpub/minimal.ttl -o minimal.html
|
|
95
80
|
```
|
|
96
81
|
|
|
82
|
+
for a SKOS vocabulary, indicate the `vocpub` profile:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python pylode examples/vocpub/GeologicSpecimenMaterialTypes.ttl -o GeologicSpecimenMaterialTypes.html -p vocpub
|
|
86
|
+
```
|
|
87
|
+
|
|
97
88
|
#### As a Docker container
|
|
98
89
|
|
|
99
90
|
```bash
|
|
@@ -274,9 +265,6 @@ Older releases
|
|
|
274
265
|
|
|
275
266
|
| Version | Date | Description |
|
|
276
267
|
|---------|------------------|---------------------------------------------------------------------------------|
|
|
277
|
-
| 3.0.5 | 27 April 2023 | Minor patching |
|
|
278
|
-
| 3.0.4 | 24 May 2022 | Use of Poetry |
|
|
279
|
-
| 3.0.2 | 24 May 2022 | Support for preformatted skos:example literals |
|
|
280
268
|
| 3.0.1 | 6 Jan 2022 | Direct HTML generation using dominate; easier to maintain and extend |
|
|
281
269
|
| 2.13.2 | 21 December 2021 | Updated RDFlib to 6.1.1, improved test to properly use pytest |
|
|
282
270
|
| 2.10.0 | 24 May 2021 | Update Windows EXE build process, simplified versioning |
|
|
@@ -324,11 +312,11 @@ Nicholas Car
|
|
|
324
312
|
2. pass all tests: `$ task test`
|
|
325
313
|
3. increment version number in `pyproject.toml`
|
|
326
314
|
4. commit all changes `$ git commit -a "..."`
|
|
327
|
-
5. tag with version number: `$git tag ...`
|
|
315
|
+
5. tag with version number: `$ git tag ...`
|
|
328
316
|
6. push changes `$ git push`
|
|
329
317
|
7. push version `git push --tags`
|
|
330
|
-
|
|
318
|
+
8. make a GitHub release
|
|
331
319
|
* PyPI release is automated from this in `pypi.yml`
|
|
332
320
|
9. increment version number to next release alpha in `pyproject.toml`
|
|
333
321
|
10. commit all changes `$ git commit -a "..."`
|
|
334
|
-
|
|
322
|
+
11. push changes `$ git push`
|
|
@@ -4,7 +4,7 @@ import sys
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
|
|
6
6
|
sys.path.insert(0, str(Path(__file__).absolute().parent.parent))
|
|
7
|
-
from pylode import OntPub, PylodeError, Supermodel, VocPub, __version__
|
|
7
|
+
from pylode import OntPub, PylodeError, Supermodel, ValPub, VocPub, __version__
|
|
8
8
|
|
|
9
9
|
parser = argparse.ArgumentParser()
|
|
10
10
|
|
|
@@ -46,9 +46,10 @@ parser.add_argument(
|
|
|
46
46
|
"--profile",
|
|
47
47
|
help="Which profile to use to generate HTML. Must be one of "
|
|
48
48
|
"'ontpub' (https://linked.data.gov.au/def/ontpub) - for ontologies, "
|
|
49
|
-
"'
|
|
49
|
+
"'valpub' (https://linked.data.gov.au/def/valpub) - for SHACL Shapes Graphs, "
|
|
50
|
+
"'vocpub' (https://linked.data.gov.au/def/vocpub) - for SKOS vocabularies, "
|
|
50
51
|
"'supermodel' - for profiles of profiles",
|
|
51
|
-
choices=["ontpub", "vocpub", "supermodel"],
|
|
52
|
+
choices=["ontpub", "valpub", "vocpub", "supermodel"],
|
|
52
53
|
default="ontpub",
|
|
53
54
|
)
|
|
54
55
|
|
|
@@ -79,6 +80,8 @@ def main():
|
|
|
79
80
|
sort_subjects = args.sort
|
|
80
81
|
if args.profile == "ontpub":
|
|
81
82
|
html = OntPub(args.input, sort_subjects=sort_subjects)
|
|
83
|
+
elif args.profile == "valpub":
|
|
84
|
+
html = ValPub(args.input, sort_subjects=sort_subjects)
|
|
82
85
|
elif args.profile == "vocpub":
|
|
83
86
|
html = VocPub(args.input, sort_subjects=sort_subjects)
|
|
84
87
|
elif args.profile == "supermodel":
|
|
@@ -1,82 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
from collections import defaultdict
|
|
3
|
-
from itertools import chain
|
|
4
|
-
from pathlib import Path
|
|
5
|
-
from typing import Dict, Union
|
|
6
|
-
|
|
7
|
-
import dominate
|
|
8
|
-
from dominate.tags import (
|
|
9
|
-
a,
|
|
10
|
-
code,
|
|
11
|
-
dd,
|
|
12
|
-
div,
|
|
13
|
-
dl,
|
|
14
|
-
dt,
|
|
15
|
-
h1,
|
|
16
|
-
h2,
|
|
17
|
-
h3,
|
|
18
|
-
h4,
|
|
19
|
-
h5,
|
|
20
|
-
li,
|
|
21
|
-
link,
|
|
22
|
-
meta,
|
|
23
|
-
script,
|
|
24
|
-
section,
|
|
25
|
-
strong,
|
|
26
|
-
style,
|
|
27
|
-
sup,
|
|
28
|
-
table,
|
|
29
|
-
td,
|
|
30
|
-
tr,
|
|
31
|
-
ul,
|
|
32
|
-
)
|
|
33
|
-
from dominate.util import raw
|
|
34
|
-
from rdflib import Graph, Literal
|
|
35
|
-
from rdflib.namespace import (
|
|
36
|
-
DC,
|
|
37
|
-
DCTERMS,
|
|
38
|
-
FOAF,
|
|
39
|
-
ORG,
|
|
40
|
-
OWL,
|
|
41
|
-
PROF,
|
|
42
|
-
PROV,
|
|
43
|
-
RDF,
|
|
44
|
-
RDFS,
|
|
45
|
-
SDO,
|
|
46
|
-
SKOS,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
from ..rdf_elements import AGENT_PROPS, CLASS_PROPS, ONT_PROPS, ONTDOC, PROP_PROPS
|
|
50
|
-
from ..utils import (
|
|
51
|
-
PylodeError,
|
|
52
|
-
back_onts_label_props,
|
|
53
|
-
get_ns,
|
|
54
|
-
load_background_onts,
|
|
55
|
-
load_background_onts_titles,
|
|
56
|
-
load_ontology,
|
|
57
|
-
make_pylode_logo,
|
|
58
|
-
prop_obj_pair_html,
|
|
59
|
-
section_html,
|
|
60
|
-
sort_ontology,
|
|
61
|
-
)
|
|
62
|
-
from ..version import __version__
|
|
63
|
-
|
|
64
|
-
RDF_FOLDER = Path(__file__).parent / "rdf"
|
|
1
|
+
from pylode.utils import *
|
|
65
2
|
|
|
66
3
|
|
|
67
4
|
class OntPub:
|
|
68
|
-
"""
|
|
69
|
-
from OWL Ontologies.
|
|
5
|
+
"""Used to create HTML documentation from OWL Ontologies.
|
|
70
6
|
|
|
71
7
|
Use:
|
|
72
8
|
# initialise
|
|
73
|
-
|
|
9
|
+
x = OntPub(ontology="some-ontology-file.ttl")
|
|
74
10
|
|
|
75
11
|
# produce HTML
|
|
76
|
-
html =
|
|
12
|
+
html = x.make_html()
|
|
77
13
|
|
|
78
14
|
# or save HTML to a file
|
|
79
|
-
|
|
15
|
+
x.make_html(destination="some-resulting-html-file.html")
|
|
80
16
|
"""
|
|
81
17
|
|
|
82
18
|
def __init__(self, ontology: Union[Graph, Path, str], sort_subjects: bool = False):
|
|
@@ -134,6 +70,9 @@ class OntPub:
|
|
|
134
70
|
for s_ in g.subjects(RDF.type, OWL.Class):
|
|
135
71
|
g.add((s_, RDF.type, RDFS.Class))
|
|
136
72
|
|
|
73
|
+
for s_ in g.subjects(RDF.type, RDFS.Class):
|
|
74
|
+
g.add((s_, RDF.type, OWL.Class))
|
|
75
|
+
|
|
137
76
|
# # property types
|
|
138
77
|
# for s_ in chain(
|
|
139
78
|
# g.subjects(RDF.type, OWL.ObjectProperty),
|
|
@@ -183,25 +122,25 @@ class OntPub:
|
|
|
183
122
|
# we do these next few so we only need to loop through
|
|
184
123
|
# Class & Property properties once: single subject
|
|
185
124
|
for s_, o in g.subject_objects(RDFS.subClassOf):
|
|
186
|
-
g.add((o,
|
|
125
|
+
g.add((o, ONTPUB.superClassOf, s_))
|
|
187
126
|
|
|
188
127
|
for s_, o in g.subject_objects(RDFS.subPropertyOf):
|
|
189
|
-
g.add((o,
|
|
128
|
+
g.add((o, ONTPUB.superPropertyOf, s_))
|
|
190
129
|
|
|
191
130
|
for s_, o in g.subject_objects(RDFS.domain):
|
|
192
|
-
g.add((o,
|
|
131
|
+
g.add((o, ONTPUB.inDomainOf, s_))
|
|
193
132
|
|
|
194
133
|
for s_, o in g.subject_objects(SDO.domainIncludes):
|
|
195
|
-
g.add((o,
|
|
134
|
+
g.add((o, ONTPUB.inDomainIncludesOf, s_))
|
|
196
135
|
|
|
197
136
|
for s_, o in g.subject_objects(RDFS.range):
|
|
198
|
-
g.add((o,
|
|
137
|
+
g.add((o, ONTPUB.inRangeOf, s_))
|
|
199
138
|
|
|
200
139
|
for s_, o in g.subject_objects(SDO.rangeIncludes):
|
|
201
|
-
g.add((o,
|
|
140
|
+
g.add((o, ONTPUB.inRangeIncludesOf, s_))
|
|
202
141
|
|
|
203
142
|
for s_, o in g.subject_objects(RDF.type):
|
|
204
|
-
g.add((o,
|
|
143
|
+
g.add((o, ONTPUB.hasMember, s_))
|
|
205
144
|
|
|
206
145
|
#
|
|
207
146
|
# Agents
|
|
@@ -295,9 +234,7 @@ class OntPub:
|
|
|
295
234
|
"""Helper function for make_html(). Makes <body>???</body> content.
|
|
296
235
|
|
|
297
236
|
Just calls other helper functions in order"""
|
|
298
|
-
make_pylode_logo(
|
|
299
|
-
self.doc, __version__, "OntPub", "https://linked.data.gov.au/def/ontpub"
|
|
300
|
-
)
|
|
237
|
+
make_pylode_logo(self.doc, "OntPub", "https://linked.data.gov.au/def/ontpub")
|
|
301
238
|
self._make_metadata()
|
|
302
239
|
self._make_main_sections()
|
|
303
240
|
self._make_namespaces()
|
|
@@ -314,14 +251,14 @@ class OntPub:
|
|
|
314
251
|
):
|
|
315
252
|
iri = s_
|
|
316
253
|
for p_, o in self.ont.predicate_objects(s_):
|
|
317
|
-
if p_ in
|
|
254
|
+
if p_ in ONTOLOGY_PROPS:
|
|
318
255
|
this_onts_props[p_].append(o)
|
|
319
256
|
|
|
320
257
|
# make HTML for all props in order of ONT_PROPS
|
|
321
258
|
sec = div(h1(this_onts_props[DCTERMS.title]), id="metadata", _class="section")
|
|
322
259
|
sec.appendChild(h2("Metadata"))
|
|
323
260
|
d = dl(div(dt(strong("IRI")), dd(code(str(iri)))))
|
|
324
|
-
for prop in
|
|
261
|
+
for prop in ONTOLOGY_PROPS:
|
|
325
262
|
if prop in this_onts_props.keys():
|
|
326
263
|
d.appendChild(
|
|
327
264
|
prop_obj_pair_html(
|
|
@@ -605,7 +542,7 @@ class OntPub:
|
|
|
605
542
|
)
|
|
606
543
|
)
|
|
607
544
|
with ul(_class="second"):
|
|
608
|
-
for c in self.toc["classes"]:
|
|
545
|
+
for c in sorted(self.toc["classes"]):
|
|
609
546
|
li(a(c[1], href=c[0]), style="margin-left:10px;")
|
|
610
547
|
|
|
611
548
|
if (
|
|
@@ -615,7 +552,7 @@ class OntPub:
|
|
|
615
552
|
with li():
|
|
616
553
|
h4(a("Properties", href="#properties"))
|
|
617
554
|
with ul(_class="second"):
|
|
618
|
-
for c in self.toc["properties"]:
|
|
555
|
+
for c in sorted(self.toc["properties"]):
|
|
619
556
|
li(a(c[1], href=c[0]))
|
|
620
557
|
|
|
621
558
|
if (
|
|
@@ -639,7 +576,7 @@ class OntPub:
|
|
|
639
576
|
)
|
|
640
577
|
)
|
|
641
578
|
with ul(_class="second"):
|
|
642
|
-
for c in self.toc["objectproperties"]:
|
|
579
|
+
for c in sorted(self.toc["objectproperties"]):
|
|
643
580
|
li(a(c[1], href=c[0]), style="margin-left:10px;")
|
|
644
581
|
|
|
645
582
|
if (
|
|
@@ -649,7 +586,7 @@ class OntPub:
|
|
|
649
586
|
with li():
|
|
650
587
|
h4(a("Datatype Properties", href="#datatypeproperties"))
|
|
651
588
|
with ul(_class="second"):
|
|
652
|
-
for c in self.toc["datatypeproperties"]:
|
|
589
|
+
for c in sorted(self.toc["datatypeproperties"]):
|
|
653
590
|
li(a(c[1], href=c[0]))
|
|
654
591
|
|
|
655
592
|
if (
|
|
@@ -659,7 +596,7 @@ class OntPub:
|
|
|
659
596
|
with li():
|
|
660
597
|
h4(a("Annotation Properties", href="#annotationproperties"))
|
|
661
598
|
with ul(_class="second"):
|
|
662
|
-
for c in self.toc["annotationproperties"]:
|
|
599
|
+
for c in sorted(self.toc["annotationproperties"]):
|
|
663
600
|
li(a(c[1], href=c[0]))
|
|
664
601
|
|
|
665
602
|
if (
|
|
@@ -669,7 +606,7 @@ class OntPub:
|
|
|
669
606
|
with li():
|
|
670
607
|
h4(a("Functional Properties", href="#functionalproperties"))
|
|
671
608
|
with ul(_class="second"):
|
|
672
|
-
for c in self.toc["functionalproperties"]:
|
|
609
|
+
for c in sorted(self.toc["functionalproperties"]):
|
|
673
610
|
li(a(c[1], href=c[0]))
|
|
674
611
|
|
|
675
612
|
if (
|
|
@@ -679,7 +616,7 @@ class OntPub:
|
|
|
679
616
|
with li():
|
|
680
617
|
h4(a("Custom Datatypes", href="#datatypes"))
|
|
681
618
|
with ul(_class="second"):
|
|
682
|
-
for c in self.toc["datatypes"]:
|
|
619
|
+
for c in sorted(self.toc["datatypes"]):
|
|
683
620
|
li(a(c[1], href=c[0]))
|
|
684
621
|
|
|
685
622
|
with li():
|
|
@@ -50,7 +50,7 @@ from pylode.profiles.supermodel.query.common import (
|
|
|
50
50
|
get_values,
|
|
51
51
|
)
|
|
52
52
|
from pylode.profiles.supermodel.query.property_shape import get_class_properties_by_sh
|
|
53
|
-
from pylode.rdf_elements import AGENT_PROPS,
|
|
53
|
+
from pylode.rdf_elements import AGENT_PROPS, ONTOLOGY_PROPS, ONTPUB
|
|
54
54
|
from pylode.utils import (
|
|
55
55
|
back_onts_label_props,
|
|
56
56
|
load_background_onts,
|
|
@@ -493,7 +493,7 @@ class Query:
|
|
|
493
493
|
this_onts_props = defaultdict(list)
|
|
494
494
|
for s_ in self.graph.subjects(predicate=RDF.type, object=PROF.Profile):
|
|
495
495
|
for p_, o in self.graph.predicate_objects(s_):
|
|
496
|
-
if p_ in
|
|
496
|
+
if p_ in ONTOLOGY_PROPS:
|
|
497
497
|
this_onts_props[p_].append(o)
|
|
498
498
|
|
|
499
499
|
return this_onts_props
|
|
@@ -569,25 +569,25 @@ class Query:
|
|
|
569
569
|
# we do these next few so we only need to loop through
|
|
570
570
|
# Class & Property properties once: single subject
|
|
571
571
|
for s_, o in g.subject_objects(RDFS.subClassOf):
|
|
572
|
-
g.add((o,
|
|
572
|
+
g.add((o, ONTPUB.superClassOf, s_))
|
|
573
573
|
|
|
574
574
|
for s_, o in g.subject_objects(RDFS.subPropertyOf):
|
|
575
|
-
g.add((o,
|
|
575
|
+
g.add((o, ONTPUB.superPropertyOf, s_))
|
|
576
576
|
|
|
577
577
|
for s_, o in g.subject_objects(RDFS.domain):
|
|
578
|
-
g.add((o,
|
|
578
|
+
g.add((o, ONTPUB.inDomainOf, s_))
|
|
579
579
|
|
|
580
580
|
for s_, o in g.subject_objects(SDO.domainIncludes):
|
|
581
|
-
g.add((o,
|
|
581
|
+
g.add((o, ONTPUB.inDomainIncludesOf, s_))
|
|
582
582
|
|
|
583
583
|
for s_, o in g.subject_objects(RDFS.range):
|
|
584
|
-
g.add((o,
|
|
584
|
+
g.add((o, ONTPUB.inRangeOf, s_))
|
|
585
585
|
|
|
586
586
|
for s_, o in g.subject_objects(SDO.rangeIncludes):
|
|
587
|
-
g.add((o,
|
|
587
|
+
g.add((o, ONTPUB.inRangeIncludesOf, s_))
|
|
588
588
|
|
|
589
589
|
for s_, o in g.subject_objects(RDF.type):
|
|
590
|
-
g.add((o,
|
|
590
|
+
g.add((o, ONTPUB.hasMember, s_))
|
|
591
591
|
|
|
592
592
|
#
|
|
593
593
|
# Agents
|