Skip to content

Commit de7c0bb

Browse files
Addition of documenttaion pages (#16)
* Updated Sphinx documentation New Index.rst page, Old index.rst page became corese.rst. Added new pages: python_api/api_root.rst with autogenerated API doc. Added python_api/bridges.rst page The example1.ipynb notebook is rendered as a uset_guide. INSTALL.md is rendered as an installation page * Added the installation of the packages from the docs/requirements.txt in case a new extension is added. * Moved VIESION.txt to src/pycorese to update the version only in one place. * Minor fixes and updates
1 parent 4f73eca commit de7c0bb

19 files changed

+557
-255
lines changed

CHANGES.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
# Changelog
22

3+
## Version 0.1.5
4+
5+
- added corese-python/pycorese API documentation
6+
- wraps corese-core v4.6.0
7+
8+
## Version 0.1.4
9+
10+
- downgraded version to 0.1.4 since it's not ready for 1.0.0 yet
11+
- updated markdown documentation
12+
- wraps corese-core v4.6.0
13+
314
## Version 1.0.1
415

5-
- document local installaiton process (INSTALL.md)
16+
- document local installation process (INSTALL.md)
617
- build jar file then running `python -m build` (may need more work)
718
- add doc skeleton and github action files
819
- add coreseVersion (not fully implemented yet)

INSTALL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The custom `sdist` command adds the following steps:
8787
> [!NOTE]
8888
> - do not run `python setup.py` that will not build the full package.
8989
> - the versions of `pycorese` and Java libraries are maintained separately.
90-
> - `corese-python` version should be the same as `corese-core` it depends on, for simplicity reasons.
90+
> - `corese-python` version should be the same as `corese-core` it depends on, for simplicity reasons.
9191
> - the commands for the first two steps are provided in the [Obtaining Java libraries manually](#obtain-java-libraries-manually) section.
9292

9393
## Testing the package
@@ -134,7 +134,7 @@ pip install dist/pycorese-0.1.1.tar.gz
134134

135135
## Verifying the installation
136136

137-
```
137+
```bash
138138
$ pip list | grep corese
139139
pycorese 0.1.1
140140
@@ -148,13 +148,13 @@ $ python -c 'import pycorese'
148148

149149
Without installing the package you can run the following command (the default Java bridge is `py4j`):
150150

151-
```
151+
```bash
152152
./examples/simple_query.py -j $PWD/build/libs/corese-python-4.6.0-jar-with-dependencies.jar
153153
```
154154

155155
or change the bridge to `jpype`:
156156

157-
```
157+
```bash
158158
./examples/simple_query.py -b jpype -j $PWD/build/libs/corese-core-4.6.0-jar-with-dependencies.jar
159159
```
160160

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
**pycorese** is a Python package that provides a simple way to integrate the [corese-core](https://github.com/corese-stack/corese-core) Java library into Python applications.
2424

25-
**pycorese** provides an intuitive API to interact with Corese's capabilities such as storage, SPARQL engine, RDFS and OWL reasoning, and SHACL validation.
25+
**pycorese** offers an intuitive API to interact with Corese's capabilities such as storage, SPARQL engine, RDFS and OWL reasoning, and SHACL validation.
2626

2727
**pycorese** unlocks the potential of Semantic Web stack for applications such as semantic data analysis, knowledge graph construction, and Machine Learning.
2828

VERSION.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ sphinx-multiversion docs/source build/html
2222

2323
## Switcher generation
2424

25-
- To navigate between versions by means of the switcher (the dropdown list indicating the available version), the switcher.json object must be generated.
26-
- To improve navigability, a landing page must also be generated to redirect to the latest version of the documentation.
25+
- To navigate between versions by means of the switcher (the dropdown list indicating the available version), the switcher.json object must be generated.
26+
- To improve navigability, a landing page must also be generated to redirect to the latest version of the documentation.
2727

2828
To this end a script must be executed and write the output to the output html directory:
2929

@@ -33,4 +33,4 @@ To this end a script must be executed and write the output to the output html di
3333

3434
Both sphinx-multiversion and switcher_generator work on tags following the ```^v[0-9]+\.[0-9]+\.[0-9]+$``` syntax and ordered by refname.
3535

36-
The minimal version set in the switcher_generator allows to not generate entries in the switcher and landing page for unexisting or uncompatible documentation.
36+
The minimal version set in the switcher_generator allows to not generate entries in the switcher and landing page for nonexisting or incompatible documentation.

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ docutils<0.21,>=0.18.1
66
Jinja2>=3.0
77
sphinx-design==0.5.0
88
myst-parser==2.0.0
9+
myst_nb==1.1.2
910
sphinxcontrib-mermaid==0.9.2
1011
breathe==4.35.0
1112
exhale==0.3.7

docs/source/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
user_guide.ipynb
2+
dev_install.md

docs/source/apis.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
CORESE APIs
1+
.. The links for corese-command and corese-server are not available in the corese-stack at the moment.
2+
.. Using the old repository documentation at https://wimmics.github.io/corese.
3+
4+
Corese APIs
25
###########
36

47
.. toctree::
58
:hidden:
69

7-
Python API
8-
910
.. grid:: 2
1011

1112
.. grid-item-card::
1213
:shadow: sm
1314
:class-card: sd-rounded-3
14-
:link: https://corese-stack.github.io/corese-core/
15+
:link: https://corese-stack.github.io/corese-core/v4.6.0/java_api/library_root.html
1516

1617
Corese Java API
1718
^^^^^^^^^^^^^^^^^^^^^^^
@@ -31,7 +32,7 @@ CORESE APIs
3132
.. grid-item-card::
3233
:shadow: sm
3334
:class-card: sd-rounded-3
34-
:link: https://corese-stack.github.io/corese-command/
35+
:link: https://wimmics.github.io/corese/cli_ref/cli_root.html
3536

3637
Corese command-line interface
3738
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -47,7 +48,7 @@ CORESE APIs
4748
.. grid-item-card::
4849
:shadow: sm
4950
:class-card: sd-rounded-3
50-
:link: https://github.com/corese-stack/corese-server/
51+
:link: https://wimmics.github.io/corese/rest_api/api_root.html
5152

5253
Corese REST API
5354
^^^^^^^^^^^^^^^^^^^^^^^
@@ -62,7 +63,7 @@ CORESE APIs
6263
.. grid-item-card::
6364
:shadow: sm
6465
:class-card: sd-rounded-3
65-
:link: https://github.com/corese-stack/corese-python/
66+
:link: python_api/api_root.html
6667

6768
Corese Python API
6869
^^^^^^^^^^^^^^^^^^^^^^^
@@ -73,4 +74,4 @@ CORESE APIs
7374
* run SPARQL queries (SELECT, CONSTRUCT, ASK, UPDATE)
7475
* validate RDF data against SHACL shapes
7576

76-
in development...
77+
and more...

docs/source/conf.py

Lines changed: 97 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,71 +10,64 @@
1010
# add these directories to sys.path here.
1111
import pathlib
1212
import sys
13-
import os
13+
import shutil
1414

15-
sys.path.insert(0, pathlib.Path(__file__).parents[1].resolve().as_posix())
16-
sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())
17-
#sys.path.insert(0, pathlib.Path(__file__).parents[2].joinpath('code').resolve().as_posix())
15+
# -- Path to the Python source code ------------------------------------------------
16+
sys.path.insert(0, pathlib.Path(__file__).parents[2].joinpath('src').resolve().as_posix())
1817

18+
# -- Copy files for docs --------------------------------------------------
19+
#
20+
# To avoid duplicating the information and symlinks
21+
shutil.copyfile(pathlib.Path(__file__).parents[2].joinpath('INSTALL.md'), "dev_install.md")
22+
shutil.copyfile(pathlib.Path(__file__).parents[2].joinpath('examples/example1.ipynb'), "user_guide.ipynb")
1923

20-
project = 'CORESE-PYTHON'
24+
# -- Project information -----------------------------------------------------
25+
project = 'corese-python'
2126
copyright = '2024, WIMMICS'
22-
author = 'WIMMICS'
23-
24-
# -- General configuration ---------------------------------------------------
25-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
26-
27-
extensions = [
28-
'sphinx.ext.duration', # to display the duration of Sphinx processing
29-
'sphinx.ext.todo', # to include todo items in the documentation
30-
# Uncomment the following lines if/when include the python code (not used in this project yet)
31-
#'sphinx.ext.doctest', # to test code snippets in the documentation
32-
#'sphinx.ext.autodoc', # to automatically generate documentation from docstrings
33-
#'sphinx.ext.autosummary', # this extension generates function/method/attribute summary lists
34-
#'sphinx.ext.autosectionlabel', # to automatically generate section labels
35-
'sphinx_multiversion',
36-
'sphinx_design', # to render panels
37-
'myst_parser', # to parse markdown
38-
'sphinxcontrib.mermaid', # to render mermaid diagrams
39-
# Alternative ways to include markdown files, cannot be used together with myst_parser
40-
# advantages of sphynx_mdinclude/m2r3: it can include partial markdown files
41-
#
42-
#'sphinx_mdinclude', # to include partial markdown files
43-
#'m2r3', # to include markdown files
44-
'sphinx_copybutton', # to add copy buttons to code blocks
45-
]
46-
47-
templates_path = ['_templates']
48-
exclude_patterns = []
27+
author = 'Corese Team'
4928

5029
# The suffix(es) of source filenames.
5130
source_suffix = ['.rst', '.md']
31+
#exclude_patterns = []
5232

53-
# -- Options for HTML output -------------------------------------------------
54-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
33+
# Add any paths that contain templates here, relative to this directory.
34+
templates_path = ['_templates']
5535

56-
html_theme = 'pydata_sphinx_theme'
36+
# Add any paths that contain data files here, relative to this directory.
5737
html_static_path = ['_static']
5838

39+
# Define the css files to include in the documentation
5940
html_css_files = [
6041
"css/custom.css",
6142
]
43+
44+
# Define the js files to include in the documentation
6245
html_js_files = []
6346

47+
# -- Options for HTML output -------------------------------------------------
48+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
49+
html_sidebars = {
50+
#"corese": [], # syntax for hiding the sidebar
51+
}
52+
53+
# Tell sphinx what the pygments highlight language should be.
54+
highlight_language = 'python'
55+
6456
# Project logo, to place at the top of the sidebar.
6557
html_logo = "_static/corese.svg"
6658

6759
# Icon to put in the browser tab.
6860
html_favicon = "_static/Corese-square-logo-transparent.svg"
6961

7062
# Modify the title to get good social-media links
71-
html_title = "CORESE-PYTHON"
72-
html_short_title = "CORESE-PYTHON"
63+
#html_title = "CORESE-PYTHON"
64+
#html_short_title = "CORESE-PYTHON"
7365

7466
# -- Theme Options -----------------------------------------------------------
7567
# Theme options are theme-specific and customize the look and feel of a theme
7668
# further. For a list of options available for each theme, see the
77-
# documentation.
69+
# documentation. https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
70+
html_theme = 'pydata_sphinx_theme'
7871
html_theme_options = {
7972
"logo": {
8073
"image_relative": "_static/corese.svg",
@@ -93,27 +86,78 @@
9386
"switcher": {"json_url": "https://corese-stack.github.io/corese-python/switcher.json", "version_match": r"v\d+\.\d+\.\d+"}
9487
}
9588

96-
html_sidebars = {
97-
"install": [],
98-
}
99-
100-
# -- MySt-parcer extension Options -------------------------------------------
101-
# https://myst-parser.readthedocs.io/en/latest/
102-
103-
myst_heading_anchors = 4
104-
myst_fence_as_directive = ["mermaid"]
10589

106-
# Tell sphinx what the primary language being documented is.
107-
primary_domain = 'python'
90+
# -- General configuration ---------------------------------------------------
91+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
92+
extensions = [
93+
'sphinx.ext.duration', # to display the duration of Sphinx processing
94+
'sphinx.ext.todo', # to include todo items in the documentation
95+
#'sphinx.ext.githubpages', # to deploy the documentation on GitHub pages ???
96+
'sphinx.ext.viewcode', # to add links to the source code
97+
'sphinx.ext.doctest', # to test code snippets in the documentation
98+
'sphinx.ext.autodoc', # to automatically generate documentation from docstrings
99+
'sphinx.ext.autosummary', # this extension generates function/method/attribute summary lists
100+
'sphinx.ext.autosectionlabel', # to automatically generate section labels
101+
'sphinx.ext.napoleon', # to parse Google-style docstrings
102+
'sphinx_design', # to render panels
103+
#'myst_parser', # to parse markdown
104+
"myst_nb", # to parse jupyter notebooks and markdown files
105+
#'sphinxcontrib.mermaid', # to render mermaid diagrams
106+
# Alternative ways to include markdown files, cannot be used together with myst_parser
107+
# advantages of sphynx_mdinclude/m2r3: it can include partial markdown files
108+
#
109+
#'sphinx_mdinclude', # to include partial markdown files
110+
#'m2r3', # to include markdown files
111+
'sphinx_copybutton', # to add copy buttons to code blocks
112+
'sphinx_multiversion', # to build documentation for multiple versions
113+
]
108114

109-
# Tell sphinx what the pygments highlight language should be.
110-
highlight_language = 'python'
115+
# -- Options for sphinx.ext.autodoc / sphinx.ext.autosummary-----------------------------
116+
# generate autosummary even if no references
117+
#autodoc_default_flags = ["members", "inherited-members"]
118+
autosummary_generate = True
119+
120+
autodoc_default_options = {
121+
#"member-order": "bysource",
122+
#"special-members": "__init__",
123+
# "undoc-members": True,
124+
# "show-inheritance": True,
125+
# "template": "_templates/base.rst", # Path to your template
126+
}
111127

112-
# Setup the sphinx.ext.todo extension
128+
# -- Options for sphinx.ext.napoleon----------------------------------------
129+
napoleon_google_docstring = True
130+
napoleon_numpy_docstring = True
131+
napoleon_use_admonition_for_notes = True
132+
napoleon_use_rtype = False
113133

114-
# Set to false in the final version
134+
# -- Setup the sphinx.ext.todo extension ------------------------------------
135+
# TODO: Set to false in the final version
115136
todo_include_todos = True
116137

138+
# -- sphinx-multiversion extension configuration -----------------------------------
117139
# Optional: Exclude certain branches or tags from multi-versioning
118140
#smv_branch_whitelist = r'develop' # TODO Build documentation only for feature/retrieve-doc, must be replaced with "main" for production
119141
smv_tag_whitelist = r'^v\d+\.\d+.*$' # Only build tags that match version pattern like v1.0
142+
143+
# -- MyST-NB configuration ---------------------------------------------------
144+
# https://myst-nb.readthedocs.io/en/latest/
145+
# Take the example notebook as-is, without executing it
146+
nb_execution_mode = "off"
147+
148+
# Suppress warnings
149+
suppress_warnings = [
150+
"myst.xref_missing", # Suppress warnings about missing references after fixing the one you can fix
151+
"mystnb.unknown_mime_type" # Suppress warnings about Google Colab button in the notebook
152+
]
153+
154+
# Substitute the relative path in the markdown file for the GitHub repo root URL
155+
def preprocess_markdown(app, docname, source):
156+
base_url = "https://github.com/corese-stack/corese-python/blob/main/"
157+
if docname == "dev_install": # Replace with the actual document using the Markdown file
158+
content = source[0]
159+
# Replace relative paths with appropriate links
160+
source[0] = content.replace("./" , base_url)
161+
162+
def setup(app):
163+
app.connect("source-read", preprocess_markdown)

0 commit comments

Comments
 (0)