From b7f1a0e75bfbb2043841c1a745b30119becbf0e7 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 24 May 2023 20:27:58 +0300 Subject: [PATCH 1/2] extension: rename docstring cache to hawkmoth_parsed_files Follow the hawkmoth naming more consistently with s/cautodoc_parsed_files/hawkmoth_parsed_files/ --- src/hawkmoth/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hawkmoth/__init__.py b/src/hawkmoth/__init__.py index 651c9882..a4810527 100644 --- a/src/hawkmoth/__init__.py +++ b/src/hawkmoth/__init__.py @@ -70,7 +70,7 @@ def __parse(self, filename): clang_args.extend(self.__get_clang_args()) # Cached parse results per rst document - parsed_files = self.env.temp_data.setdefault('cautodoc_parsed_files', {}) + parsed_files = self.env.temp_data.setdefault('hawkmoth_parsed_files', {}) # The output depends on clang args key = (filename, tuple(clang_args)) From 386953b18abc59f8beb0e7defc0f0387bf9eddca Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 24 May 2023 20:28:36 +0300 Subject: [PATCH 2/2] extension: cache directive filename option across directives When documenting lots of symbols from a file, it gets tedious to repeat the :file: option: .. c:autofunction:: foo :file: baz.c .. c:autofunction:: bar :file: baz.c Cache the filename from the :file: option across directives within a document. --- src/hawkmoth/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hawkmoth/__init__.py b/src/hawkmoth/__init__.py index a4810527..9054d175 100644 --- a/src/hawkmoth/__init__.py +++ b/src/hawkmoth/__init__.py @@ -161,6 +161,12 @@ class _AutoSymbolDirective(_AutoBaseDirective): def _get_filenames(self): filename = self.options.get('file') + # Cache filename across directives in rst document + if filename: + self.env.temp_data['hawkmoth_current_file'] = filename + else: + filename = self.env.temp_data.get('hawkmoth_current_file') + # Note: For the time being the file option is mandatory (sic). if not filename: self.logger.warning(':file: option missing.',