Skip to content

Commit

Permalink
Fixed #225. Handling of empty class folders. (#226)
Browse files Browse the repository at this point in the history
* Fixed #225. Handling of empty class folders.

* Added empty class folder.
  • Loading branch information
joeced authored Dec 10, 2023
1 parent b52664c commit 408039c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
sphinxcontrib-matlabdomain-0.X.Y (2023-MM-DD)
==============================================

* Fixed `Issue 225`. Empty ``@classfolder`` would throw an assertion error.

.. _Issue 225: https://github.com/sphinx-contrib/matlabdomain/issues/225


sphinxcontrib-matlabdomain-0.20.2 (2023-09-15)
==============================================

Expand Down
4 changes: 4 additions & 0 deletions sphinxcontrib/mat_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ def isClassFolderModule(name, entity):
# Find the class entity class.
class_entities = [e for e in cf_entity.entities if isinstance(e[1], MatClass)]
func_entities = [e for e in cf_entity.entities if isinstance(e[1], MatFunction)]

empty_class_folder = not class_entities and not func_entities
if empty_class_folder:
continue
assert len(class_entities) == 1
cls = class_entities[0][1]

Expand Down
2 changes: 1 addition & 1 deletion tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pathlib import Path

def rootdir(the_file):
return Path(os.path.dirname(__file__)).absolute()
return Path(os.path.dirname(__file__)).resolve().absolute()

else:
from sphinx.testing.path import path as sphinx_path
Expand Down
1 change: 1 addition & 0 deletions tests/test_data/@EmptyClassFolder/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Intentionally empty folder. Tests https://github.com/sphinx-contrib/matlabdomain/issues/225
1 change: 1 addition & 0 deletions tests/test_matlabify.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def test_module(mod):
expected_items = {
"+package",
"@ClassFolder",
"@EmptyClassFolder",
"Application",
"ClassAbstract",
"ClassExample",
Expand Down

0 comments on commit 408039c

Please sign in to comment.