diff --git a/sphinxcontrib/matlab.py b/sphinxcontrib/matlab.py index e822816..8373764 100644 --- a/sphinxcontrib/matlab.py +++ b/sphinxcontrib/matlab.py @@ -258,6 +258,14 @@ def get_index_text(self, modname, name): def add_target_and_index(self, name_cls, sig, signode): modname = self.options.get("module", self.env.temp_data.get("mat:module")) + if self.env.config.matlab_short_links and not name_cls[0] == modname: + # modname is only used for package names + # - "target.+package" => "package" + # - "target" => "" + parts = modname.split(".") + parts = [part for part in parts if part.startswith("+")] + modname = ".".join(parts) + fullname = (modname and modname + "." or "") + name_cls[0] fullname = fullname.lstrip(".")