From de7c7ae24197e4bf5cc699f751d388448a9bd670 Mon Sep 17 00:00:00 2001 From: Pierre-Etienne Date: Wed, 21 May 2025 22:17:42 +0200 Subject: [PATCH 1/2] for each custom directive add objtype equal to rust: --- python/sphinx_rust/directives/crate.py | 1 + python/sphinx_rust/directives/enum.py | 2 ++ python/sphinx_rust/directives/function.py | 1 + python/sphinx_rust/directives/module.py | 3 +++ python/sphinx_rust/directives/struct.py | 1 + 5 files changed, 8 insertions(+) diff --git a/python/sphinx_rust/directives/crate.py b/python/sphinx_rust/directives/crate.py index 96ec90c..27d05fd 100644 --- a/python/sphinx_rust/directives/crate.py +++ b/python/sphinx_rust/directives/crate.py @@ -67,6 +67,7 @@ def run(self) -> list[nodes.Node]: root += nodes.paragraph("", f"Version: {crate.version}") desc = addnodes.desc() + desc['objtype'] = f"{self.rust_domain.name}:crate" root += desc signature = addnodes.desc_signature(crate.name, f"pub mod {crate.name};") desc += signature diff --git a/python/sphinx_rust/directives/enum.py b/python/sphinx_rust/directives/enum.py index 7930f3d..a155166 100644 --- a/python/sphinx_rust/directives/enum.py +++ b/python/sphinx_rust/directives/enum.py @@ -49,6 +49,7 @@ def run(self) -> list[nodes.Node]: desc = addnodes.desc() root += desc if enum.variants: + desc['objtype'] = f"{self.rust_domain.name}:struct" sig_lines = [addnodes.desc_signature_line("", f"pub struct {enum.name} {{")] for var in enum.variants: # TODO types @@ -61,6 +62,7 @@ def run(self) -> list[nodes.Node]: signature = addnodes.desc_signature(enum.path_str, "", *sig_lines) signature["is_multiline"] = True else: + desc['objtype'] = f"{self.rust_domain.name}:enum" signature = addnodes.desc_signature( enum.path_str, f"pub enum {enum.name} {{}}" ) diff --git a/python/sphinx_rust/directives/function.py b/python/sphinx_rust/directives/function.py index 43de8d2..c7a7a30 100644 --- a/python/sphinx_rust/directives/function.py +++ b/python/sphinx_rust/directives/function.py @@ -46,6 +46,7 @@ def run(self) -> list[nodes.Node]: root = nodes.Element() desc = addnodes.desc() + desc['objtype'] = f"{self.rust_domain.name}:function" root += desc signature = addnodes.desc_signature( func.path_str, diff --git a/python/sphinx_rust/directives/module.py b/python/sphinx_rust/directives/module.py index 5d0cebc..d1dcc91 100644 --- a/python/sphinx_rust/directives/module.py +++ b/python/sphinx_rust/directives/module.py @@ -61,6 +61,9 @@ def run(self) -> list[nodes.Node]: root = nodes.Element() desc = addnodes.desc() + + desc['objtype'] = f"{self.rust_domain.name}:module" + root += desc signature = addnodes.desc_signature(module.path_str, f"pub mod {module.name};") desc += signature diff --git a/python/sphinx_rust/directives/struct.py b/python/sphinx_rust/directives/struct.py index 686215b..9732bd2 100644 --- a/python/sphinx_rust/directives/struct.py +++ b/python/sphinx_rust/directives/struct.py @@ -48,6 +48,7 @@ def run(self) -> list[nodes.Node]: root = nodes.Element() desc = addnodes.desc() + desc['objtype'] = f"{self.rust_domain.name}:struct" root += desc if struct.fields: sig_lines = [ From ffd1f02a5192cb3b4a47c0d498af764536ea42d7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 20:19:51 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- python/sphinx_rust/directives/crate.py | 2 +- python/sphinx_rust/directives/enum.py | 4 ++-- python/sphinx_rust/directives/function.py | 2 +- python/sphinx_rust/directives/module.py | 2 +- python/sphinx_rust/directives/struct.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/sphinx_rust/directives/crate.py b/python/sphinx_rust/directives/crate.py index 27d05fd..1d4d163 100644 --- a/python/sphinx_rust/directives/crate.py +++ b/python/sphinx_rust/directives/crate.py @@ -67,7 +67,7 @@ def run(self) -> list[nodes.Node]: root += nodes.paragraph("", f"Version: {crate.version}") desc = addnodes.desc() - desc['objtype'] = f"{self.rust_domain.name}:crate" + desc["objtype"] = f"{self.rust_domain.name}:crate" root += desc signature = addnodes.desc_signature(crate.name, f"pub mod {crate.name};") desc += signature diff --git a/python/sphinx_rust/directives/enum.py b/python/sphinx_rust/directives/enum.py index a155166..2cd5b0f 100644 --- a/python/sphinx_rust/directives/enum.py +++ b/python/sphinx_rust/directives/enum.py @@ -49,7 +49,7 @@ def run(self) -> list[nodes.Node]: desc = addnodes.desc() root += desc if enum.variants: - desc['objtype'] = f"{self.rust_domain.name}:struct" + desc["objtype"] = f"{self.rust_domain.name}:struct" sig_lines = [addnodes.desc_signature_line("", f"pub struct {enum.name} {{")] for var in enum.variants: # TODO types @@ -62,7 +62,7 @@ def run(self) -> list[nodes.Node]: signature = addnodes.desc_signature(enum.path_str, "", *sig_lines) signature["is_multiline"] = True else: - desc['objtype'] = f"{self.rust_domain.name}:enum" + desc["objtype"] = f"{self.rust_domain.name}:enum" signature = addnodes.desc_signature( enum.path_str, f"pub enum {enum.name} {{}}" ) diff --git a/python/sphinx_rust/directives/function.py b/python/sphinx_rust/directives/function.py index c7a7a30..83b6761 100644 --- a/python/sphinx_rust/directives/function.py +++ b/python/sphinx_rust/directives/function.py @@ -46,7 +46,7 @@ def run(self) -> list[nodes.Node]: root = nodes.Element() desc = addnodes.desc() - desc['objtype'] = f"{self.rust_domain.name}:function" + desc["objtype"] = f"{self.rust_domain.name}:function" root += desc signature = addnodes.desc_signature( func.path_str, diff --git a/python/sphinx_rust/directives/module.py b/python/sphinx_rust/directives/module.py index d1dcc91..2c7990a 100644 --- a/python/sphinx_rust/directives/module.py +++ b/python/sphinx_rust/directives/module.py @@ -62,7 +62,7 @@ def run(self) -> list[nodes.Node]: desc = addnodes.desc() - desc['objtype'] = f"{self.rust_domain.name}:module" + desc["objtype"] = f"{self.rust_domain.name}:module" root += desc signature = addnodes.desc_signature(module.path_str, f"pub mod {module.name};") diff --git a/python/sphinx_rust/directives/struct.py b/python/sphinx_rust/directives/struct.py index 9732bd2..2177c07 100644 --- a/python/sphinx_rust/directives/struct.py +++ b/python/sphinx_rust/directives/struct.py @@ -48,7 +48,7 @@ def run(self) -> list[nodes.Node]: root = nodes.Element() desc = addnodes.desc() - desc['objtype'] = f"{self.rust_domain.name}:struct" + desc["objtype"] = f"{self.rust_domain.name}:struct" root += desc if struct.fields: sig_lines = [