Skip to content

Commit

Permalink
fixed an issue with EOTask signature, bumped Sphinx version and minor…
Browse files Browse the repository at this point in the history
… cleanup
  • Loading branch information
AleksMat committed Jan 30, 2022
1 parent 228eeb5 commit 1a6a260
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
dependencies:
- cartopy=0.17.0
- pip:
- Sphinx
- Sphinx~=4.0
- sphinx-rtd-theme
- nbsphinx
- jupyter
Expand Down
33 changes: 19 additions & 14 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@

import sphinx.ext.autodoc

import eolearn.core
import eolearn.coregistration
import eolearn.features
import eolearn.geometry
import eolearn.io
import eolearn.mask
import eolearn.ml_tools
import eolearn.visualization
from eolearn.core import EOTask


# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -205,6 +215,14 @@ def setup(app):
intersphinx_mapping = {"https://docs.python.org/3.8/": None}


# -- Custom settings ----------------------------------------------

# When Sphinx documents class signature it prioritizes __new__ method over __init__ method. The following hack puts
# EOTask.__new__ method the the blacklist so that __init__ method signature will be taken instead. This seems the
# cleanest way even though a private object is accessed.
sphinx.ext.autodoc._CLASS_NEW_BLACKLIST.append("{0.__module__}.{0.__qualname__}".format(EOTask.__new__))


EXAMPLES_FOLDER = "./examples"
MARKDOWNS_FOLDER = "./markdowns"

Expand Down Expand Up @@ -288,19 +306,6 @@ def get_subclasses(cls):
return list(set(direct_subclasses).union(nested_subclasses))


def get_eotasks():
import eolearn.core
import eolearn.coregistration
import eolearn.features
import eolearn.geometry
import eolearn.io
import eolearn.mask
import eolearn.ml_tools
import eolearn.visualization

return get_subclasses(eolearn.core.EOTask)


with open("eotasks.rst", "w") as f:
f.write("*******\n")
f.write("EOTasks\n")
Expand All @@ -309,7 +314,7 @@ def get_eotasks():

eopackage_tasks = {}

for eotask_cls in get_eotasks():
for eotask_cls in get_subclasses(EOTask):
eopackage = eotask_cls.__module__.split(".")[1]
eotask = eotask_cls.__module__ + "." + eotask_cls.__name__

Expand Down
2 changes: 1 addition & 1 deletion requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sphinx
Sphinx~=4.0
sphinx-rtd-theme
nbsphinx
jupyter
Expand Down

0 comments on commit 1a6a260

Please sign in to comment.