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

Update api template usage #216

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
- id: check-github-workflows
args: [--verbose]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.25.0
rev: v3.25.1
hooks:
- id: commitizen
stages: [commit-msg]
Expand All @@ -64,6 +64,15 @@ repos:
rev: 1.16.0
hooks:
- id: yamlfix
# TODO: get this working
# - repo: https://github.com/motet-a/jinjalint
# rev: "0.5"
# hooks:
# - id: jinjalint
- repo: https://github.com/thibaudcolas/curlylint
rev: v0.13.1
hooks:
- id: curlylint
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Valid subsections within a version are:

Things to be included in the next release go here.

### Added

- Added a new section in the documentation of each package/subpackage that shows the submodules (files) of that package/subpackage.

### Removed

- docs: Removed the copy code button from the Python API signatures in the documentation.
Expand All @@ -26,6 +30,7 @@ Things to be included in the next release go here.

- Updated most `__init__.py` files to not include `__all__` variable definitions.
- Renamed some of the abstract base classes to separate them from the actual device driver classes.
- Updated the documentation templates to use the new jinja template style that `mkdocstrings-python` is switching to.

---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{# Original source file: https://github.com/mkdocstrings/python/blob/main/src/mkdocstrings_handlers/python/templates/material/_base/children.html#}
{# Original source file: https://github.com/mkdocstrings/python/blob/main/src/mkdocstrings_handlers/python/templates/material/_base/children.html.jinja#}
{#- Template for members (children) of an object.

This template iterates on members of a given object and renders them.
It can group members by category (attributes, classes, functions, modules) or render them in a flat list.

Context:
obj (griffe.dataclasses.Object): The object to render.
config (dict): The configuration options.
root_members (bool): Whether the object is the root object.
heading_level (int): The HTML heading level to use.
-#}
{%- macro create_summary_table(item_list) -%}
<table>
<tbody>
Expand All @@ -21,7 +32,13 @@
{%- endmacro -%}

{% if obj.members %}
{{ log.debug("Rendering children of " + obj.path) }}
{% block logs scoped %}
{#- Logging block.

This block can be used to log debug messages, deprecation messages, warnings, etc.
-#}
{{ log.debug("Rendering children of " + obj.path) }}
{% endblock logs %}

<div class="doc doc-children">

Expand Down Expand Up @@ -76,6 +93,17 @@
{{ create_summary_table(functions) }}
{% endif %}
{% endwith %}
{% with modules = obj.modules|filter_objects(
filters=config.filters,
members_list=members_list,
inherited_members=config.inherited_members,
keep_no_docstrings=config.show_if_no_docstring)|selectattr("is_init_module", "equalto", false)|list|order_members(config.members_order, members_list)
%}
{% if modules %}
{% filter heading(heading_level, id=html_id ~ "-modules") %}Submodules{% endfilter %}
{{ create_summary_table(modules) }}
{% endif %}
{% endwith %}
{% else %}
{% if config.group_by_category %}

Expand All @@ -99,7 +127,7 @@
{% endif %}
{% with heading_level = heading_level + extra_level %}
{% for attribute in attributes|order_members(config.members_order, members_list) %}
{% if not attribute.is_alias or attribute.is_explicitely_exported or attribute.inherited %}
{% if members_list is not none or attribute.is_public(check_name=False) %}
{% include attribute|get_template with context %}
{% endif %}
{% endfor %}
Expand All @@ -119,7 +147,7 @@
{% endif %}
{% with heading_level = heading_level + extra_level %}
{% for class in classes|order_members(config.members_order, members_list) %}
{% if not class.is_alias or class.is_explicitely_exported or class.inherited %}
{% if members_list is not none or class.is_public(check_name=False) %}
{% include class|get_template with context %}
{% endif %}
{% endfor %}
Expand All @@ -140,7 +168,7 @@
{% with heading_level = heading_level + extra_level %}
{% for function in functions|order_members(config.members_order, members_list) %}
{% if not (obj.kind.value == "class" and function.name == "__init__" and config.merge_init_into_class) %}
{% if not function.is_alias or function.is_explicitely_exported or function.inherited %}
{% if members_list is not none or function.is_public(check_name=False) %}
{% include function|get_template with context %}
{% endif %}
{% endif %}
Expand All @@ -162,7 +190,7 @@
{% endif %}
{% with heading_level = heading_level + extra_level %}
{% for module in modules|order_members(config.members_order, members_list) %}
{% if not module.is_alias or module.is_explicitely_exported or module.inherited %}
{% if members_list is not none or module.is_public(check_name=False) %}
{% include module|get_template with context %}
{% endif %}
{% endfor %}
Expand All @@ -186,7 +214,7 @@

{% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %}

{% if not child.is_alias or child.is_explicitely_exported or child.inherited %}
{% if members_list is not none or child.is_public(check_name=False) %}
{% if child.is_attribute %}
{% with attribute = child %}
{% include attribute|get_template with context %}
Expand Down
6 changes: 3 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ mkdocs-mermaid2-plugin==1.1.1 ; python_version >= "3.8" and python_version < "4.
mkdocs-section-index==0.3.9 ; python_version >= "3.8" and python_version < "4.0"
mkdocs-spellcheck==1.1.0 ; python_version >= "3.8" and python_version < "4.0"
mkdocstrings==0.25.1 ; python_version >= "3.8" and python_version < "4.0"
mkdocstrings-python==1.10.0 ; python_version >= "3.8" and python_version < "4.0"
mkdocstrings-python==1.10.2 ; python_version >= "3.8" and python_version < "4.0"
mypy-extensions==1.0.0 ; python_version >= "3.8" and python_version < "4.0"
packaging==24.0 ; python_version >= "3.8" and python_version < "4.0"
pathspec==0.12.1 ; python_version >= "3.8" and python_version < "4.0"
platformdirs==4.2.1 ; python_version >= "3.8" and python_version < "4.0"
platformdirs==4.2.2 ; python_version >= "3.8" and python_version < "4.0"
pygments==2.18.0 ; python_version >= "3.8" and python_version < "4.0"
pymdown-extensions==10.8.1 ; python_version >= "3.8" and python_version < "4.0"
python-dateutil==2.9.0.post0 ; python_version >= "3.8" and python_version < "4.0"
Expand All @@ -50,6 +50,6 @@ tomli==2.0.1 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.11.0 ; python_version >= "3.8" and python_version < "3.11"
urllib3==2.2.1 ; python_version >= "3.8" and python_version < "4.0"
watchdog==4.0.0 ; python_version >= "3.8" and python_version < "4.0"
wcmatch==8.5.1 ; python_version >= "3.8" and python_version < "4.0"
wcmatch==8.5.2 ; python_version >= "3.8" and python_version < "4.0"
wheel==0.43.0 ; python_version >= "3.8" and python_version < "3.9"
zipp==3.18.1 ; python_version >= "3.8" and python_version < "3.10"
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ pre-commit = [
]
pre-commit-update = "^0.3.0"
pyclean = "^3.0.0"
pylint = "3.1.0"
pyright = "1.1.362"
pylint = "3.2.0"
pyright = "1.1.363"
pyroma = "^4.2"
python-semantic-release = "^9.6.0"
ruff = "0.4.4"
Expand Down Expand Up @@ -140,7 +140,7 @@ mkdocs-mermaid2-plugin = "^1.1.1"
mkdocs-section-index = "^0.3.9"
mkdocs-spellcheck = "^1.1.0"
mkdocstrings = "^0.25.0"
mkdocstrings-python = "^1.10.0"
mkdocstrings-python = "^1.10.2"
pygments = "^2.17.2"
pymdown-extensions = "^10.8.1"
symspellpy = "^6.7.7"
Expand Down
2 changes: 1 addition & 1 deletion src/tm_devices/helpers/constants_and_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __str__(self) -> str:
for key, val in self.to_dict(ignore_none=True).items():
# must pull class type from actual value, not the to_dict()'s representation
if (
prefix := CONFIG_CLASS_STR_PREFIX_MAPPING.get(type(getattr(self, key)))
prefix := CONFIG_CLASS_STR_PREFIX_MAPPING.get(type(getattr(self, key))) # pyright: ignore[reportUnknownArgumentType]
) is not None:
if any(val.values()):
# still need to ignore the None values
Expand Down
Loading