Skip to content

Commit

Permalink
Add doc for implicit namespace packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozaq committed May 4, 2024
1 parent b23e3cc commit e07b8a4
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 19 deletions.
98 changes: 98 additions & 0 deletions docs/source/_templates/autoapi/python/module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{% if not obj.display %}
:orphan:

{% endif %}
:py:mod:`{{ obj.name }}`
=========={{ "=" * obj.name|length }}

.. py:module:: {{ obj.name }}
{% if obj.docstring %}
.. autoapi-nested-parse::

{{ obj.docstring|indent(3) }}

{% endif %}

{% block submodules %}
{% set visible_submodules = obj.submodules|selectattr("display")|list %}
{% if visible_submodules %}
Submodules
----------
.. toctree::
:titlesonly:
:maxdepth: 1

{% for submodule in visible_submodules %}
{{ submodule.short_name }}/index.rst
{% endfor %}


{% endif %}
{% endblock %}
{% block content %}
{% if obj.all is not none %}
{% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %}
{% elif obj.type is equalto("package") %}
{% set visible_children = obj.children|selectattr("display")|list %}
{% else %}
{% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %}
{% endif %}
{% if visible_children %}
{{ obj.type|title }} Contents
{{ "-" * obj.type|length }}---------

{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %}
{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %}
{% set visible_attributes = visible_children|selectattr("type", "equalto", "data")|list %}
{% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %}
{% block classes scoped %}
{% if visible_classes %}
Classes
~~~~~~~

.. autoapisummary::

{% for klass in visible_classes %}
{{ klass.id }}
{% endfor %}


{% endif %}
{% endblock %}

{% block functions scoped %}
{% if visible_functions %}
Functions
~~~~~~~~~

.. autoapisummary::

{% for function in visible_functions %}
{{ function.id }}
{% endfor %}


{% endif %}
{% endblock %}

{% block attributes scoped %}
{% if visible_attributes %}
Attributes
~~~~~~~~~~

.. autoapisummary::

{% for attribute in visible_attributes %}
{{ attribute.id }}
{% endfor %}


{% endif %}
{% endblock %}
{% endif %}
{% for obj_item in visible_children %}
{{ obj_item.render()|indent(0) }}
{% endfor %}
{% endif %}
{% endblock %}
19 changes: 8 additions & 11 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,23 @@
"members",
"undoc-members",
"show-inheritance",
"show-module-summary",
"imported-members",
]
autoapi_ignore = [
"**/tests/**",
"**/native/**",
"**/internal/**",
"**/\\w.*.py",
]

# autoapi_member_order = "groupwise"
autodoc_typehints = "both"
autoapi_python_class_content = "both"

add_module_names = False

autoapi_add_toctree_entry = False
autoapi_python_class_content = "class"
autoapi_template_dir = "_templates/autoapi"
autoapi_member_order = "groupwise"
autoapi_python_use_implicit_namespaces = True

add_module_names = False

def skip_submodules(app, what, name, obj, skip, options):
def skip_rules(app, what, name, obj, skip, options):
if what == "module":
skip = True
if what == "method":
Expand All @@ -86,8 +84,7 @@ def skip_submodules(app, what, name, obj, skip, options):


def setup(sphinx):
sphinx.connect("autoapi-skip-member", skip_submodules)

sphinx.connect("autoapi-skip-member", skip_rules)

# -- Automatic execution of jupyter notebooks --------------------------------
nb_execution_excludepatterns = []
Expand Down
20 changes: 12 additions & 8 deletions python_modules/jupedsim/jupedsim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
distribute_until_filled,
)
from jupedsim.geometry import Geometry
from jupedsim.geometry_utils import (
_geometry_from_coordinates,
_geometry_from_shapely,
_geometry_from_wkt,
)
from jupedsim.internal.tracing import Trace
from jupedsim.journey import JourneyDescription, Transition
from jupedsim.library import (
Expand Down Expand Up @@ -64,10 +59,22 @@
)

__version__ = get_build_info().library_version
"""
The version of this module.
"""

__commit__ = get_build_info().git_commit_hash
"""
Commit id that was used to build this module.
"""

__compiler__ = (
f"{get_build_info().compiler} ({get_build_info().compiler_version})"
)
"""
Id of the compiler used to build the native portion of this module.
"""


__all__ = [
"Agent",
Expand Down Expand Up @@ -113,9 +120,6 @@
"distribute_in_circles_by_density",
"distribute_in_circles_by_number",
"distribute_until_filled",
"_geometry_from_coordinates",
"_geometry_from_shapely",
"_geometry_from_wkt",
"get_build_info",
"set_debug_callback",
"set_error_callback",
Expand Down
Empty file.

0 comments on commit e07b8a4

Please sign in to comment.