Skip to content

Commit 6b051fe

Browse files
authored
Merge pull request #65 from linkml/sphinx-docs
Sphinx docs
2 parents 2f470eb + c7a49fd commit 6b051fe

File tree

12 files changed

+462
-46
lines changed

12 files changed

+462
-46
lines changed

.github/workflows/doc_pages.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Sphinx Documentation
2+
on:
3+
push:
4+
branches: [ main ]
5+
6+
jobs:
7+
build-docs:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@main
12+
with:
13+
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
14+
15+
- name: Set up Python 3.
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: 3.9
19+
20+
- name: Install Poetry.
21+
uses: snok/[email protected]
22+
23+
- name: install
24+
run: poetry install -E docs
25+
26+
- name: Build documentation.
27+
run: |
28+
mkdir gh-pages
29+
touch gh-pages/.nojekyll
30+
cd docs/
31+
poetry run sphinx-build -b html . _build
32+
cp -r _build/* ../gh-pages/
33+
34+
- name: Deploy documentation.
35+
if: ${{ github.event_name == 'push' }}
36+
uses: JamesIves/[email protected]
37+
with:
38+
branch: gh-pages
39+
force: true
40+
folder: gh-pages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ wwwroot/*.js
22
node_modules
33
typings
44
dist
5+
schema_automator.egg-info/*

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
sys.path.insert(0, os.path.abspath('../..'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'Schema Automator'
21+
copyright = '2022, Chris Mungall'
22+
author = 'Chris Mungall'
23+
24+
# The full version, including alpha/beta/rc tags
25+
# release = '0.1.4'
26+
27+
28+
# -- General configuration ---------------------------------------------------
29+
30+
# Add any Sphinx extension module names here, as strings. They can be
31+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32+
# ones.
33+
extensions = [
34+
'sphinx.ext.autodoc',
35+
'sphinx.ext.githubpages',
36+
'sphinx.ext.autosectionlabel',
37+
'sphinx_rtd_theme',
38+
'sphinx_click',
39+
'sphinx.ext.viewcode',
40+
'sphinx.ext.todo',
41+
'sphinx.ext.coverage',
42+
'sphinx.ext.autosummary',
43+
'myst_parser',
44+
'sphinx.ext.intersphinx',
45+
'sphinxcontrib.mermaid'
46+
]
47+
48+
# The suffix(es) of source filenames.
49+
# You can specify multiple suffix as a list of string:
50+
# source_suffix = ['.rst', '.md']
51+
source_suffix = ['.rst', '.md']
52+
53+
# Add any paths that contain templates here, relative to this directory.
54+
templates_path = ['_templates']
55+
56+
# List of patterns, relative to source directory, that match files and
57+
# directories to ignore when looking for source files.
58+
# This pattern also affects html_static_path and html_extra_path.
59+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
60+
61+
62+
# -- Options for HTML output -------------------------------------------------
63+
64+
# The theme to use for HTML and HTML Help pages. See the documentation for
65+
# a list of builtin themes.
66+
#
67+
html_theme = 'sphinx_rtd_theme'
68+
69+
# Add any paths that contain custom static files (such as style sheets) here,
70+
# relative to this directory. They are copied after the builtin static files,
71+
# so a file named "default.css" will overwrite the builtin "default.css".
72+
html_static_path = ['_static']

docs/index.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.. Schema Automator documentation master file, created by
2+
sphinx-quickstart on Fri Apr 22 13:19:04 2022.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to Schema Automator's documentation!
7+
============================================
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
:caption: Contents:
12+
13+
introduction
14+
intro/index
15+
16+
17+
Indices and tables
18+
==================
19+
20+
* :ref:`genindex`
21+
* :ref:`modindex`
22+
* :ref:`search`

docs/intro/cli.rst

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
Command Line Usage
2+
------------------
3+
4+
Annotating Enums
5+
~~~~~~~~~~~~~~~~
6+
7+
This toolkit allows automated annotation of LinkML enums, mapping text
8+
strings to ontology terms.
9+
10+
The command line tool ``annotate-enums`` takes a LinkML schema, with
11+
enums and fills in the ``meaning`` slots.
12+
13+
See the `annotators <schema_automator/annotators/>`__ folder for docs
14+
15+
Converting TSVs
16+
~~~~~~~~~~~~~~~
17+
18+
The ``tsv2linkml`` command infers a single-class schema from a TSV
19+
datafile
20+
21+
.. code:: bash
22+
23+
tsv2linkml --help
24+
Usage: tsv2linkml [OPTIONS] TSVFILE
25+
26+
Infer a model from a TSV
27+
28+
Options:
29+
-o, --output TEXT Output file
30+
-c, --class_name TEXT Core class name in schema
31+
-n, --schema_name TEXT Schema name
32+
-s, --sep TEXT separator
33+
-E, --enum-columns TEXT column that is forced to be an enum
34+
--robot / --no-robot set if the TSV is a ROBOT template
35+
--help Show this message and exit.
36+
37+
Example:
38+
39+
.. code:: bash
40+
41+
tsv2linkml tests/resources/biobank-specimens.tsv
42+
43+
The ``tsvs2linkml`` command infers a multi-class schema from multiple
44+
TSV datafiles
45+
46+
.. code:: bash
47+
48+
tsvs2linkml --help
49+
Usage: tsvs2linkml [OPTIONS] [TSVFILES]...
50+
51+
Infer a model from multiple TSVs
52+
53+
Options:
54+
-o, --output TEXT Output file
55+
-n, --schema_name TEXT Schema name
56+
-s, --sep TEXT separator
57+
-E, --enum-columns TEXT column(s) that is forced to be an enum
58+
--enum-mask-columns TEXT column(s) that are excluded from being enums
59+
--max-enum-size INTEGER do not create an enum if more than max distinct
60+
members
61+
62+
--enum-threshold FLOAT if the number of distinct values / rows is less
63+
than this, do not make an enum
64+
65+
--robot / --no-robot set if the TSV is a ROBOT template
66+
--help Show this message and exit.
67+
68+
Converting OWL
69+
~~~~~~~~~~~~~~
70+
71+
.. code:: bash
72+
73+
owl2linkml --help
74+
Usage: owl2linkml [OPTIONS] OWLFILE
75+
76+
Infer a model from OWL Ontology
77+
78+
Note: input must be in functional syntax
79+
80+
Options:
81+
-n, --name TEXT Schema name
82+
--help Show this message and exit.
83+
84+
Example:
85+
86+
.. code:: bash
87+
88+
owl2linkml -n prov tests/resources/prov.ofn > prov.yaml
89+
90+
Note this works best on schema-style ontologies such as Prov
91+
92+
**NOT** recommended for terminological-style ontologies such as OBO
93+
94+
Converting RDF instance graphs
95+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
96+
97+
.. code:: bash
98+
99+
rdf2linkml --help
100+
Usage: rdf2linkml [OPTIONS] RDFFILE
101+
102+
Infer a model from RDF instance data
103+
104+
Options:
105+
-d, --dir TEXT [required]
106+
--help Show this message and exit.
107+
108+
Converting JSON Instance Data
109+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110+
111+
.. code:: bash
112+
113+
jsondata2linkml --help
114+
Usage: jsondata2linkml [OPTIONS] INPUT
115+
116+
Infer a model from JSON instance data
117+
118+
119+
120+
Options:
121+
--container-class-name TEXT name of root class
122+
-f, --format TEXT json or yaml (or json.gz or yaml.gz)
123+
--omit-null / --no-omit-null if true, ignore null values
124+
--help Show this message and exit.
125+
126+
Converting JSON-Schema
127+
~~~~~~~~~~~~~~~~~~~~~~
128+
129+
.. code:: bash
130+
131+
jsonschema2linkml --help
132+
Usage: jsonschema2linkml [OPTIONS] INPUT
133+
134+
Infer a model from JSON Schema
135+
136+
Options:
137+
-n, --name TEXT ID of schema [required]
138+
-f, --format TEXT JSON Schema format - yaml or json
139+
-o, --output TEXT output path
140+
--help Show this message and exit.
141+
142+
jsonschema2linkml example
143+
~~~~~~~~~~~~~~~~~~~~~~~~~
144+
145+
.. code:: bash
146+
147+
poetry run jsonschema2linkml -n test-model -f yaml -o vrs-linkml.yaml cp tests/resources/jsonschema/vrs.schema.json

docs/intro/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _get started:
2+
3+
Get Started
4+
===============================
5+
6+
.. toctree::
7+
:maxdepth: 3
8+
:caption: Contents:
9+
10+
install
11+
cli

docs/intro/install.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Installation
2+
------------
3+
4+
``schema-automator`` and its components require Python 3.9 or greater.
5+
6+
.. code:: bash
7+
8+
chmod 755 environment.sh
9+
. environment.sh
10+
pip install -r requirements.txt
11+
pip install -e .

docs/introduction.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
LinkML Schema Automator
2+
=======================
3+
4+
This is a toolkit that assists with:
5+
6+
1. Bootstrapping LinkML models from instance data
7+
8+
- TSVs and spreadsheets
9+
- SQLite databases
10+
- RDF instance graphs
11+
12+
2. Bootstrapping a LinkML model from a different schema representation
13+
(i.e. opposite of a linkml.generator)
14+
15+
- OWL (RDFS-like subset)
16+
- TODO: JSON-Schema, XSD, ShEx, SHACL, SQL DDL, FHIR, Python
17+
dataclasses/pydantic, etc
18+
19+
3. Using automated methods to enhance a model
20+
21+
- Using text mining and concept annotator APIs to enrich semantic
22+
enums
23+
- TODO: querying sparql endpoints to retrieve additional metadata
24+
25+
These can be composed together. For example, run ``tsvs2linkml``
26+
followed by ``annotate-enums``
27+
28+
The toolkit is still experimental. It is intended as an aid to schema
29+
creation rather than act as a formal conversion tool

0 commit comments

Comments
 (0)