From bc544633a22738f5ab835ffacdc7ae782c5bd9a3 Mon Sep 17 00:00:00 2001 From: p0lygun Date: Thu, 11 Jan 2024 01:40:43 +0530 Subject: [PATCH 1/2] chore(pre-commit): use github repo and update hooks --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7deb1b384..87df052f6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,19 +7,19 @@ repos: # Format Python - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 23.12.1 hooks: - id: black # Sort imports - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort additional_dependencies: ["toml"] # Lint Python - - repo: https://gitlab.com/PyCQA/flake8 - rev: 4.0.1 + - repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 hooks: - id: flake8 From 178ce94663cfd8f64922af9e187a41e3213fdce8 Mon Sep 17 00:00:00 2001 From: p0lygun Date: Thu, 11 Jan 2024 01:41:28 +0530 Subject: [PATCH 2/2] fix(autoapi_kivymd): monkey patch NestedParse in autoapi --- docs/sources/_extensions/autoapi_kivymd.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/sources/_extensions/autoapi_kivymd.py b/docs/sources/_extensions/autoapi_kivymd.py index c2c5117f8..0ea5b18b6 100644 --- a/docs/sources/_extensions/autoapi_kivymd.py +++ b/docs/sources/_extensions/autoapi_kivymd.py @@ -16,11 +16,14 @@ import autoapi import sphinx import unidecode +from autoapi.directives import NestedParse from autoapi.extension import LOGGER from autoapi.extension import setup as autoapi_setup from autoapi.mappers.python.mapper import PythonSphinxMapper from autoapi.mappers.python.objects import PythonPythonMapper +from docutils import nodes from sphinx.util.console import bold, darkgreen +from sphinx.util.nodes import nested_parse_with_titles from sphinx.util.osutil import ensuredir @@ -128,7 +131,21 @@ def extension_build_finished(app, exception): break +def patched_nested_parse_run(self): + node = nodes.container() + node.document = self.state.document + nested_parse_with_titles(self.state, self.content, node) + try: + title_node = node[0][0] + if isinstance(title_node, nodes.title): + title_node.children.pop(0) + except IndexError: + pass + return node.children + + def setup(app): + NestedParse.run = patched_nested_parse_run PythonPythonMapper.pathname = property(PythonPythonMapper_pathname) PythonPythonMapper.include_dir = PythonPythonMapper_include_dir PythonSphinxMapper.output_rst = PythonSphinxMapper_output_rst