Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewriting ontodoc based on domain-battery #742

Merged
merged 34 commits into from
May 25, 2024
Merged

Rewriting ontodoc based on domain-battery #742

merged 34 commits into from
May 25, 2024

Conversation

jesper-friis
Copy link
Collaborator

@jesper-friis jesper-friis commented Apr 5, 2024

Description

Rewriting and simplifying the ontodoc tool based on domain-battery. For now the python module is called ontodoc_rst.py.

Structure the generated document as follows:

==========
References
==========

Module: <first_module_name>
===========================

-------
Classes
-------

<class1>
--------

...

For each module, document:

  • classes
  • object properties
  • data properties
  • annotation properties
  • individuals
  • datatypes

Tasks

  • Reproduce all information included in the battery.rst file
  • Add tooling for creating other needed files, like index.rst (just a template that the user can improve)
  • Add a new ontodoc script/tool - instead of adding a new tool, the old ontodoc tool was extended to support .rst output. It doesn't run sphinx automatically, though...
  • Add small tutorial of how to use the tool
  • Add ontology metadata documentation to generated documentation
  • Add more semantic information to generated documentation
  • Add language to keys for localised values
  • Add default css file (common for all EMMO domain ontologies, could e.g. be downloaded from a common source...)
  • Add support for figures (e.g. by displaying links to known image formats as images)
  • Sort modules in a logical order, e.g. by namespace and import depth
  • Add a module dependency graph at the top
  • Add subclasses to generated documentation to support navigating the taxonomy
  • Is it possible to collapse the sidebar to make it easier to navigate to the right module?
  • Add anchor by prefLabel, to make it easier for people to find the IRI when one knows the prefLabel

The last points can maybe be done in a separate PR.

Type of change

  • Bug fix.
  • New feature.
  • Documentation update.
  • Test update.

Checklist

This checklist can be used as a help for the reviewer.

  • Is the code easy to read and understand?
  • Are comments for humans to read, not computers to disregard?
  • Does a new feature has an accompanying new test (in the CI or unit testing schemes)?
  • Has the documentation been updated as necessary?
  • Does this close the issue?
  • Is the change limited to the issue?
  • Are errors handled for all outcomes?
  • Does the new feature provide new restrictions on dependencies, and if so is this documented?

Comments

@jesper-friis jesper-friis marked this pull request as draft April 5, 2024 05:48
@jesper-friis jesper-friis mentioned this pull request Apr 12, 2024
15 tasks
@jesper-friis jesper-friis marked this pull request as ready for review May 1, 2024 20:13
Copy link

codecov bot commented May 1, 2024

Codecov Report

Attention: Patch coverage is 89.05473% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 73.22%. Comparing base (60dda59) to head (bf1fc98).

Files Patch % Lines
ontopy/ontodoc_rst.py 88.16% 20 Missing ⚠️
ontopy/excelparser.py 0.00% 1 Missing ⚠️
ontopy/utils.py 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #742      +/-   ##
==========================================
+ Coverage   72.11%   73.22%   +1.11%     
==========================================
  Files          17       18       +1     
  Lines        3486     3683     +197     
==========================================
+ Hits         2514     2697     +183     
- Misses        972      986      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

from ontopy.ontodoc_rst import OntologyDocumentation
import owlready2

emmo = get_ontology("https://w3id.org/emmo/1.0.0-rc1").load()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not so happy about tests that dowload EMMO. We already have many of those and they make the tests very slow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced it with the local animal ontology.

str(test_file),
str(outdir / "mammal.rst"),
]
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test what is actually created?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added simple tests for generated content...

Comment on lines 227 to 229
assert not {"isq.rdfxml", "catalog-v001.xml"}.difference(
os.listdir(outputdir / "emmo.info" / "emmo" / "disciplines")
) == {"isq.rdfxml", "catalog-v001.xml"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because onto.save() stores other files in addition to isq.rdfxml and the catalogue file. Explicitly checking for all created files will fail when new modules are added to EMMO disciplines.

Comment on lines 268 to 256
assert set(
os.listdir(outputdir / "emmo.info" / "emmo" / "disciplines")
) == {"isq.rdfxml", "catalog-v001.xml"}
assert not {"isq.rdfxml", "catalog-v001.xml"}.difference(
os.listdir(outputdir2 / "emmo.info" / "emmo" / "disciplines")
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? It is more difficult to read.

Copy link
Collaborator Author

@jesper-friis jesper-friis May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it is more difficult to read. But without this, the test is failing since onto.save() creates other files in addition to isq.rdfxml and the catalogue file.

We can either explicitly checking for all created files, but that will fail when new modules are added to EMMO disciplines.

Would it be more readable to rewrite the test as

created_files = set(os.listdir(outputdir2 / "emmo.info" / "emmo" / "disciplines"))
for fname in ("chameo.rdfxml", "catalog-v001.xml"):
    assert fname in created_files

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I prefer this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

ontopy/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@francescalb francescalb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but I prefer the change in one of the tests as you propose in the comment

@jesper-friis jesper-friis merged commit 15c7e76 into master May 25, 2024
12 checks passed
@jesper-friis jesper-friis deleted the ontodoc2 branch May 25, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants